|
|
@@ -300,29 +300,33 @@ class Afterpay extends Payment
|
|
|
}
|
|
|
$countryCode = $order->billing_address->country ?? null;
|
|
|
$this->resolveCredentials($countryCode);
|
|
|
- $client = new Client();
|
|
|
- $response = $client->request('GET', $this->orderStatusUlr . $gatewayOrderId, [
|
|
|
- 'headers' => [
|
|
|
- 'Accept' => 'application/json',
|
|
|
- 'Content-Type' => 'application/json',
|
|
|
- 'Authorization' => 'Basic ' . base64_encode("{$this->clientId}:{$this->apikey}")
|
|
|
- ],
|
|
|
- 'timeout' => 30,
|
|
|
- 'verify' => false,
|
|
|
- ]);
|
|
|
- $responseBody = $response->getBody()->getContents();
|
|
|
- Log::channel('payment')->info("{$order->payment->method} fetchOrderStatus response", [
|
|
|
- 'gatewayOrderId' => $gatewayOrderId,
|
|
|
- 'status' => $response->getStatusCode(),
|
|
|
- 'body' => $responseBody
|
|
|
- ]);
|
|
|
- $resultObject = json_decode($responseBody);
|
|
|
$paymentStatus = [];
|
|
|
$paymentStatus['captures'] = null;
|
|
|
$paymentStatus['status'] = null;
|
|
|
- if ($resultObject->status == 'APPROVED' && $resultObject->paymentState == 'CAPTURED') {
|
|
|
- $paymentStatus['captures'] = true;
|
|
|
- $paymentStatus['status'] = 'COMPLETED';
|
|
|
+ try {
|
|
|
+ $client = new Client();
|
|
|
+ $response = $client->request('GET', $this->orderStatusUlr . $gatewayOrderId, [
|
|
|
+ 'headers' => [
|
|
|
+ 'Accept' => 'application/json',
|
|
|
+ 'Content-Type' => 'application/json',
|
|
|
+ 'Authorization' => 'Basic ' . base64_encode("{$this->clientId}:{$this->apikey}")
|
|
|
+ ],
|
|
|
+ 'timeout' => 30,
|
|
|
+ 'verify' => false,
|
|
|
+ ]);
|
|
|
+ $responseBody = $response->getBody()->getContents();
|
|
|
+ Log::channel('payment')->info("{$order->payment->method} fetchOrderStatus response", [
|
|
|
+ 'gatewayOrderId' => $gatewayOrderId,
|
|
|
+ 'status' => $response->getStatusCode(),
|
|
|
+ 'body' => $responseBody
|
|
|
+ ]);
|
|
|
+ $resultObject = json_decode($responseBody);
|
|
|
+ if ($resultObject->status == 'APPROVED' && $resultObject->paymentState == 'CAPTURED') {
|
|
|
+ $paymentStatus['captures'] = true;
|
|
|
+ $paymentStatus['status'] = 'COMPLETED';
|
|
|
+ }
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ Log::channel('payment')->error("{$order->payment->method} fetchOrderStatus error: " . $e->getMessage());
|
|
|
}
|
|
|
return $paymentStatus;
|
|
|
}
|