Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/hyperpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
*/
'transaction_model' => 'Devinweb\LaravelHyperpay\Models\Transaction',

'notificationUrl' => '/hyperpay/webhook'
'notificationUrl' => '/hyperpay/webhook',
];
8 changes: 2 additions & 6 deletions src/LaravelHyperpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class LaravelHyperpay implements Hyperpay
*/
protected $gateway_url = 'https://test.oppwa.com';


/**
* @var bool demand to register the user card
*/
Expand Down Expand Up @@ -180,15 +179,12 @@ public function paymentStatus(string $resourcePath, string $checkout_id)
return $response;
}

/**
*
*/
public function recurringPayment(string $registration_id, $amount, $checkout_id)
{
$result = (new HttpClient($this->client, $this->gateway_url.'/v1/registrations/'.$registration_id.'/payments', $this->config))->post(
(new HttpParameters())->postRecurringPayment($amount, $this->redirect_url, $checkout_id),
);

$response = (new HttpResponse($result, null, []))->recurringPayment();

return $response;
Expand Down Expand Up @@ -221,7 +217,7 @@ public function addRedirectUrl($url)
}

/**
* Set the register user card information, to use it when we prepare the checkout
* Set the register user card information, to use it when we prepare the checkout.
*
* @return $this
*/
Expand Down
36 changes: 18 additions & 18 deletions src/Support/HttpParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,25 @@ public function getParams($checkout_id): array
}

/**
* Generate the params that used in the recurring payment
* @param string $amount
* @param string $shopperResultUrl
* @param string $checkout_id That define the entity_id related to the registration id.
* Generate the params that used in the recurring payment.
*
* @param string $amount
* @param string $shopperResultUrl
* @param string $checkout_id That define the entity_id related to the registration id.
* @return array
*/
public function postRecurringPayment($amount, $shopperResultUrl, $checkout_id)
{
$currency = config('hyperpay.currency');

return array_merge([
"standingInstruction.mode"=>"REPEATED",
"standingInstruction.type" => "RECURRING",
"standingInstruction.source"=>"MIT",
"amount"=> $amount,
"currency" => $currency,
"paymentType"=>"PA",
"shopperResultUrl" => $shopperResultUrl
'standingInstruction.mode'=>'REPEATED',
'standingInstruction.type' => 'RECURRING',
'standingInstruction.source'=>'MIT',
'amount'=> $amount,
'currency' => $currency,
'paymentType'=>'PA',
'shopperResultUrl' => $shopperResultUrl,
], $this->getParams($checkout_id));
}

Expand All @@ -86,24 +87,23 @@ protected function getBodyParameters($amount, Model $user, $heyPerPayConfig): ar
'customer.givenName' => $user->name,
'customer.surname' => $user->name,
// 'customer.mobile' => '',
'customer.browser.userAgent' => $heyPerPayConfig['userAgent'],
'customer.browser.language' => config('app.locale'),
];

return $body_parameters;
}

/**
* The init recurring payment params
* The init recurring payment params.
*
* @return array
*/
protected function registerPaymentData()
{
return [
"standingInstruction.mode"=>"INITIAL",
"standingInstruction.type" => "RECURRING",
"standingInstruction.source"=>"CIT",
"createRegistration"=>true,
'standingInstruction.mode'=>'INITIAL',
'standingInstruction.type' => 'RECURRING',
'standingInstruction.source'=>'CIT',
'createRegistration'=>true,
];
}

Expand Down