Paypal Invoice Response - php

I want to implement Paypal Invoice to send invoices to customers in their emails. I have seenn PHP sdk of paypal for this. Once I implement this, the code will send emails to users with invoice that customers will pay.
Now my question is when customer pay via invoice their email, can my web application get a response of successful payment? Actually I want in my application when existing period of a user expires, I want to send an invoice to user to renew its registration via email. But I want when user made a payment, my application must be know about successful payment so that I can renew user registration. Is it possible if yes then how?

You'll need to setup an IPN listener to get all this working smoothly for you. Once you do that, though, it'll work very well. I've done this sort of thing a bunch of times.
Make sure to include your own record ID / invoice ID in the CreateAndSendInvoice request that you're doing. It would be in the invoiceNumber element in your XML request. More details on that here.
Then, when the invoice is paid, you'll get an immediate IPN notification sent to your listener with a txn_type of invoice_payment. It will also include an invoice_number parameter that matches what you sent in the CASI request. This allows you to hit your data to pull data back out or update your own records accordingly based on the IPN data.
Consider this sort of thing, too. If the person pays the invoice in a way that becomes an e-check, you'll get an IPN with a payment_status = pending. Of course, you wouldn't want to fulfill the order at that point, but you could have the IPN listener send out email notifications about the pending payment, and let the customer know as soon as it clears they'll get another notification.
When the payment clears, you would get another IPN with the same transaction ID and everything, but an updated payment_status. So this allows you to completely automate all of that, and it happens in real time. It's quite lovely.

Related

Verify PayPal Payment with IPN

On my website, I want to set up a "pay to remove ads" feature, and I want to collect payments for it through PayPal. The setup that I want for this is quite simple:
User pays
Payment is verified
The entry in the MySQL database containing the user's information is updated to disable ads on the site for that user
To do this, I want to use PayPal's IPN service. I understand the basics of it, but I am not quite sure how to implement it, nor do I understand how I can trigger the script to update the database for the correct user. I would imagine that to do this, I need to include some means of user identification whenever they begin the payment process, but I am not sure how to do that either. I am trying to implement this in PHP.
The process would be:
The user has an ID
When he pays, you attach this ID as the custom parameter in the PayPal request
You also define what url you want to call for the IPN
Once the payment is complete, PayPal sends the IPN
You verify that the actual status of the payment is "Completed"
You retrieve the user'ID from the custom parameter
You update your table
I hope it's clear :)

Way to check if customer has made a payment?

I'm trying to find a way of checking if a customer has clicked the final submit button to perform a transaction in PHP.
I need to send a second e-mail to different people when the customer makes a transaction, but as far as I can tell, there's no function or property to retrieve some sort of confirmation value.
I don't need to know if the payment went through or not, just if they clicked the last submit button, but the checkout page is hosted on Microsoft's servers.
All of the payment APIs will return a status immediately. You just have to look for it and handle it in your code. How this is done will vary by API.
You can use Silent Post* which is similar to Paypal's IPN. Basically a script on your server will be notified of all payments.
Use the Transaction Details API and look for the transaction in your unsettled batches.
* I am the author of that article

How can get transaction details from paypal after successful payment

My sent data to paypal is
"https://www.paypal.com/cgi-bin/webscr/cmd=_cart&upload=1&business=seller.email#something.com&currency_code=USD&bn=BusinessName&return=http://www.sellersite.com&item_number_1=55&item_name_1=battery&amount_1=55&quantity_1=2&item_number_2=52&item_name_2=bat&amount_2=5&quantity_2=3"
And I want to show those sent data(item number, item name,amount,quantity) and the paypal transaction id to the buyer on "http://www.sellersite.com" after successful payment. (Suppose, the seller has the merchant account with paypal and he would enter that paypal id into database from admin section of the website. So,I would not think about his paypal account settings, my job is just to create the environment for paypal payment for the seller.)
If I write a script like
$T_ID=$_REQUEST['tx']; // or $T_ID=$_GET['tx']; **ref(tx):- "https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/howto_html_paymentdatatransfer"
$item=$_REQUEST['item_number_1']; // or $item=$_GET['item_number_1'];
Then would I get those data from paypal ?
Please tell me.
-Thanks.
It's not going to be quite that simple. You'll need to setup Payment Data Transfer (PDT) in order to get details sent back to your return URL after the buyer completes the payment.
This is useful if you're simply going to display details back to the user, but it's not recommended for updating your own database, sending out email notifications, etc. because there is no guarantee this page will ever be reached so the code won't always run.
For that sort of thing you'll want to use Instant Payment Notification (IPN). This works very similar to PDT except that it will always POST data to your IPN listener on your server regardless of whether or not the user makes it back to your return URL, and it happens outside of your checkout system all together.

Catching duplicate PayPal IPN payments

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.

Flow for: fill form, make paypal payment, create account

I've implemented a paypal transaction before but this one has a twist that I'm not quite sure what's the best way to handle it.
The basic idea is I want to create an account for the user when he provides some details and makes a payment via PayPal. Until BOTH the user details are filled out correctly AND the payment is made correctly, I shouldn't create an account for the user.
The setup I've done before was simply a paypal button that the user clicks, makes a payment, and gets forwarded back to just a generic page "your order will be processed and shipped" so there was no pre-order form involved.
This one is different though because
before PayPal, I need to collect initial user data
after PayPal, I need to create the new user account and use in it the user data collected from the pre-paypal form
I'm sure there's a logical way to implement this, but I'm not quite sure what's the flow I should follow to do it.
I use the Zend framework by the way, which shouldn't matter but just in case Zend has an easier way to help me with what I'm trying to do.
I do the following (though I do this in ASP.NET):
User fills out form
Info is saved in Order table in db with a unique invoice number
Invoice number is passed to PayPal, along with the IPN Notify URL, when you do the redirect
User is sent to Paypal to pay and then comes back to a generic Success page
Behind the scenes, Paypal makes a call to the IPN Notify url once processing is complete. This page receives your invoice number which PP returns with its call, and then does the account creation processing for that order after retrieving the details from the db. [This is a page with no UI, since only PP is hitting it.]
An email is sent from that process which notifies the customer that their account has been created and gives them the details.
This is a simplified version of the process, but hits the highlights. You can check out PayPal's page about IPN, and do a search on google for IPN integration with PHP.

Categories