PayFast API token billing

This commit is contained in:
David Bomba 2021-09-23 17:50:58 +10:00
parent 72093e57f6
commit dbb45e705e

View File

@ -77,24 +77,32 @@ class Token
$amount = array_sum(array_column($payment_hash->invoices(), 'amount')) + $payment_hash->fee_total; $amount = array_sum(array_column($payment_hash->invoices(), 'amount')) + $payment_hash->fee_total;
$amount = round(($amount * pow(10, $this->payfast->client->currency()->precision)),0); $amount = round(($amount * pow(10, $this->payfast->client->currency()->precision)),0);
$header =[ // $header =[
'merchant-id' => $this->payfast->company_gateway->getConfigField('merchantId'), // 'merchant-id' => $this->payfast->company_gateway->getConfigField('merchantId'),
'timestamp' => now()->format('c'), // 'timestamp' => now()->format('c'),
'version' => 'v1', // 'version' => 'v1',
]; // ];
$body = [ // $body = [
'amount' => $amount, // 'amount' => $amount,
'item_name' => 'purchase', // 'item_name' => 'purchase',
'item_description' => ctrans('texts.invoices') . ': ' . collect($payment_hash->invoices())->pluck('invoice_number'), // 'item_description' => ctrans('texts.invoices') . ': ' . collect($payment_hash->invoices())->pluck('invoice_number'),
// 'm_payment_id' => $payment_hash->hash, // // 'm_payment_id' => $payment_hash->hash,
]; // ];
$header['signature'] = md5( $this->generate_parameter_string(array_merge($header, $body), false) ); // $header['signature'] = md5( $this->generate_parameter_string(array_merge($header, $body), false) );
$result = $this->send($header, $body, $cgt->token); // $result = $this->send($header, $body, $cgt->token);
nlog($result);
$adhocArray = $this->payfast
->init()
->payfast
->subscriptions
->adhoc($cgt->token, ['amount' => $amount, 'item_name' => 'purchase']);
nlog($adhocArray);
// /*Refactor and push to BaseDriver*/ // /*Refactor and push to BaseDriver*/
// if ($data['response'] != null && $data['response']->getMessages()->getResultCode() == 'Ok') { // if ($data['response'] != null && $data['response']->getMessages()->getResultCode() == 'Ok') {