Page 1 of 1

Submitting form to third-party merchant solution provider

Posted: Mon Apr 02, 2007 4:29 am
by php4user2007
Hi there,

I've come across a fairly specific problem but I'm sure other php users must have encountered the same situation.

I would like to submit a form from my website to the website of a third-party merchant solution provider for payment processing using php but I'm not sure how to catch or display the response variables that the third-party website provides. What happens is that the response variable containing either an error or confirmation message is displayed on some webpage on the website of the third-party merchant solution provider. I need to know how I can display this message on my own website without having to access the third-party website's handler (which I can't with my particular merchant solution provider). I do know the names of the response variables created by the merchant solution provider.

This should be possible, but I just have no idea how it can be done. Please help!

Thanks,


P

Posted: Mon Apr 02, 2007 4:32 am
by onion2k
The solution depends on how the provider works. You'll either need to forward the user to the provider's site with a return URL or some sort (PayPal and Secpay work in this way), or you'll need to send the form to the provider's site using PHP with something like cURL and programmatically do something with the returned text.

The answer is basically: read the payment provider's documentation and do what they suggest.

Posted: Mon Apr 02, 2007 4:42 am
by lestervan
Who is the provider? Paypal or Google or ...? Let us know so that we can help you.

Yeah, normally each provider has the document and also sample source code to help you with the integration.

Providers

Posted: Mon Apr 02, 2007 4:50 am
by php4user2007
the two providers in question are

authorize.net and powerepay.com

Unfortunately authorize.net does not provider any tech support and powerepay.com "kindly" suggested to try to figure it out yourself.

Is there really no generic way to capture response variables?


thanks,

P

Re: Providers

Posted: Mon Apr 02, 2007 5:00 am
by onion2k
php4user2007 wrote:Unfortunately authorize.net does not provider any tech support and powerepay.com "kindly" suggested to try to figure it out yourself.
Authorize.net have a massive amount of integration documentation: http://developer.authorize.net/ .. I assume powerepay.com gives you similar info when you sign up.

There are generic ways to capture different types of data, but you'd be a lot better off using the way they suggest in their developer documentation.

powerepay does not offer intergration guidelines

Posted: Tue Apr 03, 2007 3:39 am
by php4user2007
Thanks for the constructive advice.

I was able to do the integration with authorize.net by adjusting the sample code. However, powerepay does not offer any integration guidelines even if you set up an account. They also don't have a support ticket system. I was told that they would do the integration for me but it would cost quite alot of money. Since my employer does not want to change merchant solution provider from powerepay, is there any generic way that would work?

the code from authorize.net that apparently does the fetching of the response without ending up on the third party website is:

Code: Select all

$ch = curl_init("https://test.authorize.net/gateway/transact.dll"); 

	curl_setopt($ch, CURLOPT_HEADER, 0); // set to 0 to eliminate header info from response
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1)
	curl_setopt($ch, CURLOPT_POSTFIELDS, rtrim( $fields, "& " )); // use HTTP POST to send form data
	$resp = curl_exec($ch); //execute post and get results

	curl_close ($ch);
Any ideas whether this can be modified to fetch the result from powerepay (which is simply a string consisting of 4 variables)? I will try just changing the url, but if someone has experience with this please let me know if I'm on the right track. Thanks

Posted: Tue Apr 03, 2007 4:27 am
by onion2k
If there's no integration documentation then there's no way to tell what data you need to send to powerepay, so your job is actually impossible.

post with curl

Posted: Tue Apr 03, 2007 7:52 am
by php4user2007
sorry, I wasn't precise enough.

The provider does specify that it needs the name value pairs in this format: http://www.provider.cgi?firstname=Tom&l ... nes&...etc. This is achieved through the GET method as opposed to the POST method. For some odd reasons this service provider returns a system error if a form uses the POST method.

The url with the concatenated string appended is not difficult to create except that the code from authorize.net specifies the POST method in the curl function. If I now could only get the curl function to execute a GET command then theoretically the integration would be complete.

Unfortunately, even in posts from Daniel Steinberg himself (the creator of curl) I have not been able to find an actual concrete example of how to use the GET method with curl. He writes that the default is GET and so leaving out the code relating to POST and just including the full url with concatenated string appended would execute the GET request.

the example in some other documentation shows intead of [Example A)] using a line of code that which will pass the fields using POST to [example B)] use the line of code show below which however creates a parse error in PHP as unrecognized function or argument. Different modications to the code (such as using curl () or curl_setopt() instead of just curl also did not make any difference.

Example A) curl_setopt($ch, CURLOPT_POSTFIELDS, "http:www.provider.cgi?firstname=Tom&lastname=Jones&...etc");

Example b) curl "http:www.provider.cgi?firstname=Tom&lastname=Jones&...etc";


I'm hoping someone must know the exact code on how to execute a GET command with curl?

Posted: Tue Apr 03, 2007 8:46 am
by Begby

Code: Select all

// create a new cURL resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://www.example.com/?arg1=taco&arg2=burrito");
curl_setopt($ch, CURLOPT_HEADER, 0); // This is just an example option, not required

// grab URL and pass it to the browser
curl_exec($ch);

// close cURL resource, and free up system resources
curl_close($ch);
Just include the arguments in the init as above

awesome... that worked

Posted: Thu Apr 05, 2007 6:05 am
by php4user2007
thank you for the great advice. That was exactly what I needed.

Someone else also suggested to use

http_post_fields ();

That seems to potentially be an even more elegant or simpler solution (and generic as well). I haven't tried it however. If anyone has, it would be interesting to know whether it works with generic forms and providers, as well as different php versions.

Otherwise, this problem has been solved.

thanks again,

P