Jump to content

[SOLVED] Curl - I'm new to it and stuck


thisendup

Recommended Posts

I've been PHPing for a few years, but brand new to the curl universe and need help.

 

I am trying to figure out how to post credit card form data to the credit card company my client has signed up with, and need some basic help as this is a brand new thing to me.

 

I am attempting to use this code below. It is supposed to post the credit card info to the credit card company using the variables names they gave me, but I get nothing, not even an error message - so it is probably my ignorance making elementary ommissions, if you could help me I'd surely appreciate it. I have been all over the web looking at tutorials and such and am not sure what all I am looking at yet..

 

$curlpost = curl_init();

curl_setopt($curlpost, CURLOPT_URL, "http://www.creditcardcompanywebsite.com" );

$curlpost=("ssl_yourmerchant_id=" .urlencode('mymerchantid123')
."&ssl_yourpin=".urlencode ('pin1234')
."&ssl_youruser_id=".urlencode('userid567')
."&ssl_show_form=" .urlencode('false')
."&ssl_card_number=".urlencode ($thiscardnumber)
."&ssl_exp_date=".urlencode($expdate)
."&ssl_amount=" .urlencode($saleamount)
."&ssl_thetransaction_type=".urlencode ('SALE')
."&ssl_invoice_num=".urlencode ('10131abc')
."&ssl_buyer_first_name=".urlencode($buyerfname)
."&ssl_buyerlast_name=". urlencode($buyerlname)
."&ssl_email=".urlencode ($buyeremail)
."&ssl_receipt_decl_method=".urlencode ('REDG')
."&ssl_receipt_decl_get_url=".urlencode ('http://www.mysite.org/problems.php')
."&ssl_receipt_apprvl_method=".urlencode ('REDG')
."&ssl_receipt_apprvl_get_url=".urlencode ('http://www.mysite.org/thank_you.php')
."&ssl_test_mode=" .urlencode ('false' ). "&SUBMIT=Send"); 

$postresult=curl_exec($curlpost);

echo $postresult;

 

 

 

Thanks in advance

 

Link to comment
https://forums.phpfreaks.com/topic/46952-solved-curl-im-new-to-it-and-stuck/
Share on other sites

<?php
$refCurl = curl_init();
curl_setopt($refCurl, CURLOPT_URL, "http://www.creditcardcompanywebsite.com");
curl_setopt($refCurl, CURLOPT_POST, true);
curl_setopt($refCurl, CURLOPT_POSTFIELDS, "ssl_yourmerchant_id=" .urlencode('mymerchantid123')
."&ssl_yourpin=".urlencode ('pin1234')
."&ssl_youruser_id=".urlencode('userid567')
."&ssl_show_form=" .urlencode('false')
."&ssl_card_number=".urlencode ($thiscardnumber)
."&ssl_exp_date=".urlencode($expdate)
."&ssl_amount=" .urlencode($saleamount)
."&ssl_thetransaction_type=".urlencode ('SALE')
."&ssl_invoice_num=".urlencode ('10131abc')
."&ssl_buyer_first_name=".urlencode($buyerfname)
."&ssl_buyerlast_name=". urlencode($buyerlname)
."&ssl_email=".urlencode ($buyeremail)
."&ssl_receipt_decl_method=".urlencode ('REDG')
."&ssl_receipt_decl_get_url=".urlencode ('http://www.mysite.org/problems.php')
."&ssl_receipt_apprvl_method=".urlencode ('REDG')
."&ssl_receipt_apprvl_get_url=".urlencode ('http://www.mysite.org/thank_you.php')
."&ssl_test_mode=" .urlencode ('false' ). "&SUBMIT=Send");

curl_setopt($refCurl, CURLOPT_RETURNTRANSFER, true);
$curlResponse = curl_exec($refCurl);
?>

Should work.  Let me know if there are any problems.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.