Newbie at PHP needs help with curl for payment gateway

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
User avatar
Goshawk
Forum Newbie
Posts: 2
Joined: Thu Sep 07, 2006 8:40 am

Newbie at PHP needs help with curl for payment gateway

Post by Goshawk »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi all,

I am new to all of this, and have just installed a ZenCart on my Host (GoDaddy)and I would like to include a payment gateway module, supplied by DirectOne (Australia). This needs to have curl support with ssl.

I have been pulling my hair out, as I have not been able to make a connections with DirectOne from my shopping cart. My site is secured, and https:// address is displayed in my cart. My server address is added to DirectOne, so it should accept my calls. Each time, it defaults to my index.php

I have contacted GoDaddy and they tell me that all is ok from their end. Here are my details:

[quote]CURL support 	enabled
CURL Information 	libcurl/7.10.6 OpenSSL/0.9.7a ipv6 zlib/1.2.3

PHP Version 5.1.4

This Web site is secured with a GoDaddy.com Web Server Certificate. Transactions on the site are protected with up to 256-bit Secure Sockets Layer encryption.[/quote]
How can I test my curl to make sure it is working correctly?

this is the code I am trying to submit:

Code: Select all

unset($authorize);

	  if (MODULE_PAYMENT_DIRECTONE_TRANSACTION_MODE == 'Test') {
	  $url = 'https://vault.safepay.com.au/cgi-bin/direct_test.pl';
          } else {
	  $url = 'https://vault.safepay.com.au/cgi-bin/direct_process.pl';
	      }

      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL, $url);
      curl_setopt($ch, CURLOPT_HEADER, 0);
      curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
      curl_setopt($ch, CURLOPT_POST, $data);
      curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

      $authorize = curl_exec($ch);

      curl_close ($ch);

      // Begin Debug Section
	  if (MODULE_PAYMENT_DIRECTONE_DEBUG == 'True'){
   echo $authorize;
   echo $data;
   echo $url;
   exit();
	    }
      // End Debug Section

      $response = array_shift(split(" ",$authorize["summary_code"]));

      //parse Directone response string
      $authorize = explode("\n",$authorize);
      for($i=0 ; $i<sizeof($authorize)-1 ; $i++)
      {$authorize[$i] = trim($authorize[$i]);
      $authorize[$i] = substr(strstr($authorize[$i], '='),1);
      }

      $payment_number = $authorize[0];
      $payment_reference =  $authorize[1];
      $bank_reference = $authorize[2];
      $summary_code = $authorize[3];
      $response_code = $authorize[4];
      $response_text = $authorize[5];
      $time = time();
When I set up my payment module in debug mode, I do not see any error messages.

In your response, could you please be specific, as I am a php and programming virgin..LOL, only been introduced to it in the last 3 weeks.

Here you can see my site. http://www.inekesfashions.com.au

Many thanks for your help,

Goshawk


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
hanji
Forum Commoner
Posts: 46
Joined: Fri Apr 29, 2005 3:23 pm

Post by hanji »

Hello

I ran into similar problem with GoDaddy and a osCommerce application using Authorize.net's Advanced Integration Method (which also uses cURL). The problem is that GoDaddy uses a proxy. After much googling, I found this snip of code.. and it worked for me.

After your block...

Code: Select all

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, $data);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
Try adding this to it...

Code: Select all

curl_setopt ($ch, CURLOPT_HTTPPROXYTUNNEL, TRUE);
curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
curl_setopt ($ch, CURLOPT_PROXY, "http://64.202.165.130:3128");
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
Hope this helps.
hanji
User avatar
Goshawk
Forum Newbie
Posts: 2
Joined: Thu Sep 07, 2006 8:40 am

Post by Goshawk »

Thanks Hanji

I have after pulling out all my hair done the same, and it works.

Goshawk
Post Reply