1

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

Please help me how to solve it.

Community
  • 1
  • 1
user3708566
  • 39
  • 1
  • 5

1 Answers1

0

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

Kailash
  • 1
  • 1