0

我正在使用 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);
    }

但是查看 League/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 参数。这允许我将它们设置在网关上。我怎么做?当我实例化网关时它会自动完成吗?

4

1 回答 1

0

我是对的,这个问题很愚蠢。

在阅读了代码并尝试之后,我发现AbstractGateway使用 Symfony 的请求类来自动获取 POST 变量,在这种情况下是 'MD' 和 'PaRes'。

事实上,它在 CompletePurchase 类中是这样说的:

$md = $this->httpRequest->request->get('MD');
$paRes = $this->httpRequest->request->get('PaRes');

httpRequest设置在AbstractGateway.

基本上,它只是工作。

于 2014-09-22T13:27:06.863 回答