I'm trying to make a recurring payment system with paypal on my own website.
People on my website have accounts, and they will pay in order to get more options.
I've a "suscribe" button created with paypal (price, payments intervals etc choosen in paypal). Onclick, my customer is redirected to paypal website in order to continue his purchase.
This is working, if the payment performed I add options to the user in my database.
So, there is a recurring payment each months but I have to create a "Cancel" or "Disengagement" button.
This disengagment button have been created too, so onclik the user is redirected to the paypal website to cancel his subscription.
If the subscription is canceled, paypal send me informations with the IPN (Instant Payment Notifications) to an URL indicate in paypal options (paypal-notification.php).
The problem is that the user isn't redirected to my website after this, so I can't get his session information (id or email indicate in my database) to delete his options in the database.
I think that is possible to add custom options to paypal when a user suscribe at the options. For example, I give the user ID (of my database) to paypal when he is suscribing and Paypal give me back this Id when the user cancel is suscribtion ?
Thanks !
PayPal uses a subscription ID. When you're registering the subscription you can send through a custom ID, normally an order ID but in your case it could be the user ID. So you just add <input type="hidden" name="custom" value="$id"> to your form, and then the IPN will have that ID in it for every notification, including the cancellation notification.
When the user first subscribes you'll get a subscription started notification from PayPal, at that point you should record the ID given to this subscription by PayPal. It's stored in the subscr_id value passed back by PayPal IPN. Then when the user cancels the subscription the notification will have that subscription id, which you can use to identify which user has cancelled their subscription. This would be the better way, rather than relying on the user ID being passed back from PayPal.
Related
I wrote a website in PHP last weeks. Users can register and login to my website. Logged in users are also able to buy an item on the site. Payment is handled by paypal via a paypal payment button. Payment is working fine, but.
Problem:
When a logged in user pays for the article, i only see in paypal that someone bought my article. but i need to know which user it was. Is there a way to store the username of the user that bought the article?
Its a problem that the paypal button is created by paypal, i cannot modify that button with my own code.
Which Payment product are you implemented?
For PayPal Payment Standard, there is "custom" variable that you can specify anything for your own tracking purposes:
https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables/#id08A6HH00W2J
For Express Checkout, you can use "PAYMENTREQUEST_n_CUSTOM" variable:
https://developer.paypal.com/docs/classic/api/merchant/DoExpressCheckoutPayment_API_Operation_NVP/
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.
When using Paypal Standard Payments what is the best way to tie a customer to an order before payment? When the customer clicks 'checkout' the site will store information about the order in the database with a status of 'pending' and then send the user to Paypal to complete their purchase. After purchase I plan on using IPN to verify the payment and store customer shipping info in a separate table. How should I tie the original order information to the shipping info? I could ask the user for their Paypal email address before sending them to Paypal and store that alongside the order information but maybe there is a better way?
With PayPal's Website Payments Standard, you can send the identifier for your pending order (header) as the CUSTOM variable in your form. PayPal will return it to you in the IPN message. See https://www.x.com/developers/paypal/documentation-tools/ipn/integration-guide/IPNandPDTVariables Table 2 for other items that can arrive in the IPN message.
I have a recurring payment solution set up via PayPal's IPN service, basically the user fills in a form, pays the money and via IPN my system gets a ping to grand the user access to the system.
Everything technically works fine, but occasionally on the last day of a user's cycle they forget that it is a recurring payment and complete the form again. PayPal doesn't seem to mind this and creates a second recurring payment profile.
Currently I go in, refund the money and cancel this new payment profile, but obviously this isn't ideal - is there any way I can configure PayPal to not accept new profiles from people with currently active profiles? Or will I need to catch this at my website's end and do some form of lookup before allowing the payment?
Paypal did not recognize the a transaction is a duplicate one, It tackles the transaction as a new transaction. You will have to tackle it from your system.
When implementing payment gateways, It is good approach to save the billing with a status pending or something in your system before sending to payment gateway.
Also in the form user is filling you can implement a field to uniquely identify the user like his email address and you can also save the expiry or second recurring date against the user unique field in your system. Now when the user enter the same unique field and want to submit a form again you can validate that the same user is paying again but its expiry of second billing date is not yet reached, so prompt and restrict him for paying again.
Hope it will help you.
Am having a lot of trouble getting my head around this paypal payment stuff...
How can i confirm that the user has successfully signed up for my subscription?
I know 0 about IPN but for example : If a user signs up to my website with example#e.com but uses the paypal account sample#s.com to pay then how to i match up the user.
I read that PDT do not send out a transaction ID (tx) for recurring (subscription) payments is that true ?
Just need help with it all... honest and easy :)
Thanks.
Yeah sometimes is hard to understand Paypal and all their documentation but for any kind of subscription i would recommend Paypal IPN. You set IPN URL in your paypal account for example: http://www.domain.com/ipn.php. Then you create a subscription button in paypal account where you can set the price, recurring price etc.
More about Paypal IPN you can read here:
https://www.paypal.com/ipn
When creating Paypal button you can also add some custom fields which can help you determine which customer really pays. So for example you have a database of users and there is user with userid=100, username=Nickname and registered_email=xxx#gmail.com. Now you can decide to add userid=100 as a custom field and add this to paypal button. For example CUSTOM=100.
ipn.php in this case is a script which handles all the logic. When user pay, Paypal send any status to http://www.domain.com/ipn.php (you set this in your paypal account as IPN URL). So ipn.php in this case needs to check if payment is complete and status is ok. Then retrieve a CUSTOM field ($_POST['custom']) which is in this case 100 (userid). And then update your database with users and somehow mark that this user payed of course if status is Completed.
Hope this helps a little. But in this case it's not really important from which paypal account user pays and which is registered in your database. All you need is that you somehow link it together. In this case with userid or something like that.
If you want to implement Paypal IPN and your customers don't use same email from my experience you can use a form to authenticate the user
user login on your website with xxx#example.org
user clicks on your item and pays with yyy#example.org
after he pays you can redirect him to a form where they can merge Paypal account with website account
every time that user pays then your IPN will be covered by the information he provided
you should save his payment information for later use.