我在我的网站上实施了安全付费网关。它工作正常,但从昨天起它无法正常工作。我没有从安全服务器得到任何响应。我也收到了一个错误。
遇到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);
}
以下是我的示例代码:
包括( '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");
}
请帮我解决一下。
答案 0 :(得分:0)
您可以使用以下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