Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integration of escrow web services in a PHP site

Tags:

php

escrow

I want to integrate the services of escrow.com in my PHP site.

How would you get started with this goal, and what APIs provided would be the basic functionality? Do you have any PHP specific advice or gotchas? Would you recommend another service provider?

like image 576
Hunt Avatar asked Jul 29 '10 10:07

Hunt


1 Answers

I'm working on an API project with this Company at the moment. I know looking at the documentation it all looks a little daunting, however, you can get away with making it as simple as a small cURL request.

I'd suggest starting with the "New escrow transaction" example provided, and build your request using the provided XML they offer, amended with your details.

Assign the XML to a variable, and pass it through a curl request similar to the below;

        // Initialise your cUrl object
    $ch = curl_init('https://xml.Escrow.com/Invoke/Partners/ProcessrequestXML.asp');

    //set your cURL options
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, "\$xmldata=".urlencode($xml));

    //Start your cURL Transaction
    ob_start();

    //execute your cURL object with your parameters
    $result = curl_exec($ch);

    //set the returned info to a variable
    $info = curl_getinfo($ch);

    // close the transaction
    curl_close ($ch);

    //get the contents of the transaction
    $data = ob_get_contents();
    ob_end_clean();

    //optional; Redirect to a specific place
    header("Location:".$url);

The only advise I can offer is to read through the documentation carefully, and always check the values you are passing in.

Where possible, it is also a good idea to segregate the API functions into their own class, this will make maintenance and troubleshooting, as well as testing the functionality that much easier.

like image 159
guyver4mk Avatar answered Nov 02 '22 05:11

guyver4mk