Confirm Express Checkout on PayPal via PHP - php

This question asked before but didn't got any answer.Maybe things have been changed.
When you click the Express Checkout PayPal button on any webshop, it redirects you to a specific paypal login link, for paying the order.
I have been searching high and low for 3 weeks for a simple paypal php curl script that logs you in from this step, and confirms the payment, but have not been able to find anything.
I found out it is not possible to use the API for this, so its gotta be done by CURL.
I'm asking for this because I run a dropshipping website, and would like to automate certain steps, like placing and paying orders. A working code for this would help not just me, but all looking to automate buying in some form.
Thank's!

You can't log the buyer into PayPal when you redirect them to the site. The buyer has to enter their own account credentials themselves.
If you wanted to bill a buyer without requiring they log into PayPal each time you would need to use billing agreements (reference transactions) through Express Checkout. If you set up a billing agreement with a buyer you can charge a previously successful sale to bill them again for a different amount.

You cannot do what you want with Express Checkout, especially since nobody will ever enter the paypal details on your website (that is the entire point of paypal).
You can use either preapproved payments (buyers preappove payments being taken out of their account up to a certain ceiling), or reference transactions (you reference a new transaction to an older transaction. PayPal will then use the billing details of this earlier transaction to bill the user).
Preapproved payments is part of Adaptive Payments. Documentation is at https://developer.paypal.com/webapps/developer/docs/classic/adaptive-payments/integration-guide/APIntro/
You can find more details about Reference Transactions at https://cms.paypal.com/uk/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ECReferenceTxns
Note: Reference Transactions needs to be enabled on your account. This API call is not open to everyone due to the potential for abuse, so you may want to look into whether you're eligible for it before you start working on a full integation with it.
You can find more info here :https://www.paypal-community.com/t5/Merchant-services-Archive/Does-Paypal-have-a-quot-Token-Payments-quot-concept/td-p/325794
Also google "token payments" as that is what you need and most payment gateways usually support them.

Related

IPN works for "guest" payments but not paypal account holders

I have a subscription payment set up for my website. When a user clicks to subscribe, they are taken to a Paypal page with the option to log in and pay through their Paypal account or to continue basically as a "guest" and enter their credit card information. When a payment is made, it is supposed to open extra features on the user's account.
When making test payments, payments made as a "guest" would go through and be relayed to my site to open the extra features for that user. However, any time I log in to my personal Paypal account to pay, the payment itself will go through but it is not being recognized by the website to unlock the additional features.
We have looked for settings that may need to be changed, such as enabling PDT, but that did not help. The website is receiving all the proper information from "guests" but I don't understand why someone logging into their Paypal account would be any different and cause this problem. I don't want people to be paying money and not getting what they are expecting. Any ideas how to fix this?
When unlocking the extra features, is the redirection URL included in the code? I would suggest to use IPN to assist with this feature.
https://developer.paypal.com/docs/classic/products/instant-payment-notification/
Do note that for subscription payment, it might take a few hours for the profile to be active on the PayPal site.

How can I make an automatic PayPal buy button?

I want my PHP web application to have the ability to save the user's PayPal details in their user account.
When they go to purchase items, rather than going through the standard PayPal form, it will automatically grab the user's PayPal details from their user account, and make the payment directly from my website. There is definitely a way to do this, as I have seen this feature on sites such as Freelancer.com
Thanks for the help! :)
No, you don't need Payments Pro for that. That would only be if you want to do it with direct credit cards. What you're after in general is called Reference Transactions, and when done with PayPal Express Checkout it uses Billing Agreements.
You'll use Express Checkout and/or Payments Pro (optional) to process an original authorization or sale transaction. Then, you can send that ID you get back in that original transaction along with a new amount in the DoReferenceTransaction API and that new amount will be instantly processed without any redirection or further authorization required.

Adding Credit Card Payment Support to my website

I've puzzled by this question for quite a while, but never had the need for it. Now I do.
What I currently need is a Credit Card payment option for my website that does not rely on services such as Paypal. I want something like Name.com or Hostmonster.com have. You simply enter you credit card number, expiration date and the three little numbers at the back of the card. How can I achieve the same effect on my website?
I'll be programming the website in PHP.
Answers would be appreciated.
You need to signup to a payment gateway. It's a service that allows you to process credit card payments. I know you don't want to use PayPAL to accept payments, but PayPAL offer two solutions:
PayPAL Payments - That is the button and people pay through PayPAL
PayPAL Payments Pro (Payment Gateway). That is when you use PHP or anything else to connect to PayPAL with the credit card information. The customer never knows you used PayPAL, and they never leave your site.
When choosing a payment gateway these are the four most important things you should consider:
How easy is it to implement (PayPAL has a lot of documentation)
How much is the monthly fee.
How much do they charge per transaction.
How much do they charge to setup an account.
There are other options, and one of the most common is Authorize.net, but the is more setting up and a larger deposit to open an account.
Most accounts will require a background and credit check.
Well, you'll still need to rely on a Merchant Services company for card processing. There are many companies that boast an API that can then be accessed with PHP. One that I have recently learned of is Stripe. However, there are many competitors and you can research other companies further, but companies like Stripe will allow you to generate payments programmatically without having to leave your site to visit the black-box that is PayPal.

PayPal checkout solution confusion

I am trying to figure out exactly what payment solution to use for my site.
I would like to do the same thing as Spotify (https://www.spotify.com/us/freetrial/ - You'll need to login to see it), allowing users to choose whether they want to pay with PayPal or use a credit card and then taking them to a payment selection screen (on PayPal), then returning them to my site to click confirm and buy.
I am already paying for recurring payments (even though I've yet to use it) and am unsure if that is applicable here. I have also integrated express checkout but I don't know if it will allow recurring payments.
EDIT: Do I need a separate token for recurring payments? Do I have to use the old recurring payments checkout screen? How can this be done as efficiently as possible, like Spotify? Here are my efforts to create a recurring payments profile after express checkout: http://pastie.org/private/sakzopltnwfv93wwmduqq
Diagram:
Select Buy & PayPal (subscription) --> Choose Payment (on PayPal) --> confirm & pay (my site)
This is what spotify's checkout looks like (It wouldn't say update for first time users):
Are they using recurring payments + express checkout? I would really appreciate some help with this.
Yes, you can get this done with Express Checkout + Recurring Payments. That said, if the person chooses credit card when setting up a recurring payment they will have to create a PayPal account. If they're paying a non-recurring checkout then they could use the credit card option without creating a PayPal account.
You mentioned that you're already paying for recurring payments..?? Are you referring to Payments Pro? If so, you don't need to pay for that to use EC + RP. Pro is only necessary if you want to process credit cards directly on your site without ever redirecting to PayPal. This can sometimes make things seem a little more professional and would also give you the ability to let people setup recurring payments without creating a PayPal account when using a credit card.
When using EC you just need to make sure to include the billing agreement parameters in order to get a token back that will work within CreateRecurringPaymentsProfile. Refer to the SetExpressCheckout API reference for more details on that.
This is kind of old now, but is still useful. Take a look at this sample express checkout set of api calls. You'll notice it uses the same token throughout all of the calls.
Just like Spotify -you would need to build that option on your site. If the user chooses to subscribe with a credit card - use the recurring payments w/ direct credit card (see below). If the user chooses to subscribe with a PayPal account - use the recurring payments w/ PayPal Account (this is what Andrew is suggesting above in his response).
Here are the how-to guides:
For direct credit card subscriptions: https://www.x.com/developers/paypal/documentation-tools/paypal-payments-pro/how-set-recurring-payments-profile-using-direct-payment
For PayPal Account subscriptions: https://www.x.com/developers/paypal/documentation-tools/express-checkout/how-to/ht_ec-recurringPaymentProfile-curl-etc
The APIs would allow you to do things like trial periods, setup fee, etc. For example here is a how to on building a freemium kind of model: https://www.x.com/developers/paypal/documentation-tools/express-checkout/how-to/ht_ec-freeTrialRecurringPayments-curl-etc

How do I get data back from Paypal so I can alter my MySQL database accordingly?

I'm just starting out with Paypal, so this is a newbie question.
I've been going through the instructions for setting up Paypal subscription service, but I think I'm looking at the wrong thing.
What I want to acheive is to get back some kind of response from Paypal so that I can update the database on my web site to mark a registered user as having paid. Basically I have a flag in the database that says if the user is subscribed or not. I want to ensure that the user is marked as paid so long as their Paypal subscription is maintained.
While the instructions linked above do say how to set up a button to receive a payment, there's nothing there about getting any data back from Paypal.
I know there are terms like IPN and sandbox that are related to what I'm trying to do, but I can't find clear instructions for how to get started on this process. I'm just circling around and not getting anywhere.
Where do I start on setting this up? Where is there a clear beginner's tutorial?
Also, I'm using PHP/Javascript/MySQL on my website.
PayPal's IPN service is what you want to use. I've used it myself to do just what you're looking to do.
Instant Payment Notification (IPN) is PayPal's message service that
sends a notification when a transaction is affected. Once IPN is
integrated, sellers can automate their back office so they don’t have
to wait for payments to come in to trigger order fulfillment. IPN can
send notifications for these transactions:
Instant payments, including Express Checkout and direct credit card payments
eCheck payments and pending, completed, or denied status payments
Pending payments
Recurring payments and subscriptions
Authorizations
Disputes, chargebacks, reversals, and refunds
You can also view notifications on PayPal’s IPN History page and
resend them if you need to. As PayPal’s interface for handling
purchase confirmation and server-to-server communications, IPN can
also be used to manage and customize a variety of APIs and
communications, including:
Customize your website's response to customer purchases in seconds
Track customers via IPN "pass-through" variables
Notify sellers who deal mostly in software downloads and other digital, online goods
Track affiliate sales and commissions
Store transaction information in your own database
For more about IPN:
Technical Overview (link to new html version of docs on developer central)
Instant Payment Notification Guide (PDF)
Code Samples
I'm not sure if its the same thing, but I just setup my friends website with Express Checkout, and I wanted to add all paid orders to an orders table in my database.
After I call SetExpressCheckout, and the user is returned to my site after going through the purchase flow on Paypal's side,
I used the information from GetExpressCheckoutDetails.
Then, if DoExpressCheckoutPayment
is successful (also called from the "callback" page) I then do the appropriate work in my database as far as logging the order details. For you in this case, it could be updating a record for the user in the database.
Hope that helps a little.

Categories