duanao6704 2017-04-07 12:44
浏览 38

Securepay无法正常工作

I have implemented Secure pay payment gateway in my website. It was working fine but from yesterday it is not working. I did not get any response from secure server. Also I am getting an error.

A PHP Error was encountered

Severity: Notice

Message: Trying to get property of non-object

Filename: libraries/securepay.php

Line Number: 479

In securepay.php 479 number line is

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

and full function is below

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);
} 

Below is my sample code:

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
";
    } else {
        echo "Transaction failed with the error code: $response
";
        echo "XML Dump: " . print_r($sp->ResponseXml,1) . "
";
    }
} else {
    die("Your data is invalid
");
} 

Please help me how to solve it.

  • 写回答

1条回答 默认 最新

  • dongmi4734 2019-01-23 10:08
    关注

    You can use the following curl REST API code:

    $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 );
    

    Here $jsonRequest will consist of request data like "credit card payment". You can use the following link to find the JSON request data and test it. SecurePay Sandbox Testing Environment

    评论

报告相同问题?

悬赏问题

  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用