使用omnipay通过securepay进行处理时,指纹异常无效

时间:2014-05-26 03:10:32

标签: zend-framework2 omnipay

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

2 个答案:

答案 0 :(得分:1)

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

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

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

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

答案 1 :(得分:1)

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