|
|
@@ -16,6 +16,7 @@ class Afterpay extends Payment
|
|
|
protected $apikey;
|
|
|
protected $secret;
|
|
|
protected $currentOrder;
|
|
|
+ protected $currentInput;
|
|
|
protected $createPaymentUlr = 'https://global-api-sandbox.afterpay.com/v2/checkouts';
|
|
|
protected $capturePaymentUlr = 'https://global-api-sandbox.afterpay.com/v2/payments/capture';
|
|
|
|
|
|
@@ -23,7 +24,7 @@ class Afterpay extends Payment
|
|
|
{
|
|
|
if ($this->getConfigData('mode') == 'live') {
|
|
|
$this->createPaymentUlr = 'https://global-api.afterpay.com/v2/checkouts';
|
|
|
- $this->capturePaymentUlr = 'https://global-api-sandbox.afterpay.com/v2/payments/capture';
|
|
|
+ $this->capturePaymentUlr = 'https://global-api.afterpay.com/v2/payments/capture';
|
|
|
}
|
|
|
$this->clientId = $this->getConfigData('client_id');
|
|
|
$this->apikey = $this->getConfigData('secret_id');
|
|
|
@@ -46,17 +47,30 @@ class Afterpay extends Payment
|
|
|
{
|
|
|
return $this->currentOrder;
|
|
|
}
|
|
|
+ public function setInput($input = null): self
|
|
|
+ {
|
|
|
+ $this->currentInput = $input;
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
|
|
|
+ public function getInput()
|
|
|
+ {
|
|
|
+ return $this->currentInput;
|
|
|
+ }
|
|
|
public function createGatewayOrder()
|
|
|
{
|
|
|
try {
|
|
|
- return $this->createPayment($this->getOrder(), ['merchantOrderId' => $this->getOrder()->increment_id]);
|
|
|
+ return $this->createPayment(
|
|
|
+ $this->getOrder(),
|
|
|
+ ['merchantOrderId' => $this->getOrder()->increment_id],
|
|
|
+ $this->getInput()
|
|
|
+ );
|
|
|
} catch (\Exception $e) {
|
|
|
throw new \Exception($e->getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function createPayment($order, $override)
|
|
|
+ public function createPayment($order, $override, $input = null)
|
|
|
{
|
|
|
$shop = $order->shipping_address;
|
|
|
$bill = $order->billing_address;
|
|
|
@@ -106,8 +120,8 @@ class Afterpay extends Payment
|
|
|
'countryCode' => $shop->country,
|
|
|
],
|
|
|
'merchant' => [
|
|
|
- 'redirectConfirmUrl' => $this->getBaseUlr() . '/afterpay/return?order_id=' . $override['merchantOrderId'],
|
|
|
- 'redirectCancelUrl' => $this->getBaseUlr() . '/afterpay/return?order_id=' . $override['merchantOrderId']
|
|
|
+ 'redirectConfirmUrl' => $input->paymentSuccessUrl . '?orderId=' . $order->id,
|
|
|
+ 'redirectCancelUrl' => $input->paymentCancelUrl. '?orderId=' . $order->id
|
|
|
],
|
|
|
'items' => $products
|
|
|
];
|