DISQUS

Md Emran Hasan (phpfour): PHP Payment Library for Paypal, Authorize.net and 2Checkout (2CO)

  • Pete · 10 months ago
    Thanks man!
  • hasin hayder · 10 months ago
    bookmarked!!

    excellent writing, carry it on
  • ranacse05 · 10 months ago
    thanks , its very much helpful .
  • MadMax3000 · 10 months ago
    Awesome - Awesome - and Awesome

    Thanx
  • Nurul Ferdous · 10 months ago
    Downloaded :) Thanks man!!
  • Md Emran Hasan (phpfour) · 10 months ago
    I'm glad that you people are finding it good :) And yes, two new gateway will be added soon: Internet Secure and Google Checkout.
  • ganz · 4 months ago
    For PayPal payment success echo "Success"
    if fail ---> How can i rollback Mysql update?
  • Gus · 10 months ago
    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?
  • Shimon · 10 months ago
    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!
  • Md Emran Hasan (phpfour) · 10 months ago
    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 :)
  • Shimon · 9 months ago
    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.
  • Shimon · 9 months ago
    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
  • Md Emran Hasan (phpfour) · 9 months ago
    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.
  • Luke · 10 months ago
    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.
  • MJ · 10 months ago
    Thank you, this is great!
  • Mhd Zaher Ghaibeh · 10 months ago
    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 :D
  • Md Emran Hasan (phpfour) · 10 months ago
    Thanks man, if you do develop, post a link here with your MoneyBooker class. It would be much appreciated :)
  • Will · 10 months ago
    I agree with Hasin. Bookmarked for sure. Thanks man, I was looking for something like this awhile back.
  • Guhan Iyer · 10 months ago
    Excellent work! This will useful for my clients who have custom shopping carts built into their websites. Thank you!
  • JP · 10 months ago
    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.
  • JP · 10 months ago
    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!!
  • Md Emran Hasan (phpfour) · 10 months ago
    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
  • francesco · 5 months ago
    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!
  • Geekalicio.us · 9 months ago
    Any updates on adding recurring/subscription payments? Thanks!
  • Sean Nieuwoudt · 9 months ago
    When will google checkout be added?

    Regards,
    Sean
  • Md Emran Hasan (phpfour) · 9 months ago
    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 :)
  • Darrell Greenhouse · 9 months ago
    Thanks from the U.S.

    Just starting to review your work, but I believe it will save me a load of time.

    Thanks again
  • Jason Brooks · 9 months ago
    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.
  • cf · 9 months ago
    can u add the working demo link as well!
  • Md Emran Hasan (phpfour) · 7 months ago
    There is no working demo mate, sorry!
  • niaoren · 9 months ago
    thank you ! man!

    And hope the google checkout will be released!
  • Rich Pedley · 9 months ago
    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.
  • Mahmud Ahsan · 9 months ago
    Really a nice, organized and very essential library.
  • Md Emran Hasan (phpfour) · 7 months ago
    Thanks!
  • Agam · 9 months ago
    Nice
  • Md Emran Hasan (phpfour) · 9 months ago
    Thanks!
  • Karl · 8 months ago
    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.
  • Md Emran Hasan (phpfour) · 8 months ago
    That's great to know Karl. Go ahead and finalize your additions. I am thinking about keeping a wiki with all the changes, and keeping a list of payment processors there. Maybe every now & then add one processor and if others want to contribute, great !
  • Paul · 8 months ago
    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.
  • Md Emran Hasan (phpfour) · 7 months ago
    The custom value will be available in the IPN post values returned from the paypal server.
  • Jack · 6 months ago
    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
  • mahfuz05 · 8 months ago
    excelent work. If you add another Google Checkout its will be great.
  • Md Emran Hasan (phpfour) · 7 months ago
    Thanks
  • brian · 8 months ago
    sweet!
  • Sam · 7 months ago
    can we integrate code without going on paypal wesite. It should not redirect to paypal's website
  • Md Emran Hasan (phpfour) · 7 months ago
    Sorry, you have to redirect to Paypal's website for payment - it is mandatory.
  • Austin Mount · 7 months ago
    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
  • Md Emran Hasan (phpfour) · 7 months ago
    Hello Austin, good to know the base class helped you. And thanks for sharing the snippet for allowing multiple items :)
  • cubanhenry5 · 5 months ago
    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
  • muhit · 7 months ago
    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. :)
  • Ambassador · 7 months ago
    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?
  • Md Emran Hasan (phpfour) · 4 months ago
    Well, yes its that simple. If the developer knows what he's doing, he can do this in one single PHP page.
  • prakashkommerla · 7 months ago
    its very useful...........

    Thanks
  • quantro · 7 months ago
    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
  • Jack · 6 months ago
    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!
  • Md Emran Hasan (phpfour) · 4 months ago
    Good to know its helpful. You'll get the passbacks on the IPN handler. Use this:

    echo $myPaypal->ipnData['custom'];
  • jigish · 6 months ago
    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
  • Md Emran Hasan (phpfour) · 4 months ago
    Sorry. You can get yourself from their site.
  • Ofer · 5 months ago
    Grear post, saved me a lot of writing efforts.
    I took your tool as a infrastructure for my payment system.
  • Tomh · 5 months ago
    Where is INS parser?
  • vishal · 5 months ago
    your code who processing the payment using paypal does not pass multiple items . so send the solution of it as well as possible.
  • ZMax · 5 months ago
    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?
  • Md Emran Hasan (phpfour) · 4 months ago
    You might be running an old PHP version. This needs PHP5. Thanks.
  • diseoweb · 5 months ago
    Thanks for the contribution will prove, it!
  • ariful · 4 months ago
    boss you become famous for this classes, see at http://komunitasweb.com/2009/03/20-great-php-li...
  • Md Emran Hasan (phpfour) · 4 months ago
    Thanks for sharing!
  • vancuong3682 · 4 months ago
    Thanks for your library,
    Thank you very much indeed,
  • southfranceproperty · 4 months ago
    Brilliant! :)