Update: This library has gone through full re-write and the uploaded version can be found here.
If you are like me, whenever you need to work with a 3rd party API or a gateway, you’d first search in Google for a possible wrapper for it in PHP. When it comes to supporting payment gateways, you get bunch of libraries in the search results who are fundamentally different. Some of them are old PHP 3/4 ones, some are new, some may need PEAR, etc.
As they were not required together in one single project, I used them whenever needed. But in one project, I needed them all. I thoughts it’s a chance and decided to stop using them and wrote my own ones where I can use the same methods for all the gateways.
So, here is an abstract PaymentGateway library which is being extended to be used for three popular payment gateways (Paypal, Authorize.net, and 2Checkout) in order to provide you with a similar way of using them. Note that the libraries are for basic usage only and do not contain options for recurring payments. Without much babble, let’s see a few examples of how you can use them.
Download
No download available for this version.
Paypal
In order to process payments using Paypal, you’ll need to follow these steps:
1. Send the required information to Paypal (snippet 1). Be sure to specify your Paypal email where you want to receive the funds, the success and failure pages, the IPN page, and the product information. The example has the test mode ON, which you will not need in real scenario.
2. Create a payment success page where Paypal will send your customer after payment.
3. Create a payment failure page where Paypal will send your customer after failed payment.
4. Create a IPN page where Paypal will send payment notification in the background. Make sure you use/remove the test mode in conjunction with step 1. (snippet 2)
Snippet 1
1// Include the paypal library 2include_once ('Paypal.php'); 3 4// Create an instance of the paypal library 5$myPaypal = new Paypal(); 6 7// Specify your paypal email 8$myPaypal->addField('business', 'YOUR_PAYPAL_EMAIL'); 9 10// Specify the currency11$myPaypal->addField('currency_code', 'USD');12 13// Specify the url where paypal will send the user on success/failure14$myPaypal->addField('return', 'http://YOUR_HOST/payment/paypal_success.php');15$myPaypal->addField('cancel_return', 'http://YOUR_HOST/payment/paypal_failure.php');16 17// Specify the url where paypal will send the IPN18$myPaypal->addField('notify_url', 'http://YOUR_HOST/payment/paypal_ipn.php');19 20// Specify the product information21$myPaypal->addField('item_name', 'T-Shirt');22$myPaypal->addField('amount', '9.99');23$myPaypal->addField('item_number', '001');24 25// Specify any custom value26$myPaypal->addField('custom', 'muri-khao');27 28// Enable test mode if needed29$myPaypal->enableTestMode();30 31// Let's start the train!32$myPaypal->submitPayment();
Snippet 2
1// Include the paypal library 2include_once ('Paypal.php'); 3 4// Create an instance of the paypal library 5$myPaypal = new Paypal(); 6 7// Log the IPN results 8$myPaypal->ipnLog = TRUE; 9 10// Enable test mode if needed11$myPaypal->enableTestMode();12 13// Check validity and write down it14if ($myPaypal->validateIpn()) {15 if ($myPaypal->ipnData['payment_status'] == 'Completed') {16 file_put_contents('paypal.txt', 'SUCCESS');17 }18} else {19 file_put_contents('paypal.txt', "FAILURE\n\n" . $myPaypal->ipnData);20}
Authorize.net
In order to process payments using Authorize.net, you’ll need to follow these steps:
1. Send the required information to Authorize.net(snippet 3). Be sure to specify your Authorize.net login and secret key, the success/failure pages, the IPN page, and the product information. The example has the test mode ON, which you will not need in real scenario.
2. Create a payment success/failure page where Authorize.net will send your customer after payment.
3. Create a IPN page where Authorize.net will send payment notification in the background. Make sure you use/remove the test mode in conjunction with step 1. (snippet 4)
4. In order to set the secret key, log into your authorize.net merchant account. Go to “MD5 Hash” menu and set a secret word to desired values and use that in the “setUserInfo” function showed in the example.
Snippet 3
1<!--?php </p--> 2 3// Include the paypal library 4include_once ('Authorize.php'); 5 6// Create an instance of the authorize.net library 7$myAuthorize = new Authorize(); 8 9// Specify your authorize.net login and secret10$myAuthorize->setUserInfo('YOUR_LOGIN', 'YOUR_SECRET_KEY');11 12// Specify the url where authorize.net will send the user on success/failure13$myAuthorize->addField('x_Receipt_Link_URL', 'http://YOUR_HOST/payment/authorize_success.php');14 15// Specify the url where authorize.net will send the IPN16$myAuthorize->addField('x_Relay_URL', 'http://YOUR_HOST/payment/authorize_ipn.php');17 18// Specify the product information19$myAuthorize->addField('x_Description', 'T-Shirt');20$myAuthorize->addField('x_Amount', '9.99');21$myAuthorize->addField('x_Invoice_num', rand(1, 100));22$myAuthorize->addField('x_Cust_ID', 'muri-khao');23 24// Enable test mode if needed25$myAuthorize->enableTestMode();26 27// Let's start the train!28$myAuthorize->submitPayment();
Snippet 4
1<!--?php </p--> 2 3// Include the paypal library 4include_once ('Authorize.php'); 5 6// Create an instance of the authorize.net library 7$myAuthorize = new Authorize(); 8 9// Log the IPN results10$myAuthorize->ipnLog = TRUE;11 12// Specify your authorize login and secret13$myAuthorize->setUserInfo('YOUR_LOGIN', 'YOUR_SECRET_KEY');14 15// Enable test mode if needed16$myAuthorize->enableTestMode();17 18// Check validity and write down it19if ($myAuthorize->validateIpn()) {20 file_put_contents('authorize.txt', 'SUCCESS');21} else {22 file_put_contents('authorize.txt', "FAILURE\n\n" . $myPaypal->ipnData);23}
2Checkout
In order to process payments using 2Checkout, you’ll need to follow these steps:
1. Send the required information to 2Checkout(snippet 5). Be sure to specify your 2Checkout vendor id, the return page, and the product information. Please note that 2Checkout does not send IPN in the background, so you will need to handle the payment data in the return page. The example has the test mode ON, which you will not need in real scenario.
2. Create a return page where 2Checkout will send your customer after payment. This is also where you will need to retrieve and use the payment data. Make sure you use/remove the test mode in conjunction with step 1. (snippet 6)
3. In order to set the secret key, log into your 2checkout.com account and go to “Look and Feel” section. At the bottom enter the “Secret Word” and use it in the IPN verification process as shown in the example.
Snippet 5
1<!--?php </p--> 2 3// Include the paypal library 4include_once ('TwoCo.php'); 5 6// Create an instance of the authorize.net library 7$my2CO = new TwoCo(); 8 9// Specify your 2CheckOut vendor id10$my2CO->addField('sid', 'YOUR_VENDOR_ID');11 12// Specify the order information13$my2CO->addField('cart_order_id', rand(1, 100));14$my2CO->addField('total', '9.99');15 16// Specify the url where authorize.net will send the IPN17$my2CO->addField('x_Receipt_Link_URL', 'http://YOUR_HOST/payment/twoco_ipn.php');18$my2CO->addField('tco_currency', 'USD');19$my2CO->addField('custom', 'muri-khao');20 21// Enable test mode if needed22$my2CO->enableTestMode();23 24// Let's start the train!25$my2CO->submitPayment();
Snippet 6
1<!--?php </p--> 2 3// Include the paypal library 4include_once ('TwoCo.php'); 5 6// Create an instance of the authorize.net library 7$my2CO = new TwoCo(); 8 9// Log the IPN results10$my2CO->ipnLog = TRUE;11 12// Specify your authorize login and secret13$my2CO->setSecret('YOUR_SECRET_KEY');14 15// Enable test mode if needed16$my2CO->enableTestMode();17 18// Check validity and write down it19if ($my2CO->validateIpn()) {20 file_put_contents('2co.txt', 'SUCCESS');21} else {22 file_put_contents('2co.txt', "FAILURE\n\n" . $my2CO->ipnData);23}
Hope this will help you integrate the payment gateways in an easy manner. If you have any questions, or find any bug, have a suggestion, feel free to post them as comment here. Btw, this library is released under the MIT license.
Cheers!
Thanks man!
bookmarked!!
excellent writing, carry it on
thanks , its very much helpful .
Awesome – Awesome – and Awesome
Thanx
Downloaded 🙂 Thanks man!!
thanks dude.
any chance of adding google checkout?
I'm glad that you people are finding it good 🙂 And yes, two new gateway will be added soon: Internet Secure and Google Checkout.
How do you implement this library for a small website with multiple items? What part of the code do we need to include next to the different items?
Right in time when I started looking for it. I'll see if I will be able to add recurring payments for paypal since I need them too.
Thank you!
You should check out Spreedly.com. I've used them, for my subscription service. It's fantastic, and saves me a lot of time and effort.
Thank you, this is great!
thank you very much for this nice lib , but i was wondering if you have a plan to add moneybookers.com to the library , i will try to but am not sure if am gana be able to do it .
but if i did , i will share it with you 😀
Thanks man, if you do develop, post a link here with your MoneyBooker class. It would be much appreciated 🙂
I will be adding the recurring option to the class in two days, so you might wanna wait if there is no emergency on your side 🙂
I agree with Hasin. Bookmarked for sure. Thanks man, I was looking for something like this awhile back.
Excellent work! This will useful for my clients who have custom shopping carts built into their websites. Thank you!
I must be missing something here. The payment posts to authnet…the log shows the post from the gateway…but the ipn response from gateway server is blank and i CANNOT get to the receipt page, obviously. I'm almost home, or so I think, but I can't get there on my own…please help.
Ok, ok…i'm posting 'success' to the results log for an authorize.net payment, but
IPN Response from gateway Server: is blank.
I'm lost. Testing gives me a:
An error occurred while trying to report this transaction to the merchant. An e-mail has been sent to the merchant informing them of the error. The following is the result of the attempt to charge your credit card.
This transaction has been approved.
It is advisable for you to contact the merchant to verify that you will receive the product or service.
at the secure.authorize.net page.
The merchant gets a receipt…the buyer gets a receipt…so everything appears to be working except I receive no e-mail informing me of the error, no IPN response from gateway Server, and i cannot get to my receipt page. Please help…Please!!
Hi JP,
I did a search on the net and it seems a few other people have faced similar error. One of them contacted authorize.net and here goes their response:
“Greetings from Authorize.Net!
When Authorize.Net is responding back to a script on your server our system waits 10 seconds for a response. If we do not get a response in 10 seconds, our server will time out and display an error page. In this case the customer will see the transaction results on an error page that Authorize.net generates.
If this happens we will either send an email to you indicating: “An error occurred while trying to report this transaction to the merchant. An email has been sent to the merchant informing them of the error. The following is a result of the attempt to charge your credit card”
or
The transaction will be declined within your Merchant Interface. The transaction detail will display (Unable to send notification to Customer).
If the customer closes the browser window before we receive data from your script to print to the screen we will change the transaction response reason code to 52.
To prevent these errors the first thing that you will need to look for is the order that your script executes. It is very important that something is printed to the screen before any other process is started. If your script prints to the screen first, we will recognize that you have received the transaction results.
To resolve this issue:
– Before doing anything else start writing to your receipt page. For example: print your page headers and the first part of the page body.
– Check that your script permissions are correct and that it can accept an HTTPS POST.
– Check that the script is not completing other functions before writing to the screen, such as writing to a database or sending emails.
– Please check to see if there are different processes that are used in your script for approvals, declines, or errors. Check each process to be sure that they will write to the screen before any other functions.
– Verify that your script is not using redirects upon receipt of the response from our servers. Redirects strongly are discouraged because they can potentially interfere with the process.”
I think you might as well get in touch with them. Let me know if it gets resolved.
Thanks
Any updates on adding recurring/subscription payments? Thanks!
Yeah I thought I'll start working with your library last week but didn't happen even to set up anything yet… Got some important updates going on.
Thank's though I'll monitor your page. I should be subscribed to your RSS too.
I think that my comment was lost so I'll try again – sorry if double.
In short I didn't get a chance to even look at the library yet although was planning to do so last week. I monitor your page and if you come up with something sooner that'll be cool. If i happen to finish my part first i'll send you my updates to see if that'll be helpful for you.
Thanks
When will google checkout be added?
Regards,
Sean
Thanks from the U.S.
Just starting to review your work, but I believe it will save me a load of time.
Thanks again
I've been playing with that for some time now, but not getting enough time on hand to complete yet. If you'd like to give me a hand, you can go ahead 🙂
thanks man. I've been busy with ZCE preparation and didn't find enough time to work. So if you can come up with that, it would be helpful for others as well.
I tried to integrate your PayPal functionality into my checkout system and entered the business account email into the place where you asked for the email. Nonetheless, when I try to submit the payment to PayPal I get the following error: “We cannot process this transaction because there is a problem with the PayPal email address supplied by the seller…” When I created the business acount it forced creation of a username, password and signature; but I noticed your code does not require that. Please help.
can u add the working demo link as well!
thank you ! man!
And hope the google checkout will be released!
I'm another one that would like to see google checkout added but I don't want standard level 1 integration – and can't use level 2. level 2 requires a secure server, level 1 doesn't – but also doesn't integrate with your site – at all. Well it can do – but so far they haven't written instructions for the api that can grab the results of transactions.
Really a nice, organized and very essential library.
Nice
Thanks!
Great work and very simplistic too. Its also a good way for beginers to see what is actually going on due to the simple codeflow. I have modified your code and added forms with checkboxes, and stored all common variables to a flat config file and am currently expanding on your initial work to allow balance checking and periodical payment cycles. Also added a paypal recurring billing facillity last night and will look into 2co and authorize for the same, though I am unfamiliar with their process. Paypal recurring is easy by changing the payment type and adding the relevant variables to pass over to paypal.
Google checkout would be among my wish list as would Nochex. Nochex is great for UK sellers like me, though it hard to work with.
More on this soon as I may release it when finalized and 100% stable.
Great idea and thanks so much for putting it out there.
Question:
in the Paypal version you have:
$myPaypal->addField('custom', 'muri-khao');
How do we get that custom value back in the IPN?
Because when someone has paid obiviously I want to update X but I dont see how to get that value back.
excelent work. If you add another Google Checkout its will be great.
sweet!
can we integrate code without going on paypal wesite. It should not redirect to paypal's website
Had to change your Paypal.php to enable multiple items…
parent::__construct();
// Some default values of the class
$this->gatewayUrl = 'https://www.paypal.com/cgi-bin/webscr';
$this->ipnLogFile = 'paypal.ipn_results.log';
// Populate $fields array with a few default
$this->addField('rm', '2'); // Return method = POST
$this->addField('cmd', '_cart');
$this->addField('upload', '1');
}
then when you add items just append _# to the tags with # being the line item you're working with
nice base class for paypal with the skeleton in place… was a great starting point for what I'm working on…
thanks for the great start
Downloaded and trying to finding out clues. But Till it sames really awesome.Hope soon we ll have it for clickbank and goodlcheckout as well. 🙂
There is no working demo mate, sorry!
The custom value will be available in the IPN post values returned from the paypal server.
Thanks
Sorry, you have to redirect to Paypal's website for payment – it is mandatory.
Hello Austin, good to know the base class helped you. And thanks for sharing the snippet for allowing multiple items 🙂
Given an existing Authorize.net account, can a single static web page (i.e., no shopping cart, just one single web page) be made to complete an e-commerce transaction via Authorize.net's “Secure Hosted Payment Form” and the “Snippet 3” code listed here? Is it really that easy? Is that all there is to it?
its very useful………..
Thanks
thanks man…
goo job i need this, but for me this script just on the halfway…
i must modded it to be used with zend framework
Thanks, its indeed helpful.
Could you please shed me some light on how to echo the custom value in the success page?
// Specify any custom value
$myPaypal->addField('custom', 'muri-khao');
I just want to let the customer see the custom value after he returns from PayPal to the success notification page. Thanks again!
Hasan,
Could you please give us more details? Which file needs to be modified so that the $myPaypal->ipnData['custom'] can be shown to the customer. Thank you!
Best regards,
Jack
hey Emran its gr8 work….
can you please provide me authorize.net developer account credentials..
if yes then please mail it to me, if you don't want to post it here
that will be gr8 help
thanks, and thanks again for this amazing work
Grear post, saved me a lot of writing efforts.
I took your tool as a infrastructure for my payment system.
Where is INS parser?
your code who processing the payment using paypal does not pass multiple items . so send the solution of it as well as possible.
…….
$myPaypal->addField(‘cmd’, ‘_cart’);
$myPaypal->addField(‘upload’, ‘1’);
……
// 1st product added..
$myPaypal->addField(‘item_number_1’, ‘XXXX’);
$myPaypal->addField(‘item_name_1’, ‘Product 1’);
$myPaypal->addField(‘amount_1’, 10.00);
$myPaypal->addField(‘quantity_1’, 2);
// 2nd
$myPaypal->addField(‘item_number_2’, ‘YYYY’);
$myPaypal->addField(‘item_name_2’, ‘Product 2’);
$myPaypal->addField(‘amount_2’, 50.00);
$myPaypal->addField(‘quantity_1’, 2);
Thank you very much for this useful class, i spent a whole afternoon figuring out how to do it, and then you arrived! ;=)
I am experiencing just one problem, i am testing paypal local with sandbox, text file for ipn isn't created, do you think it is because i am not over internet with my website?
Thanks!
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/www/xxxxx/xxxxxx/Authorize.php on line 25
please help me?
Thanks for the contribution will prove, it!
Hello Austin,
I don't understand how send multiple items with this change … pls can you explain me with a very little code example.
thanks
boss you become famous for this classes, see at http://komunitasweb.com/2009/03/20-great-php-li…
For PayPal payment success echo “Success”
if fail —> How can i rollback Mysql update?
Thanks for your library,
Thank you very much indeed,
Brilliant! 🙂
Well, yes its that simple. If the developer knows what he's doing, he can do this in one single PHP page.
Good to know its helpful. You'll get the passbacks on the IPN handler. Use this:
echo $myPaypal->ipnData['custom'];
Sorry. You can get yourself from their site.
You might be running an old PHP version. This needs PHP5. Thanks.
Thanks for sharing!
Thanks for sharing!
Md Emran Hasan
Nice Code.
Can u tell me plz the way to use the code through mysite or send me the form? I m beginner in this things.
Waiting for your favorable reply soon.
Thanks in advance,
Vipin
Excuse me, does anyone knows how to use the PayPal class for multiple items?
@Jessica: Sorry, this version does not have the multiple product feature. It will be added in the next version. Right now you can have a look at the paypal documentation and use the addField function to setup the form.
Thank you Emran, really appreciate your help.
I’ll really really appreciate if you could let me know when the new version will be available.
Thanks Again !!!!
Why I was redirect to paypal sandbox after use your code?
Thanks its very help full for me ..
Thanks for the wonderful piece of work, i really appreciate it… I have one question though, how can i now use the information from the IPN test page… Eg. if the transaction was successful, then i need to capture that info on my website. In short, i can i modify the IPN page to complete the recording of the transaction on my site. I wish to record the amount paid and all other relevant transaction details. Thanks for your help… Am a bit new to this…
Hai,
When i am trying to using your script i am not able to redirecting to my site automatically
@andy: Can you be a bit specific, then I’d be able to help you out.
This is awesome, just what I have been looking for! Very good script! Thank you!
Nice Job 😀
Thanks Emran,
I’m curious – have you added the recurring option to the class?
Keep up the great work and make sure you use your class with a donate option! 😉
I’m sure people here and future downloaders will donate for you to keep this up-to-date.
thanks again!
really excellent writing,carry on man n please tell when your new version will be released with multiple item enabled specially in authorize.net,i have done it in PayPal ,i need it urgently,please help
Thanks in advance
I find your scripts useful. However, I’m having a few problems using the paypal script.
I updated all of the information in the paypal_start.php file to the correct paths and correct paypal email.
However, when I go to the Paypal.php file and turn test mode to FALSE it still directs me to the Sandbox gateway.
Is there any additional information I need to change or anything else I need to customized to get this working on my server?
Thanks – short and to the point!!!
Hi Emran,
First thank you very much for this class and is really helpful.
1. When you are going to release version to support Recurring Payment for Paypal ?
2. You have an example of custom field for Paypal :
// Specify any custom value
$myPaypal->addField(‘custom’, ‘muri-khao’);
Can we get back this custom field in IPN something like below example ?
if ($myPaypal->ipnData[‘payment_status’] == ‘Completed’) {
$custom = $myPaypal->ipnData[‘custom’];
}
Thanks so much for a clear and working code, finally something for PHP5.
will share this around the www 🙂
Very useful and nice post indeed.
What I’m looking for is PHP class for mooneybookers payment.
Any help would be cordially appreciated. 🙂
Fantastic !!!
i Will Absolety use it !
thank u
Many thanks – this class is great! 🙂
Really helped me on my task today.. Thanks a lot for this post.
very useful post.. Thanks!
Love this script! Covering the 3 major online payment gateways in one script… brilliant. Are there any other updates going to be made to this script, and if so can you tell when?
Thanks!
Hi. Thankyou very much for this library. saved lots of time. and thanks to Austin Mount for pointing out how to add multiple items to the payment.
Excellent work!
BTW, in authorize.net, the test mode in the code does not work when you are not using a developer’s account… i just want to share because i had a hard time with that..=)
Hi Emran.
We have a 501(c)3 organization that has an account set up with PayPal for contributions. It’s the “standard” setup, i.e. click the button and it goes to PayPal.
The head of our group saw a website that used PayPal, but they person visiting the website could enter an amount right there instead of being redirected.
Do you know of any snippet like that? What are your thought on it. Would that be secure? If so, where do we get the snippet for that.
Thanks, Emran. Great job!
Quite informative. But i m not successfully able to integrate 2CO using authorize.net parameters on my website. Any possible solution?
Hello all, thanks for your comments and I’m happy to be able to help you guys.
I’ve planned to post updates on the payment script is in the following week with better code interface and stability.
Thanks
Perfect!
AWESOME.
Thanks a lot mate.
really excellent!!
Hello Emran vai,
I’ve added a extra security layer on IPN testing, here is my code:
/**———————————————-
* Fraud detection system by Parvez Akther
* first take all ip form paypal and paypal sandbox
* then compare ip with posting script
* if match then proceed next
* if not match generate mail with possible cause
*————————————————–*/
// Get the list of IP addresses for http://www.paypal.com and notify.paypal.com
$paypal_iplist = gethostbynamel(‘www.paypal.com’);
$paypal_iplist2 = gethostbynamel(‘notify.paypal.com’);
$paypal_iplist = array_merge( $paypal_iplist, $paypal_iplist2 );
$paypal_sandbox_hostname = ‘ipn.sandbox.paypal.com’;
$remote_hostname = gethostbyaddr( $_SERVER[‘REMOTE_ADDR’] );
$valid_ip = false;
if( $paypal_sandbox_hostname == $remote_hostname ) {
$valid_ip = true;
$hostname = ‘www.sandbox.paypal.com’;
}
else {
$ips = “”;
// Loop through all allowed IPs and test if the remote IP connected here
// is a valid IP address
foreach( $paypal_iplist as $ip ) {
$ips .= “$ip,n”;
$parts = explode( “.”, $ip );
$first_three = $parts[0].”.”.$parts[1].”.”.$parts[2];
if( preg_match(“/^$first_three/”, $_SERVER[‘REMOTE_ADDR’]) ) {
$valid_ip = true;
}
}
$hostname = ‘www.paypal.com’;
}
if(!$valid_ip){
$this->lastError(“Error code 506. Possible fraud. Error with REMOTE IP ADDRESS = “.$_SERVER[‘REMOTE_ADDR’].”.
The remote address of the script posting to this notify script does not match a valid PayPal ip addressn” );
}
If it worth to add on ur script you can add it.
Thanks
@Parvez: Nice addition, I’ll surely add this on the next version…thanks !
Thanks.
This is the best “PHP Payment script” i had used.
Hy Dear Emran.
i have am very beginner programmer in php
my boss assign me payment integration task
i read you library and understand it little bit.
i have created test account with 2co and i received verdor id.
now how to use it and how to integrate it
please help me if u can
i will be very thank full to you.
if u reffer me some link where i can understand payment integration.
setp by step if posible thanks
Hi Emran,
Thanks for the simple code, i tweeted it 🙂
Do you have an article on how to configure the VAT info? I really haven’t had too much time to sift through all the stuff and i haven’t taken a guess at it yet, but im betting it’s pretty easy?
Would it be ‘unethical’ to consider your full order as a single item with paypal? i.e Order 3012419 – $250.00. Instead of posting all cart items individually?
Thanks again
Hi emran
thanks,nice script…
but i have a problem in running this script in test mode
i have an account on https://test.authorize.net/ and api login and transaction key which i use in your script but i dont know why its giving me error”(87) Transactions of this market type cannot be processed on this system.”;
Can u plz tell me whats a prbl its urgent and i dont have any idea remain…
i also try code got from authorize.net professional site giving me same error…
if u have any idea plz reply me as soon as possible..
Thanks in advances…
What a library!!. I have get the solution for my payment integration in 2checkout by your library. Thank you very much.
I have bookmarked it
In 2checkout example :
// Specify the url where authorize.net will send the IPN
$my2CO->addField(‘x_Receipt_Link_URL’, ‘http://YOUR_HOST/payment/twoco_ipn.php’);
authorize.net ?? twoco_ipn.php ?
see Snippet 5…
This is the best payment class for php.
Thanks.
download url does not work
I just tried to download this (which looks awesome by the way) and the link is not there. The word DOWNLOAD is not a link…nor is the ZIP file name… Just wanted to let you know. Also, is there a new version of this or is this the latest? ALl the comments and activity is early 2009. THANKS!
Fixed the download link, sorry for that.
Hi Friends,
Thanks Md Emran Hasan for this wonderful script.
Here is my code for adding multiple items…
Step1:
in paypal.php
replace
$this->addField(‘cmd’, ‘_xclick’);
with
$this->addField(‘cmd’, ‘_cart’);
$this->addField(‘upload’, ‘1’);
Step2
in paypal_start.php , You can loop through the add item code in following format
for(X=1;X=10;X++)
{
$myPaypal->addField(‘item_name_X’, ‘T-Shirt’);
$myPaypal->addField(‘amount_X’, ‘9.99’);
$myPaypal->addField(‘quantity_X’, ‘1’);
$myPaypal->addField(‘item_number_X’, ‘001’);
}
FYI: Please note _(underscore) its very important for sending data to paypal.
that’s it you multiple item form is ready.
I hope it helps someone…
Cheers
Nitin
Hi Md!
First of all, thanks to share your great work!
I can see that you send the data to paypal through a simple html form, Don’t you think that is unsecure way to send the data? I could create an html file with false data and send it to paypal, How can I prevent this?
Could you give me an advice?
Thanks and sorry for my english (i’m not an native english speaker).
NB from Argentina.
I’m newbie on authorize.net and getting this error on
URL: https://test.authorize.net/gateway/transact.dll
Error: The following errors have occurred.
(13) The merchant login ID or password is invalid or the account is inactive.
can anybody help me on this.I checked already my status on authorize and its active.
regards
I want to know should o make any configure to payal.com before make online payment gateway intregreation
Is it possible to create a standard html page for the Redirect
PHP Payment Library for Paypal, Authorize.net and 2Checkout?
I can see that it starts with a echo “n”; and ends with a echo “n”;
So is it possible to create a custom html page and convert it so that it works in your library?
kind regards
Michelle
Hello Imran vai,
Is there any update about your library?
It would have been helpful if you had provided us with the html form example too. As I need to research which custom values to use in order to submit the information.
I know this is quite an old script, but just thought I would point out that there is a security issue in the 2checkout library IPN code. You verify it against the vendor_number that was submitted, not the configured. Therefore as far as I can see an attacker could change the submitted vendor number to their own in the original request, and pay themselves (or whoever they like), and your library would be none the wiser, and still mark the order as paid.
Very very nice and useful tutorial. Thank you very much.
Hi thank u for your code..how to do hold and capture of transaction in 2checkout, hope for your reply ..
By God. You made my life easy. Thanks a ton.
Keep Rocking.
I’m always searching on line for tips to help me. Thanks!
it very very useful and great…thank u so much
Hint: The paypal_ipn.php has to be accessible from the internet even if you just want to try out the library with the sandbox, or it won’t work. While paypal_success.php and paypal_failure.php are called by the customer’s browser, the paypal_ipn.php will be called by Paypal directly once the customer paid. Obviously the service cannot reach the script on your machine if you supply an url like http://localhost/…
Greetings from germany,
Warpenstein
Unfortunately validateIpn() method is no longer working with the current PayPal IPN, so this library is useless for PayPal.
man you are rock!!!!!!!!! thxs for save all developers time
Hello!
Thank you for a great library.
I am just wondering how I can port this to Codeigniter? Have you already done it?
Thanks!
Hi,
I need the library with recurring payment for paypal, its urgent 🙁
Can someone send me it? email: paulo(at)prsolucoes.com
Please i need too much.
Dear sir Your code us very excellent.
I have a little problem during authorize.
A415 Error 13: The merchant login ID or password is invalid or the account is inactive.
I have add correct info in that variable
$myAuthorize->setUserInfo(”, ”);
Hello Emran Hasan,
Nice work man, can u help me how to use paypal payment in normal mode rather than in sandbox. please help me. thank you
how i can add multiple product in paypal
I have an other IPN Script. It should work but i cant convert it to work with this script.
can someone help me to fix the IPN part?
$value) {
$value = urlencode(stripslashes($value));
$req .= “&$key=$value”;
}
// post back to PayPal system to validate
$header = “POST /cgi-bin/webscr HTTP/1.0rn”;
$header .= “Content-Type: application/x-www-form-urlencodedrn”;
$header .= “Content-Length: ” . strlen($req) . “rnrn”;
$fp = fsockopen (‘ssl://www.sandbox.paypal.com’, 443, $errno, $errstr, 30);
if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, “VERIFIED”) == 0) {
// PAYMENT VALIDATED & VERIFIED!
$text = “jon”; // Dateiinhalt
$dateiname = “daten.txt”; // Name der Datei
// Datei öffnen,
// wenn nicht vorhanden dann wird die Datei erstellt.
$handler = fOpen($dateiname , “a+”);
// Dateiinhalt in die Datei schreiben
fWrite($handler , $fp);
fClose($handler); // Datei schließen
}
else if (strcmp ($res, “INVALID”) == 0) {
// PAYMENT INVALID & INVESTIGATE MANUALY!
$text = “non”; // Dateiinhalt
$dateiname = “daten.txt”; // Name der Datei
// Datei öffnen,
// wenn nicht vorhanden dann wird die Datei erstellt.
$handler = fOpen($dateiname , “a+”);
// Dateiinhalt in die Datei schreiben
fWrite($handler , $text);
fClose($handler); // Datei schließen
}
}
fclose ($fp);
}
?>
ipn script generator to fix the paypal problems:
https://www.paypaltech.com/SG2/PHPfunctionalityparse.php
Thanks….Emran bhai…very good code.
I applied some of the fixes above, made some embellishments, and fleshed out the Google class that was started at http://code.google.com/p/phppayment/ but not really completed.
I only focused on implementing the Paypal and Google modules, so if you’re using one of the others, make sure changes to the PaymentGateway class aren’t getting in your way. First commit to the repository is the same as the original zip file on this site.
Code is available at:
https://bitbucket.org/greenhollowtech/emran-payment/overview
Glad to know that. However, there is a new version of this library already here: https://github.com/phpfour/php-payment. You may want to have a look into it, its a lot cleaner and better designed version.
For the PayPal script it requires that a user creates an account before they can purchase something. Is it possible to make it so they can purchase as a guest?
Not for Paypal.
Thanks Nitin, it really did,
Md Emran Hasan thanks for the great script, easy to addapt.
We cannot process this transaction because there is a problem with the PayPal email address supplied by the seller. Please contact the seller to resolve the problem. If this payment is for an eBay listing, you can contact the seller via the “Ask Seller a Question” link on the listing page. When you have the correct email address, payment can be made at http://www.paypal.com.
Well done man..thanks a lot ..it helps me a lot … 🙂
Any updates on Recurring Payment for PayPal ?
Can’t seem to download the class. For some reason, there is no link available. Any updates? Thanks.
Nevermind, I guess I had to keep reading the comments. 😀
hello Emran Bhai,
This is a nice library you have put here and thank you so much for this.
im trying to make it as a joomla library and everything is working fine except after user making payment,its not auto redirecting to my website rather user has to press return to “Seller name” site to get back into the site again.
Ive enabled auto return to true in paypal setting also but with no luck.
could you please tell me if theres anything im missing ?
I downloaded this from gitHub (https://github.com/phpfour/php-payment) and assume that that is the latest version…however there are no examples for using Auth.net. The title says PayPal, Auth.net, and 2CO…but I only see examples for PayPal and 2CO. Am i not looking at the latest version (please let me know updated link) or has nobody made an Auth.net example? Thanks!
Hello Imaran Hasan Vaia,
Maybe you changed any plugin that’s why i can’t see the download link of the library. would you please fix this article. Thanks
I just cant see the download link!
and the link? I can’t download
sorry, where can I download the Paypal.php scripts?
Provide me with the download