|
|
@@ -144,14 +144,14 @@ class Afterpay extends Payment
|
|
|
'verify' => false
|
|
|
]);
|
|
|
$resultObject = json_decode($response->getBody()->getContents());
|
|
|
- if ($resultObject->token == 'APPROVED') {
|
|
|
- return true;
|
|
|
+ if ($resultObject->status == 'APPROVED') {
|
|
|
+ return ['transaction_id' => $resultObject->token];
|
|
|
} else {
|
|
|
- return false;
|
|
|
+ return [];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function paymentsSuccess($orderId, $transactionId)
|
|
|
+ public function captureAndVerify($orderId, $transactionId)
|
|
|
{
|
|
|
$order = app(OrderRepository::class)->find($orderId);
|
|
|
if (!$order->id) {
|
|
|
@@ -166,17 +166,7 @@ class Afterpay extends Payment
|
|
|
if ($transactionId != $token) {
|
|
|
return new \Exception('order token is error');
|
|
|
}
|
|
|
- if (!$this->capture($token)) {
|
|
|
- return new \Exception('order capture fail');
|
|
|
- }
|
|
|
- $order->status = Order::STATUS_PROCESSING;
|
|
|
- $order->save();
|
|
|
- $additional['transaction_id'] = $transactionId;
|
|
|
- if ($order->payment) {
|
|
|
- $order->payment->additional = $additional;
|
|
|
- $order->payment->save();
|
|
|
- }
|
|
|
- return true;
|
|
|
+ return $this->capture($token);
|
|
|
}
|
|
|
|
|
|
public function getBaseUlr()
|
|
|
@@ -209,8 +199,7 @@ class Afterpay extends Payment
|
|
|
return false;
|
|
|
}
|
|
|
$info = $this->getOrder() ?: Cart::getCart();
|
|
|
- if ($info) {
|
|
|
- $billingCountry = $info->billing_address->country;
|
|
|
+ if ($info && $billingCountry = $info->billing_address->country ?? false) {
|
|
|
$allowedCountries = ['AU', 'CA', 'NZ', 'GB', 'US'];
|
|
|
return in_array($billingCountry, $allowedCountries);
|
|
|
}
|