Paypal ipn processing and dropdown option/price buttons logic - process

I read lots of post from various sites including paypal documentations. But I have some quesitons wihch I couldnt solve those. One of them is that how to design the codes after receiving the ipn message. Ofcourse I make my code I am able to optain and process the variables of message. like payment status and I am able to save them into database. But the point is that how should I desing the code to control the payment to overcome my requirements. I know the post become long but I feel the need of this explanation. So I have a site which works with membership with payment. Site is check after login the membership trial is expired or not if it is expired it shows a div in fornt of the site wihch includes the paypal buttons and redirect to paypal payment screen when button is clicked. User shodul have ability to choos membership period like 6 or 12 mounths (by dropdown paypal button). When the user finalize his payment ipn is trrigerd and I get the datas but all my members dont have to have a paypal account so they can use therid credit card directli and if I understand correctly the transfer of money can take some time to be recevied by me. Which time interval I should set the members approved flag is true ? I am confused about this. If I approve him after ipn is sent is there a possibility an error can occure while transferring me. How the process works.
other problem is the dropdown button. when I set option/price button when I click the button an error page is shown after redirecting to my selling page. It does not redirect to the payment page.
Realy sorry for my long post but I dont know how can I descirebethe situtation in a short way

If you need to wait until funds are available, you should test the value of "payment_status" in the verified IPN message for "Completed".
An eCheck can take from 3-5 days for collection (sometimes longer; you can see the estimated hold time in your account) and has payment_status="Pending". Once collected, you will get another IPN message with "Completed".
Note that the user never sees the IPN process. Normally you set up the conditions (in a table or something that is persistent enough), then send the user to PayPal. When the user comes back from PayPal, your code (at the "return_url") checks the table to see if Payment had completed successfully (perhaps a flag, which was set by your IPN handler code that is called by/communicated with PayPal when the user leaves PayPal gracefully).

Related

A good way to check if the payment form was left off in between

We use PayPal to accept donations on our website. The problem we're facing is usually this happens that a user clicks on the pay button on our website but then for some reason drops from PayPal.
Is there a way through the PayPal API we could check that the user for some reason left off the transaction or maybe his transaction was denied.
No there is not; keep track of that drop off yourself if they don't come back or you don't get a resulting transaction.
If you are not using an API to accept the donations, then to be notified of resulting transactions you can use Webhooks. A parameter you can use for reconciliation is custom, which can be set at the moment the user clicks 'Pay' and you redirect them to PayPal.
(But if you are using an API, then the API is your notification already)

How to set trial period in shopify app?

I have created shopify app and setting up billing Api. In the App, I want to apply trial period of 20 days. I have created the charge during the app installation and send customers to confirmation url so that they can accept or decline the charge.. So I want to know that if customer decline the payment charge, then can he uses the app featurs till trial period?
If a customer declines the subscription, you still get the confirmation URL callback. Examine the charge. The status will say declined. At this point you can kill off their DB token and destroy their session. This will ensure they cannot use your App as they declined the terms.
It is one bad aspect of the whole billing scenario. I have lots of customers that are faced with a question they don't read. So they assume the trial you offer for free is activated by declining the subscription. Silly customers... still cannot operate the Internet :)

Get transaction details in real time, Paypal

I am creating a website and instead of using a fully featured shopping cart I want to use the Paypal API to "automate" some functionality.
By that, the user clicks on the "buy now" button goes and makes payment to paypal, and I want them to be redirected back to my site so I can process some info for my database. I looked into IPN but it seems like an overkill. Is there any simpler way of doing it?
You should look at either IPN or Express Checkout.
If you are using web standard payments it is important to note that a customer does not have to return to your page, once they hit pay on the Paypal site - the transaction is complete. Hence relying on them to return to your page to do a database update is a bad idea. This is where IPN comes into play.
Express Checkout gets around this by allowing the customer to authorize on Paypal and complete a transaction on your site. Passing the data directly to your site once the transaction is complete.

Is this processus to pay a user, reliable and safe?

I'm working on a project that require my application to pay the user to his paypal account when he asks it.
Here's how I did it so far:
The (logged) user goes to the Pay page that will list all his Payments (received or not)
He enters his Paypal email and his application (mine) password (for security)
The POST page get a list of all the Payments that have status="UNPAID" for that user and update the status to "WORKING" (to avoid the user to refresh the page before the whole process is done and resend the same amount of money)
We count the total amount to pay in that list (a simple for)
The amount is sent to Paypal via Paypal Adaptive Payment API (request: PAY)
The response is checked, if completed, the list status is set to "COMPLETED", if not, the list is reverted to "UNPAID" (the SQL update is made via a WHERE id IN(x, y, z) in case a second Payment request has been made during that time.
A message is then displayed to the user
But I need your help, I'm in front of one risky problem I'd like to avoid, and I would know how you would do:
If the user hit refresh on the process page, I don't want to send him twice (or more) the amount (The "WORKING" lock is here for that, but what happens if the user hit refresh before I set the lock ?)
Rare possible: what happens if the user hit f5 after the lock "WORKING" is made, but before the request to paypal, and a new payment is received. By following what I did, just one item (the new) would be get and set to WORKING, but all others previous payment would be losts
How would you do? What is the best way to make it to be 100% reliable?
Thanks for your help
Note:
The steps between 4 to 6 is made via a PlayFramework jobs, called with now() and awaiting() the result
you can:
prevent double post via JQuery
use the checkAuthenticity() method to validate the request
do a GET redirect after processing the POST (so they can't submit the same 2 times even by mistake)
do the payment processing asynchronous (see below)
For the payment, instead of calling the job, set the id's of payments in a queue (or table in the database) and a job that runs once per minute that processes that table if it has some data. When the user does the POST you redirect to a page that says that you are processing the payments and will notify if there is some issue. You can notify the user later via a UI warning using comet or via mail.
That way you don't link the request to the processing, and you won't have threading/racing issues, as well as being able to detect stale requests (payments already done) if you do a sequential processing.

DNN Problem: Dynamic Registration, Paypal, and User Creation

I'm having a problem with the module Dynamic Registration for DNN.
The module is set up with form completion events in such a way that a user gets redirected to paypal and on completion of payment a user gets created and an email is sent out.
I also have it set up so that an email gets sent out on completion of payment, just to test that the module knows when payment has been completed.
I tried going through the process with the payment gateway (Paypal) enabled - the email gets sent out, but the user does not get created. When I disable the payment gateway, however, a user does get created as well as the email is sent out.
Is there something I'm missing here that is making the module not realize it needs to create the user?
The fact that the module sends out the email makes me think that it should also trigger the Uesr Creation event.
Any ideas/hints as to how Dynamic Registration works with Paypal or how I might be able to fix this?
When the user returns to your site from paypal you must have Friendly URL's turned on or the site can't read the data sent back from paypal.
I found the following information at http://www.datasprings.com/Products/ProductForums/tabid/727/forumid/3/tpage/1/view/topic/postid/4581/language/en-US/Default.aspx#4581
When PayPal integration is turned on:
The user is redirected to PayPal based on the information and settings within your PayPal Payment gateway. This includes the PayPal login, sandbox or standard gateway, and payment information/additional parameters.
Completion events do not get fire off initially
How do completed events get fired off?
When PayPal is enabled Dynamic Completion Events need to be ‘linked’ to PayPal IPN codes. In short, this means that you will specify within the PayPal payment gateway section which ‘completion events’ should be fired off basically conditionally upon which IPN code PayPal will send to your registration form.
For example: Maybe you want to setup a completion event to add the user to a security role, but you only want this to happen when the payment is completed. You would first create the completion event, and then you would ‘link it’ within the PayPal payment gateway section under ‘Form Completion Events / PayPal Payment Status’
For example: Maybe you want to setup a ‘Payment failed’ email to be sent to the administrator if a subscription payment fails. You would first create the completion event, and then you would ‘link it’ within the PayPal payment gateway section under ‘Form Completion Events / PayPal Payment Status’