Просмотр исходного кода

Merge remote-tracking branch 'origin/feature/EK-5822' into feature/EK-5822

# Conflicts:
#	common/services/GuestDeclarationOrderService.php
ryan 2 дней назад
Родитель
Сommit
6ca74bf402
1 измененных файлов с 6 добавлено и 5 удалено
  1. 6 5
      common/services/GuestDeclarationOrderService.php

+ 6 - 5
common/services/GuestDeclarationOrderService.php

@@ -108,8 +108,8 @@ class GuestDeclarationOrderService
         if ($draft->STATUS !== GuestDeclarationDraftStatus::PENDING_PAYMENT || $draft->isExpired()) {
             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');
@@ -117,7 +117,7 @@ class GuestDeclarationOrderService
             'id' => 'DEBUG-' . $draft->ID,
             'domain' => 'debug',
             'status' => 'success',
-            'reference' => 'DEBUG-' . $draft->ORDER_SN,
+            'reference' => $draft->PAYMENT_REFERENCE,
             'amount' => (int) round((float) $draft->PAY_AMOUNT * 100),
             'currency' => strtoupper((string) $draft->CURRENCY),
             'metadata' => ['custom_fields' => [
@@ -280,7 +280,7 @@ class GuestDeclarationOrderService
         }
         $draft->refresh();
         $paymentReference = 'GD' . strtoupper(bin2hex(random_bytes(12)));
-        $init = \\common\\helpers\\PayStack::transactionInit(
+        $init = \common\helpers\PayStack::transactionInit(
             strtoupper($currency['CODE']),
             $amount,
             $input['email'],
@@ -295,8 +295,9 @@ class GuestDeclarationOrderService
                 ['STATUS' => $previousStatus, 'UPDATED_AT' => time()],
                 ['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->ORDER_SNAPSHOT = json_encode(['amount' => $amount, 'pv' => $pv, 'goods' => $goods], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
         $draft->PAY_AMOUNT = $amount;