我使用Omnipay允许用户使用Cardsave付款。
我有以下内容:
\Omnipay::setTestMode(true);
$transactionId = date('YmdHis').$booking->space->id.$booking->user->id;
$response = $gateway->purchase([
'amount' => $booking->price,
'currency' => 'GBP',
'card' => $card,
'transactionId' => $transactionId,
'cancelUrl' => \base_url('cardsave/cancel/'.$booking->id),
'returnUrl' => \base_url('cardsave/confirm/'.$booking->id)
])->send();
if ($response->isSuccessful()) {
$transactionReference = $response->getTransactionReference();
//save the transaction reference in case of refund
return ['status' => 'success', 'message' => 'Reservation process complete'];
} elseif ($response->isRedirect()) {
\Log::info('3DSecure redirect');
$booking->addAdditional(['3dsecure_transaction_id' => $transactionId]);
return [
'status' => 'redirect',
'form_html' => $response->getRedirectResponse()->getContent()
];
}
throw new PaymentException ($response->getMessage());
我的确认网址采用以下方法:
$transactionId = $booking->getAdditional('3dsecure_transaction_id');
$response = $gateway->completePurchase([
'amount' => $amount,
'transactionId' => $transactionId,
'currency' => 'GBP',
])->send();
if ($response->isSuccessful()) {
$transactionReference = $response->getTransactionReference();
return $this->finalise($booking, $transactionReference);
} else {
$this->cancel($booking);
}
但是查看联盟/ omnipay-cardsave的代码,我看到以下内容:
$md = $this->httpRequest->request->get('MD');
$paRes = $this->httpRequest->request->get('PaRes');
if (empty($md) || empty($paRes)) {
throw new InvalidResponseException;
}
所以我的问题是(我意识到这可能是愚蠢的,但由于某些原因,我似乎无法理解这一点),如果我刚刚实例化了网关,请求来自哪里?
我想我做错了。
编辑:
我发现来自3DSecure的返回调用带有MD和PaRes值作为POST参数。这允许我在网关上设置它们。我怎么做?它是在我实例化网关时自动完成的吗?
答案 0 :(得分:0)
我是对的,问题很愚蠢。
在阅读完代码并尝试之后,我发现AbstractGateway
使用Symfony的请求类来自动获取POST变量,其中就是这种情况,' MD&# 39;和' PaRes'。
事实上,它在CompletePurchase类中也是这样说的:
$md = $this->httpRequest->request->get('MD');
$paRes = $this->httpRequest->request->get('PaRes');
httpRequest
已在AbstractGateway
中设置。
基本上,它只是有效。