diff --git a/app/PaymentDrivers/PayFast/CreditCard.php b/app/PaymentDrivers/PayFast/CreditCard.php index 2d2b49990b..51d48e5f68 100644 --- a/app/PaymentDrivers/PayFast/CreditCard.php +++ b/app/PaymentDrivers/PayFast/CreditCard.php @@ -21,6 +21,7 @@ use App\Models\PaymentType; use App\Models\SystemLog; use App\PaymentDrivers\PayFastPaymentDriver; use Illuminate\Support\Str; +use Illuminate\Support\Facades\Cache; class CreditCard { @@ -81,6 +82,8 @@ class CreditCard public function authorizeView($data) { + $hash = Cache::put(Str::random(32), 'cc_auth', 300); + $data = [ 'merchant_id' => $this->payfast->company_gateway->getConfigField('merchantId'), 'merchant_key' => $this->payfast->company_gateway->getConfigField('merchantKey'), @@ -88,9 +91,8 @@ class CreditCard 'cancel_url' => route('client.payment_methods.index'), 'notify_url' => $this->payfast->genericWebhookUrl(), 'amount' => 5, + 'm_payment_id' => $hash, 'item_name' => 'pre-auth', - // 'item_description' => 'cc_auth', - 'custom_str1' => 'cc_auth', 'subscription_type' => 2, 'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'), ]; diff --git a/app/PaymentDrivers/PayFastPaymentDriver.php b/app/PaymentDrivers/PayFastPaymentDriver.php index d1e131e841..9c17acb43b 100644 --- a/app/PaymentDrivers/PayFastPaymentDriver.php +++ b/app/PaymentDrivers/PayFastPaymentDriver.php @@ -20,6 +20,7 @@ use App\PaymentDrivers\PayFast\CreditCard; use App\Utils\Traits\MakesHash; use \PayFastPayment; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Cache; class PayFastPaymentDriver extends BaseDriver { @@ -146,10 +147,17 @@ class PayFastPaymentDriver extends BaseDriver nlog($request->all()); $data = $request->all(); - if(array_key_exists('custom_str1', $data) && $data['custom_str1'] == 'cc_auth') + if(array_key_exists('m_payment_id', $data)) { - return $this->setPaymentMethod(GatewayType::CREDIT_CARD) - ->authorizeResponse($request); + + $hash = Cache::get($data['m_payment_id']); + + if($hash == 'cc_auth') + { + return $this->setPaymentMethod(GatewayType::CREDIT_CARD) + ->authorizeResponse($request); + } + } return response()->json([], 200); diff --git a/app/Utils/PhantomJS/Phantom.php b/app/Utils/PhantomJS/Phantom.php index ca957ffe9b..57495c8411 100644 --- a/app/Utils/PhantomJS/Phantom.php +++ b/app/Utils/PhantomJS/Phantom.php @@ -26,9 +26,9 @@ use App\Utils\CurlUtils; use App\Utils\HtmlEngine; use App\Utils\Traits\MakesHash; use Illuminate\Support\Facades\App; -use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Response; use Illuminate\Support\Facades\Storage; +use Illuminate\Support\Facades\Cache; use Illuminate\Support\Str; class Phantom