PHP XML Solution for Chase Orbital Gateway

17

Posted on : 14-Feb-2010 | By : jontroth | In : PHP Programmer, Tricks & Treats

I recently had the chance to setup a Chase Merchant Account Orbital Gateway. I needed a PHP solution for it though Orbital didn’t have any PHP examples, only SDKs for Java, Perl and .net.

So I decided to use their XML API and create the PHP script using CURL.
I hope this is helpful to anyone looking for help with the Chase Orbital Gateway.

<?PHP

$xmlRequest = get_xml(); // XML Order Request using PTI47 DTD

$header = array(
‘MIME-Version: 1.1′,
‘Content-Type: application/PTI47′, // DTD PTI47
‘Content-length: ‘ . strlen( $xmlRequest ), // length of XML file
‘Content-transfer-encoding: text’, // simple text encoding
‘Request-number: 1′, // only process one request
‘Document-type: Request’
);

$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, “https://orbitalvar1.paymentech.net” ); // XML payment gateway
curl_setopt( $ch, CURLOPT_HTTPHEADER, $header ); // Send predefined http header
curl_setopt( $ch, CURLOPT_HEADER, FALSE );
curl_setopt( $ch, CURLOPT_TIMEOUT, 30 );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt( $ch, CURLOPT_POST, 1 );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $xmlRequest ); // Post XML content
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
$returnXML = curl_exec( $ch );
curl_close( $ch );

$xml = simplexml_load_string( $returnString );

if( isset( $xml->NewOrderResp ) ){ // approved

// Transaction Approved
echo $xml->NewOrderResp->TxRefNum; // Transaction Number

}else{ // not approved

echo $xml->QuickResp->ProcStatus; // Error Code
echo $xml->QuickResp->StatusMsg; // Error Message

}

?>

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

Comments (17)

Thanks for this code, Jon. I also need to set up this payment gateway for purchasing gift cards. What does this script actually do? Looks like it receives the approved transaction. Is that all you need? What about converting the form data to XML?

Thanks!

The "$xml = simplexml_load_string( $returnString );" converts the xml into an object so you can just pull information from the xml using the $xml object … example $xml->NewOrderResp->TxRefNum would return the transaction number … just do a print_r( $xml ); to view everything.

The curl is just a snippet that you can use to send your "request XML" to Orbital, and receive the "responce XML" from orbital. Once approved the rest is in you hands to do want you like with the returned data. If you have any specific questions just post them here and I will try to help you out.

Hi — Is sending the "'request XML' to Orbital" the same as sending the order to them for processing? Is this what my form would connect to as the "action" to take when submitting? And under "Transaction Approved" I would echo out all of the pertinent transaction data on my Thank You page, correct? And echo out an error page under "not approved"? While I'm familiar with working with shopping carts, I've never really written a payment processing script myself before so I hope you can bear with me on this.

Btw, I tried to register with your site today, but never received the confirmation email. How can I get in contact with you directly? If I want to hire you to do this?

Thanks,
azurelink

Hi Jon — Thanks for the explanation. I'm still not clear on how to use the script. Btw, I tried to register but never received the confirmation email.

[...] or htdigest, but it is still fairly simple. The syntax which you will usually be using is …PHP XML Solution for Chase Orbital Gateway | Jon TrothPHP XML Solution for Chase Orbital Gateway. 4. Posted on : 14-Feb-2010 … htaccess Password [...]

Is the get_xml(); call to a function you would create yourself to create you xml request? Or is it a built in function?

get_xml() is a function you would create that would return the Orbital XML request code based on the PTI47 DTD format. Did you need an example?

Jon,

That would be great if you have an example! So far I am using the example provided on their XML Specification PDF, but wanted to see how you did this.

Here is the basic class … you'll need to add the profile function and the error page, etc.
Hope this helps.
http://jontroth.com/demo/orbital.zip

[...] or htdigest, but it is still fairly simple. The syntax which you will usually be using is …PHP XML Solution for Chase Orbital Gateway | Jon TrothPHP XML Solution for Chase Orbital Gateway. 4. Posted on : 14-Feb-2010 … htaccess Password [...]

great post as usual!

Jon, thanks for posting this. I am trying to setup a client with Orbital and this appears to be exactly what I need. However, I think I'm missing something. The above code is designed to work with an xml file, correct? Could you show an example of how it all works together? There needs to be the merchant ID, amount of sale, customer name, etc. and I'm not clear how or where that info would integrate into the above code. Thanks in advance!

Setup a public function in the class like this …

public function process( $order_code, $order_total ){
$this->gateway_process( $order_code, $order_total );
}

In your script create a new instance of the class …

$process = New Orbital();

Then send your order number and order total like this …

$process->process( "4EOR345", "100" );

Remember that orbital does not like decimal points so $1.00 would be a value of 100.

In the "function xml_build()" there is a reference to $this->profile() … you'll need to create that method to return an object containing all your users profile information that is relevant to the order.

The $MerchantID is the ID that Orbital provides you for the development site, and for the production site.

Hope this helps.
Jon

Thank you for the quick reply!

Hi Jon!

Great blog and I appreciate your work. We have a magento site and all our transactions even declined cards are going through to the success page. It does not give us any error messages. Any ideas?

Are you still in testing mode? Maybe send me your Chase Mod at jontroth@gmail.com and I'll run through it for you.

thanks Jon! I will forward the paymentmethod.php for your review thanks!!!!!!!

Write a comment

Rss Feed Tweeter button Facebook button Technorati button Reddit button Myspace button Linkedin button Webonews button Delicious button Digg button Flickr button Stumbleupon button Newsvine button Youtube button