2

我正在尝试了解使用 Omnipay/SecurePay 进行付款的流程,但在尝试完成购买时总是出错。

从在线文档中我可以看到,completePurchase应该使用与函数相同的参数purchase调用函数,但是当我调用时,completePurchase我收到“无效指纹”异常。

这些错误也被抛出:

Undefined index: merchant in /var/www/vendor/omnipay/securepay/src/Message/DirectPostCompletePurchaseRequest.php on line 28
Undefined index: refid in /var/www/vendor/omnipay/securepay/src/Message/DirectPostCompletePurchaseRequest.php on line 30
Undefined index: timestamp in /var/www/vendor/omnipay/securepay/src/Message/DirectPostCompletePurchaseRequest.php on line 32
Undefined index: summarycode in /var/www/vendor/omnipay/securepay/src/Message/DirectPostCompletePurchaseRequest.php on line 33

我是否错过了添加这些缺失数据的步骤?还是应该在响应中返回这些数据?

代码:

$params = array(
    'amount' =>  $data->payment['amount'] . '.00',
    'currency' => $this->getOptions()->getCurrency(),
    'description' => 'test purchase',
    'transactionId' => '12345',
    'transactionReference' => $data->course['course_code'],
    'returnUrl' => 'http://test.localhost/register/55622/confirmation',
    'cancelUrl' => 'http://test.localhost/register/55622/summary',
    'card'=>$card
 );

$gateway = new DirectPostGateway();
$gateway->setMerchantId( $this->getOptions()->getGateway( $type )['merchant_id'] );
$gateway->setTransactionPassword( $this->getOptions()->getGateway( $type )['password'] );

$gateway->setTestMode( $this->getOptions()->getTestMode() );

$response = $gateway->purchase($params)->send();
var_dump($response->getRedirectData());

$response = $gateway->completePurchase($params)->send();
var_dump($response);
//"Invalid fingerprint" exception thrown

if ($response->isSuccessful()) {
    // payment was successful: update database
    return $response;
} elseif ($response->isRedirect()) {
    // redirect to offsite payment gateway
    if($response->getRedirectData()){
        var_dump($response->getRedirectData());
    } else {
        return $response->redirect();    
    }
    exit;
    return $response->redirect();
} else {
    // payment failed: display message to customer
    // echo $response->getMessage();
    throw new Exception("Error Processing Request", 1);
}
4

2 回答 2

1

你做事正确。当 SecurePay 返回您的网站时,应该有包含这些参数的 POST 数据,以及fingerprint确认请求真实性的参数。

我会在使用 SecurePay 付款时查看您浏览器的网络选项卡,并在付款完成后检查 HTTP POST 数据(并重定向到您的网站)。我的猜测是某些 htaccess 或其他脚本正在进行第二次重定向,并同时剥离重要的 POST 数据。

Omnipay 会自动检查 POST 数据,因此无需明确发送。只要您completePurchase()从同一个请求中调用,它就应该正确处理付款。

请参阅:https ://github.com/omnipay/securepay/blob/master/src/Message/DirectPostCompletePurchaseRequest.php

于 2014-05-27T02:49:28.217 回答
1

Securepay 使用端点https://test.securepay.com.au,然后切换到https://test.api.securepay.com.au

于 2017-02-21T10:57:45.540 回答