|
@@ -3,6 +3,7 @@
|
|
|
namespace Longyi\Pay\Afterpay\Payment;
|
|
namespace Longyi\Pay\Afterpay\Payment;
|
|
|
|
|
|
|
|
use GuzzleHttp\Client;
|
|
use GuzzleHttp\Client;
|
|
|
|
|
+use Illuminate\Support\Facades\Log;
|
|
|
use Illuminate\Support\Facades\Storage;
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
use Webkul\Payment\Payment\Payment;
|
|
use Webkul\Payment\Payment\Payment;
|
|
|
use Webkul\Sales\Models\Order;
|
|
use Webkul\Sales\Models\Order;
|
|
@@ -136,7 +137,14 @@ class Afterpay extends Payment
|
|
|
'timeout' => 30,
|
|
'timeout' => 30,
|
|
|
'verify' => false
|
|
'verify' => false
|
|
|
]);
|
|
]);
|
|
|
- $resultObject = json_decode($response->getBody()->getContents());
|
|
|
|
|
|
|
+ $responseBody = $response->getBody()->getContents();
|
|
|
|
|
+ Log::channel('payment')->info('Afterpay createPayment response', [
|
|
|
|
|
+ 'order_id' => $order->increment_id ?? null,
|
|
|
|
|
+ 'status' => $response->getStatusCode(),
|
|
|
|
|
+ 'body' => $responseBody,
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ $resultObject = json_decode($responseBody);
|
|
|
if (empty($resultObject->token)) {
|
|
if (empty($resultObject->token)) {
|
|
|
throw new \Exception($resultObject->message);
|
|
throw new \Exception($resultObject->message);
|
|
|
} else {
|
|
} else {
|
|
@@ -157,7 +165,14 @@ class Afterpay extends Payment
|
|
|
'timeout' => 30,
|
|
'timeout' => 30,
|
|
|
'verify' => false
|
|
'verify' => false
|
|
|
]);
|
|
]);
|
|
|
- $resultObject = json_decode($response->getBody()->getContents());
|
|
|
|
|
|
|
+ $responseBody = $response->getBody()->getContents();
|
|
|
|
|
+ Log::channel('payment')->info('Afterpay capture response', [
|
|
|
|
|
+ 'token' => $token,
|
|
|
|
|
+ 'status' => $response->getStatusCode(),
|
|
|
|
|
+ 'body' => $responseBody,
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ $resultObject = json_decode($responseBody);
|
|
|
if ($resultObject->status == 'APPROVED') {
|
|
if ($resultObject->status == 'APPROVED') {
|
|
|
return ['transaction_id' => $resultObject->token, 'amount' => $resultObject->events[0]->amount->amount];
|
|
return ['transaction_id' => $resultObject->token, 'amount' => $resultObject->events[0]->amount->amount];
|
|
|
} else {
|
|
} else {
|