Paypal api get success or failed - php

Ok so I have built my shopping cart system for my site that uses PayPal Parallel Payments to multiple sellers since the site allows users to sell thier own items and when a buyer buys stuff, they can buy from many sellers at once. I then figure out the payment to each seller including fee's and then send the user off to paypal where they would pay.
The part I am not sure of is do I create the order ID and update in the DataBase the order has been created but not paid for yet. Then when the users pays for it in paypal, I would update order in the Database it has been paid. At which point I would allow the user access to the content they paid for.
I guess I am asking how do I check to see if the user has payed in PayPal or if the transaction failed due to insufficient funds or something? Is there way to search by the order ID in paypal to see if the order has been paid for?
edit: I know I could use the return URL but that doesn't seem very safe?

Once a Payment is executed (payKey created, user has been redirected to PayPal, approved payment, and is redirected back to your return URL), you can then use the Adaptive Payments API to call and check the status of the payment to determine if the money has really moved.
Use the PaymentDetails call - the status should be COMPLETED if the payment was successful.

Related

PayPal PHP SDK, Getting the Payment Amount

I am using PayPal PHP SDK for processing PayPal payments.
A user adds items to my cart and then chooses to pay via PayPal. I construct a Paypal PAYMENT, send the PAYMENT to Paypal, the user logs in and approves the PAYMENT. The user is then redirected back to my website with the three $_GET parameters where I can then execute the PAYMENT.
All good so far.
According to the code, a PAYMENT holds an array of TRANSACTIONS. It seems each TRANSACTION holds an AMOUNT.
My Question: How do I retrieve what the user paid? If there are multiple TRANSACTIONS that can take place under one PAYMENT - how do I know which TRANSACTION'S AMOUNT to use?
(When I pass the initial PAYMENT to PayPal for approval, I do only provide one TRANSACTION, so I would assume when PayPal returns the approval back to my site, there will still be only one TRANSACTION, however, I do not want to assume this will always be the case!)

paypal Preapproval API

we are trying to add a pre-approval paypal process to our website before a user can bid on any of our items for sale. We currently accomplished this using Authorize.net but want to now integrate paypal as well.
I have been doing some research and am trying to find out if paypal even offers such a solution. The main reason for adding this verification is of course to make sure an individual actually has the money to purchase the item, some items can range from $100-$100,000. Does paypal offer a pre approval process for those types of transactions?
https://developer.paypal.com/docs/classic/api/adaptive-payments/Preapproval_API_Operation/
The Preapproval API gives your application permissions to trigger payments on a user's behalf without further approval (no login required to submit payments with a preapproval ID). There is no guarantee funds will be available when you submit this payment. A transaction with a preapproval ID could simply fail like any other transaction.
It sounds like what you're looking is the Authorization and Capture process, which is probably what you're doing with Auth.net, too.
With PayPal you can run Authorizations from credit cards directly (exactly like you do with Auth.net) and you can also do it with Express Checkout, which would be PayPal login payments.

Custom Paypal Cart (Payment ID Number)

We are working on finding a solution for a custom PayPal cart install. I'll try to explain what actions are taking place then point out where we are having issues.
Here is the issue that we are facing:
1.) Users of our site can purchase a subscription
2.) That subscription once paid for activates several actions on the user’s account.
3.) Subscriptions last for Xx amount of time.
4.) Each hour our cron page runs and checks for payment received or not.
5.) After Xx amount of time (the subscription length duration) if the payment is verified to have been received the users account automatically renews. If payment is not verified to have been received then the account we return to normal.
6.) We have it operating correctly in the scenario if the payment is made from one PayPal account for a single user subscription.
7.) However, if a user uses one PayPal account to purchase multiple subscriptions (for this example 10) and cancels X amount (for this example 9) of subscriptions from within their PayPal account, none of the accounts get cancelled from within our site. Say a office manager submits payment from one single PayPal account (because they are in charge of 10 users accounts). Then immediately cancels 9 of the subscriptions from within that sign PayPal account and leaves one active account in our current setup it still thinks a payment was received for all 10 of the users because it’s checking the account rather than individual PayPal subscription for payment. (Tricky to explain)
** What I am are trying to figure out is how to have this action record the Payment ID # that is given by PayPal for each individual subscription when a purchase is completed and when the cron page runs it would pair the user’s (our site user) account to their Payment ID # and take action accordingly. So this way if 9 of the payment ids did not receive a renewal payment those accounts would become inactive and the one payment ID subscription that did receive payment would active properly.
I hope that makes sense and I would really appreciate anyone's help on this. Thanks a ton!
You should be using Instant Payment Notification (IPN) to handle automated updates based on actions that occur on the PayPal account including new profiles, payments, failed payments, canceled profiles, etc.
Any time a transaction occurs on your account (payments, profiles, refunds, disputes, etc.) PayPal's server will POST all of the transaction data to a listener script you have sitting on your server. Within your script you can process that data however you need to, and it happens in real-time.

PayPal tracking not showing the Receipt ID for certain transactions

I'm using Website Payments Standard account and I have integrated Add to Cart button and Subscription button in my website. Few payments were made by my clients. But upon downloading my transaction history, I cannot view/retrieve the Receipt ID for certain payments, no matter if it is through Add to Cart or Subscription. Few transactions shows blank field for receipt ID. Can anyone guide me in finding out the problem? Is it anything related to my Website Payments Standard account? Or anything related to my client's account?
The PayPal IPN variable reference states the following for the receipt_id parameter.
Unique ID generated during guest checkout (payment by credit card
without logging in).
Sounds to me like you must have some payments coming through via guest checkout and others coming through as actual PayPal payments, so those wouldn't have a receipt_id.

Subscription system with Paypal

I'm developing a restaurant catalog in which the restaurant owners pay a monthly fee for having their restaurant appear on the site. I was thinking in using Paypal recurring payments but I don't understand exactly how it works. Would Paypal automatically charge the fee each month? (Like auto-renew) or would the users be able to decide if they pay or not? I need that the users decide if they want to continue with the membership instead of being automatically charged. How can I achieve this with Paypal?
I'm using express checkout with instant payment notifications (IPN).
Recurring Payments would be a subscription that would be charged automatically unless the profile was in a canceled or suspended state. So if your customers signed up, they can indeed choose whether to pay or not if you give them a way to suspend their profile, which you can do via the ManageRecurringPaymentsProfileStatus API.
If you would rather setup a way where users have to click a button to approve the payment each month then you could go with a billing agreement and a reference transaction. In your SetExpressCheckout request you would make sure to include the billing agreement parameters to get a valid token, and then when the order is completed with that billing agreement you can use the transaction ID you get back from it in a DoReferenceTransaction request in the future to process any amount using the previous billing info that PayPal has saved, so no additional login auth would be necessary.

Categories