mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fixes for base driver
This commit is contained in:
parent
c19d088bd9
commit
29c013191e
@ -82,7 +82,9 @@ class CreditCard
|
|||||||
|
|
||||||
public function authorizeView($data)
|
public function authorizeView($data)
|
||||||
{
|
{
|
||||||
// $hash = Cache::put(Str::random(32), 'cc_auth', 300);
|
$hash = Str::random(32);
|
||||||
|
|
||||||
|
Cache::put($hash, 'cc_auth', 300);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'merchant_id' => $this->payfast->company_gateway->getConfigField('merchantId'),
|
'merchant_id' => $this->payfast->company_gateway->getConfigField('merchantId'),
|
||||||
@ -91,7 +93,9 @@ class CreditCard
|
|||||||
'cancel_url' => route('client.payment_methods.index'),
|
'cancel_url' => route('client.payment_methods.index'),
|
||||||
'notify_url' => $this->payfast->genericWebhookUrl(),
|
'notify_url' => $this->payfast->genericWebhookUrl(),
|
||||||
'amount' => 5,
|
'amount' => 5,
|
||||||
|
'm_payment_id' => $hash,
|
||||||
'item_name' => 'pre-auth',
|
'item_name' => 'pre-auth',
|
||||||
|
'item_description' => 'Credit Card Pre Authorization',
|
||||||
'subscription_type' => 2,
|
'subscription_type' => 2,
|
||||||
'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'),
|
'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'),
|
||||||
];
|
];
|
||||||
|
@ -20,6 +20,7 @@ use App\PaymentDrivers\PayFast\CreditCard;
|
|||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
use \PayFastPayment;
|
use \PayFastPayment;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
|
||||||
class PayFastPaymentDriver extends BaseDriver
|
class PayFastPaymentDriver extends BaseDriver
|
||||||
{
|
{
|
||||||
@ -122,24 +123,67 @@ class PayFastPaymentDriver extends BaseDriver
|
|||||||
return $this->payment_method->yourTokenBillingImplmentation(); //this is your custom implementation from here
|
return $this->payment_method->yourTokenBillingImplmentation(); //this is your custom implementation from here
|
||||||
}
|
}
|
||||||
|
|
||||||
public function generateSignature($data, $passPhrase = null)
|
// public function generateSignature($data, $passPhrase = null)
|
||||||
|
// {
|
||||||
|
// // Create parameter string
|
||||||
|
// $pfOutput = '';
|
||||||
|
// foreach( $data as $key => $val ) {
|
||||||
|
// if($val !== '') {
|
||||||
|
// $pfOutput .= $key .'='. urlencode( trim( $val ) ) .'&';
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// // Remove last ampersand
|
||||||
|
// $getString = substr( $pfOutput, 0, -1 );
|
||||||
|
// if( $passPhrase !== null ) {
|
||||||
|
// $getString .= '&passphrase='. urlencode( trim( $passPhrase ) );
|
||||||
|
// }
|
||||||
|
// nlog($getString);
|
||||||
|
// return md5( $getString );
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
protected function generateSignature($data, $passPhrase = null)
|
||||||
{
|
{
|
||||||
// Create parameter string
|
$fields = array();
|
||||||
$pfOutput = '';
|
|
||||||
foreach( $data as $key => $val ) {
|
// specific order required by PayFast
|
||||||
if($val !== '') {
|
// @see https://developers.payfast.co.za/documentation/#checkout-page
|
||||||
$pfOutput .= $key .'='. urlencode( trim( $val ) ) .'&';
|
foreach (array('merchant_id', 'merchant_key', 'return_url', 'cancel_url', 'notify_url', 'name_first',
|
||||||
|
'name_last', 'email_address', 'cell_number',
|
||||||
|
/**
|
||||||
|
* Transaction Details
|
||||||
|
*/
|
||||||
|
'm_payment_id', 'amount', 'item_name', 'item_description',
|
||||||
|
/**
|
||||||
|
* Custom return data
|
||||||
|
*/
|
||||||
|
'custom_int1', 'custom_int2', 'custom_int3', 'custom_int4', 'custom_int5',
|
||||||
|
'custom_str1', 'custom_str2', 'custom_str3', 'custom_str4', 'custom_str5',
|
||||||
|
/**
|
||||||
|
* Email confirmation
|
||||||
|
*/
|
||||||
|
'email_confirmation', 'confirmation_address',
|
||||||
|
/**
|
||||||
|
* Payment Method
|
||||||
|
*/
|
||||||
|
'payment_method',
|
||||||
|
/**
|
||||||
|
* Subscriptions
|
||||||
|
*/
|
||||||
|
'subscription_type', 'billing_date', 'recurring_amount', 'frequency', 'cycles',
|
||||||
|
/**
|
||||||
|
* Passphrase for md5 signature generation
|
||||||
|
*/
|
||||||
|
'passphrase') as $key) {
|
||||||
|
if (!empty($data[$key])) {
|
||||||
|
$fields[$key] = $data[$key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Remove last ampersand
|
|
||||||
$getString = substr( $pfOutput, 0, -1 );
|
return md5(http_build_query($fields));
|
||||||
if( $passPhrase !== null ) {
|
|
||||||
$getString .= '&passphrase='. urlencode( trim( $passPhrase ) );
|
|
||||||
}
|
|
||||||
nlog($getString);
|
|
||||||
return md5( $getString );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function processWebhookRequest(Request $request, Payment $payment = null)
|
public function processWebhookRequest(Request $request, Payment $payment = null)
|
||||||
{
|
{
|
||||||
$this->init();
|
$this->init();
|
||||||
@ -147,10 +191,17 @@ class PayFastPaymentDriver extends BaseDriver
|
|||||||
nlog($request->all());
|
nlog($request->all());
|
||||||
$data = $request->all();
|
$data = $request->all();
|
||||||
|
|
||||||
if(array_key_exists('m_payment_id', $data) && $data['m_payment_id'] == 'pre-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);
|
return response()->json([], 200);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user