$date = date( 'Y/m/d H:i' );
$xmldata = '
<API3G>
<CompanyToken>545415541</CompanyToken>
<Request>createToken</Request>
<Transaction>
<PaymentAmount>400</PaymentAmount>
<PaymentCurrency>NAD</PaymentCurrency>
<CompanyRef>888ff </CompanyRef>
<RedirectURL>https://secure.3gdirectpay.com/payv2.php?ID=token</RedirectURL>
<BackURL>www.motlee-systems.com</BackURL>
<customerEmail>jeoemex@gmail.com</customerEmail>
</Transaction>
<Services>
<Service>
<ServiceType>3854</ServiceType>
<ServiceDescription>me</ServiceDescription>
<ServiceDate>2020/11/06</ServiceDate>
</Service>
</Services>
</API3G>';
$url = "https://example.com/API/v6/";
$ch = curl_init();
if (!$ch) {
die("Couldn't initialize a cURL handle");
}
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $xmldata);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$result = curl_exec($ch); // execute
echo $result; //show response
curl_close($ch);
if ( $result != '' ) {
$xml = new \SimpleXMLElement( $result );
// Check if token was created successfully
if ( $xml->xpath( 'Result' )[0] != '000' ) {
exit("me");
} else {
$transToken = $xml->xpath( 'TransToken' )[0]->__toString();
$result = $xml->xpath( 'Result' )[0]->__toString();
$resultExplanation = $xml->xpath( 'ResultExplanation' )[0]->__toString();
$transRef = $xml->xpath( 'TransRef' )[0]->__toString();
}
} else {
throw new \Exception( 'Token could not be created. Please go back and try again' );
}
header("Location: https://example.com/payv2.php?ID=$transToken");
The code above runs perfectly on localhost / XAMPP but when I upload this file on my Ubuntu 16.04 VPS, it's giving this error:
This page isn’t working www.example.com is currently unable to handle this request. HTTP ERROR 500
Any idea why? I've installed curl and php-xml on Ubuntu but nothing.