【问题标题】:Securepay is not working安全支付不工作
【发布时间】:2017-09-02 20:41:20
【问题描述】:

我已经在我的网站中实施了安全支付支付网关。它工作正常,但从昨天开始它不工作了。我没有得到安全服务器的任何响应。我也遇到了错误。

遇到了 PHP 错误

严重性:通知

消息:试图获取非对象的属性

文件名:libraries/securepay.php

行号:479

在securepay.php 479号行是

($this->_TranslateServerCode($this->ResponseTree->Status->statusCode) == SECUREPAY_STATUS_OK);

完整功能如下

function TestConnection() {
    $this->RequestXml = $this->_ComposeEcho();
    $this->ResponseXml = $this->_Dispatch($this->RequestXml);
    $this->ResponseTree = simplexml_load_string($this->ResponseXml);
    return ($this->_TranslateServerCode($this->ResponseTree->Status->statusCode) == SECUREPAY_STATUS_OK);
} 

下面是我的示例代码:

include('securepay.php');

$sp = new SecurePay('ABC0001','abc123', TRUE);
$sp->TestMode();    
$sp->TestConnection();  
$sp->Cc = 4111111111111111;
$sp->ExpiryDate = '07/20';
$sp->ChargeAmount = 1500;
$sp->ChargeCurrency = 'AUD';
$sp->Cvv = 321;
$sp->OrderId = 'ORD34234';

if ($sp->Valid()) { 
    $response = $sp->Process();
    if ($response == SECUREPAY_STATUS_APPROVED) {
        echo "Transaction was a success\n";
    } else {
        echo "Transaction failed with the error code: $response\n";
        echo "XML Dump: " . print_r($sp->ResponseXml,1) . "\n";
    }
} else {
    die("Your data is invalid\n");
} 

请帮我解决一下。

【问题讨论】:

    标签: php payment securepay


    【解决方案1】:

    您可以使用以下 curl REST API 代码:

    $ch = curl_init ();
    curl_setopt ( $ch, CURLOPT_URL, 'https://test.api.securepay.com.au/xmlapi/payment' );
    curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, false );
    curl_setopt ( $ch, CURLOPT_SSL_VERIFYHOST, 2 );
    curl_setopt ( $ch, CURLOPT_FOLLOWLOCATION, false );
    curl_setopt ( $ch, CURLOPT_MAXREDIRS, 1 );
    curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true );
    curl_setopt ( $ch, CURLOPT_HTTPHEADER, array (
                'Content-Type: application/json' 
        ) );
    
    curl_setopt ( $ch, CURLOPT_POST, true );
    curl_setopt ( $ch, CURLOPT_POSTFIELDS, $jsonRequest );
    
    curl_setopt ( $ch, CURLOPT_CONNECTTIMEOUT, 10 );
    curl_setopt ( $ch, CURLOPT_TIMEOUT, 30 );
    
    $result = curl_exec ( $ch );
    

    这里的 $jsonRequest 将包含诸如“信用卡支付”之类的请求数据。您可以使用以下链接查找 JSON 请求数据并进行测试。 SecurePay Sandbox Testing Environment

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-08-31
      • 2020-04-12
      • 1970-01-01
      • 2015-05-24
      • 1970-01-01
      • 2011-10-21
      • 2015-12-31
      • 2017-10-01
      相关资源
      最近更新 更多