feat(payment): enhance payment flow with new pay endpoint and POST redirect method
This commit is contained in:
@@ -53,7 +53,15 @@ class MellatGateway implements PaymentGatewayInterface
|
||||
$refId = $this->parseRefId($response->getContent());
|
||||
$redirectUrl = self::PAYMENT_URL . '?RefId=' . $refId;
|
||||
|
||||
return new PaymentInitResult(true, redirectUrl: $redirectUrl, token: $refId);
|
||||
// درگاه ملت باید با POST فرم (فیلد RefId) باز شود؛ redirectUrl (شامل RefId)
|
||||
// برای سازگاری با مصرفکنندههای قدیمی نگه داشته میشود.
|
||||
return new PaymentInitResult(
|
||||
true,
|
||||
redirectUrl: $redirectUrl,
|
||||
token: $refId,
|
||||
redirectMethod: 'POST',
|
||||
redirectParams: ['RefId' => $refId],
|
||||
);
|
||||
} catch (\Throwable $e) {
|
||||
$this->logger->error(sprintf('Payment initiate failed (mellat): %s @ %s:%d', $e->getMessage(), $e->getFile(), $e->getLine()), ['exception' => $e, 'orderId' => $orderId, 'amount' => $amountRials]);
|
||||
return new PaymentInitResult(false, errorMessage: $e->getMessage());
|
||||
|
||||
@@ -4,10 +4,16 @@ namespace App\Payment\Gateway;
|
||||
|
||||
final class PaymentInitResult
|
||||
{
|
||||
/**
|
||||
* @param 'GET'|'POST' $redirectMethod نحوهٔ انتقال به درگاه: GET (302) یا POST (فرم auto-submit)
|
||||
* @param array<string, string> $redirectParams فیلدهای فرم برای حالت POST
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly bool $success,
|
||||
public readonly string $redirectUrl = '',
|
||||
public readonly string $token = '',
|
||||
public readonly string $errorMessage = '',
|
||||
public readonly string $redirectMethod = 'GET',
|
||||
public readonly array $redirectParams = [],
|
||||
) {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user