PayPal payment intergation with php

This questionis a follow on to this question.

I forgot to mention; we want the customer to be able to pay either through paypal (with  paypal account) or via credit card. Does the awarded answer, based on cover that case as well? Also, in some cases there may be a buyer whose paypal email is not the same as that we have in our database for that client; I presume the payer email used must be that of the payers paypal account, assuming the buyer want's to use their paypal account.

Richard KortsAsked:
Who is Participating?
Ray PaseurConnect With a Mentor Commented:
PayPal can accept credit cards at the same rates as PayPal account payments.  PayPal is quite rigid about its requirements for client verification and email addresses.  So much so, that vendors can rely on shipping products to PayPal verified addresses.  Mismatched emails are simply unacceptable, so if you're using email #1 and PayPal is using email #2, you will have to have program logic to bridge the gap.

My instinct is that instead of going to "evoluted" for PayPal advice you should go straight to PayPal.  They have all kinds of helpful developer documentation.  And if you want to save time you can hire a PayPal developer - they have links for that, too.
Scott Fell, EE MVEConnect With a Mentor Developer & EE ModeratorCommented:
It's too hard to follow the other question because the excepted answer was just a link to some possible test code and not what you may or may not actually be doing.

Payments are one of those things that seem simple in your mind but get more complex when you start adding on features.

In short, you have an invoice table in your database.  That invoice will contain the invoice id and contact id that is related to a contact table.  Then you will have a table of invoice transactions that will contain the invoice transaction id, invoice id, item id and selling price.

You will probably also have a table of payments that contains a contact id, invoice id and amount.

Your cart code adds up the total billed using the invoice transaction table, then subtracts any payments associated with the invoice.

A customer now pays online where you offer to pay by credit card or via paypal.  If the customer chooses pay by credit card or their paypal account, that is something you must account for in your code then send the info via the appropriate api call

Once the payment is accepted, you update your payment transaction table that shows $X amount went to invoice #123.  As mentioned, I put a contact id in the payment table because sometimes the person paying is not the person buying.  

That is an over simplified view.

There are different integration methods and the "easier" methods do make it more complex when you have more custom features.  Also, you can accept payment on your server which gives you more control, but then the pci compliance (essentially running a scan on your server and make sure your server passes) is your responsibility.   When you send the payer to the paypal site, you do not worry about pci compliance but then you also are sending the user to the paypal site and have to build in a listener page on your site to accept the paypal call back.
Andrew AngellConnect With a Mentor Co-Owner / DeveloperCommented:
Your question is pretty broad.  There are lots of potential answers to it.

I would recommend you start with the Express Checkout APIs.  This will allow you to integrate PayPal in a way that you can force "guest checkout" as an option, which is what they call it when somebody pays with a credit card without signing in to a PayPal account.  The checkout still occurs on the PayPal hosted pages, but again, the user does not have to create/log-in to an account.

With EC integrated people who prefer to login and pay that way can do so, and people who do not have PayPal or prefer to enter card details directly will also be able to do so (in most cases.)

Guest checkout is simply not available for ALL transactions.  Depending on the seller and buyer countries and some other variables the buyer may not get the option to pay without logging in or creating an account.  If you're in the US and most of your buyers are US, though, you won't have any issues.

Beyond that, you could then choose to leave Express Checkout integrated but eliminate the guest checkout option.  This way people who choose to pay with PayPal would go through your EC integration and would simply login as they would expect to do.

Then for credit card payments you could use the REST API with "direct credit card" enabled in your REST application settings, or you could upgrade your account to PayPal Payments Pro.  

Pro gives you more functionality for handling direct credit card payments.  When approved for Pro you'll use either DoDirectPayment API or the PayFlow API to send credit card payment requests to PayPal depending on the version of Pro they put you in.

Yet another option would be to use Braintree, which is now owned by PayPal, and it has an entirely separate set of APIs / SDKs you can use to integrate payments.  In fact, the Braintree integration would allow you to include credit cards, PayPal, Apple Pay, Samsung Pay, and more, all within a single integration.

So again, you have all sorts of options here.  You'll need to study each and figure out what suits your business needs the best.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.