|
@@ -108,8 +108,8 @@ class GuestDeclarationOrderService
|
|
|
if ($draft->STATUS !== GuestDeclarationDraftStatus::PENDING_PAYMENT || $draft->isExpired()) {
|
|
if ($draft->STATUS !== GuestDeclarationDraftStatus::PENDING_PAYMENT || $draft->isExpired()) {
|
|
|
throw new BadRequestHttpException('Only an active pending-payment draft can be debug-completed.');
|
|
throw new BadRequestHttpException('Only an active pending-payment draft can be debug-completed.');
|
|
|
}
|
|
}
|
|
|
- if ((float) $draft->PAY_AMOUNT <= 0 || !$draft->CURRENCY) {
|
|
|
|
|
- throw new BadRequestHttpException('The guest draft has no valid payment amount.');
|
|
|
|
|
|
|
+ if (!$draft->PAYMENT_REFERENCE || (float) $draft->PAY_AMOUNT <= 0 || !$draft->CURRENCY) {
|
|
|
|
|
+ throw new BadRequestHttpException('The guest draft has no valid initialized payment.');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$now = gmdate('Y-m-d\\TH:i:s\\Z');
|
|
$now = gmdate('Y-m-d\\TH:i:s\\Z');
|
|
@@ -117,7 +117,7 @@ class GuestDeclarationOrderService
|
|
|
'id' => 'DEBUG-' . $draft->ID,
|
|
'id' => 'DEBUG-' . $draft->ID,
|
|
|
'domain' => 'debug',
|
|
'domain' => 'debug',
|
|
|
'status' => 'success',
|
|
'status' => 'success',
|
|
|
- 'reference' => 'DEBUG-' . $draft->ORDER_SN,
|
|
|
|
|
|
|
+ 'reference' => $draft->PAYMENT_REFERENCE,
|
|
|
'amount' => (int) round((float) $draft->PAY_AMOUNT * 100),
|
|
'amount' => (int) round((float) $draft->PAY_AMOUNT * 100),
|
|
|
'currency' => strtoupper((string) $draft->CURRENCY),
|
|
'currency' => strtoupper((string) $draft->CURRENCY),
|
|
|
'metadata' => ['custom_fields' => [
|
|
'metadata' => ['custom_fields' => [
|
|
@@ -280,7 +280,7 @@ class GuestDeclarationOrderService
|
|
|
}
|
|
}
|
|
|
$draft->refresh();
|
|
$draft->refresh();
|
|
|
$paymentReference = 'GD' . strtoupper(bin2hex(random_bytes(12)));
|
|
$paymentReference = 'GD' . strtoupper(bin2hex(random_bytes(12)));
|
|
|
- $init = \\common\\helpers\\PayStack::transactionInit(
|
|
|
|
|
|
|
+ $init = \common\helpers\PayStack::transactionInit(
|
|
|
strtoupper($currency['CODE']),
|
|
strtoupper($currency['CODE']),
|
|
|
$amount,
|
|
$amount,
|
|
|
$input['email'],
|
|
$input['email'],
|
|
@@ -295,8 +295,9 @@ class GuestDeclarationOrderService
|
|
|
['STATUS' => $previousStatus, 'UPDATED_AT' => time()],
|
|
['STATUS' => $previousStatus, 'UPDATED_AT' => time()],
|
|
|
['AND', ['ID' => $draft->ID], ['STATUS' => GuestDeclarationDraftStatus::PAYMENT_INITIALIZING]]
|
|
['AND', ['ID' => $draft->ID], ['STATUS' => GuestDeclarationDraftStatus::PAYMENT_INITIALIZING]]
|
|
|
);
|
|
);
|
|
|
- throw new \\RuntimeException('Unable to initialize payment. Please retry.');
|
|
|
|
|
|
|
+ throw new \RuntimeException('Unable to initialize payment. Please retry.');
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
$draft->PAYLOAD = $storedPayload;
|
|
$draft->PAYLOAD = $storedPayload;
|
|
|
$draft->ORDER_SNAPSHOT = json_encode(['amount' => $amount, 'pv' => $pv, 'goods' => $goods], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
|
$draft->ORDER_SNAPSHOT = json_encode(['amount' => $amount, 'pv' => $pv, 'goods' => $goods], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
|
|
$draft->PAY_AMOUNT = $amount;
|
|
$draft->PAY_AMOUNT = $amount;
|