Paypal IPN, But From Who (if the registration and paypal mail different) - php

I am having trouble with Paypal IPN About one thing,
As I understood, paypal redirects the user to a page of us after the successful order, then calls our IPN page, after the transection with post variables including result.
Paypal sends the mail of the order owner in the post variables, but what if the mail in the site and paypal are different.
If PayPal is calling the ipn page, sessions won't work. If i don't check the mail, I won't be able to catch simultaneously IPN orders ( I think ).
I saw something about txn_id and receipt_id, but if I'am not sending the variables, how can they help me to catch the user.
I am Mixed a bit.
Thanks for any reply.
Regards.

There is a custom parameter, it can be user to send additional parameters

You link the IPN request and the transaction by the txn_id (transaction_id). This is an id you generate, the only requirement is that it's unique.
So:
User starts a payment transaction on your site. You generate a transaction_id which is linked to the user with address info and some 'shopping cart', price info, items etc. This is all the info you need, to know who ordered what and where to send it - all identified by the transaction_id
You pass your merchant info and transaction_id on to PayPal.
User completes payment.
IPN calls your server with user info, payment status and a transaction_id. The email address you get from PayPal may be a different email address than you have registered for the user, maybe the user has a separate email for PayPal? .. It doesn't matter. Use the email address the user gave you, not the one you got from PayPal. And don't use the email address for identification, use the transaction id it's the only value you can rely on.
I'm not sure about the receipt_id. If you want to email a receipt, mail it after you've got a successful payment from IPN. You should have all the info to generate the receipt.

Related

Retrieving PayPal email address after payment?

When you are setting up a PayPal Buy Now Button, you can take customers to the URL when they finish checkout.
Is there a way to retrieve their PayPal email immediately after PayPal checkout using $_GET?
Does PayPal append some kind of ?email=email#address.com at the end of your thankyou page?
Or is there any variable I could add at the end of my thankyou page when typing a success URL inside the PayPal?
Basically I want to store their PayPal email address that they used on deposit, so that when they would cash out, the same PayPal email address will be used.
Just wanted to let you know why I'm interested in storing their real PayPal email address in the first place.
Any help from someone who have knowledge in this would be appreciated.
With a legacy HTML Buy Now button that redirects away from your page, there is never any guarantee the payer will return to your site after a successful transaction. With such an old integration, the only reliable way to get the email address of the payer and record this information in your database is to implement the old IPN service.
Instead, you should do a server-side integration of the current Standard Checkout.
Follow the Set up standard payments guide and make 2 routes on your server, one for 'Create Order' and one for 'Capture Order', documented here. Both routes should return only JSON data (no HTML or text). Inside the 2nd route, when the capture API is successful you should store its resulting payment details in your database (particularly purchase_units[0].payments.captures[0].id, which is the PayPal transaction ID -- as well as the payer object's email address, in your case) and perform any necessary business logic (such as sending confirmation emails or reserving product) immediately before forwarding your return JSON to the frontend caller.
Pair those 2 routes with the frontend approval flow: https://developer.paypal.com/demo/checkout/#/pattern/server

PHP script to know whether receiver's email id is registered paypal id or not?

I am integrating PayPal payment gateway on my site. My issue is:
I want a php script with the help of which, before transaction, I can verify whether the email id, user is providing, is registered PayPal id or not. If email id is not PayPal registered id I can generate a error message pop up window to show that you can not make this payment because email id is not registered PayPal id.
Please help me.
Thanks & Regards
Atul Rai
Use the Instant Payment Notification (IPN) service they provide, you can verify afterwards, not before.
IPN Introduction
Ideally you could use IPN for getting such information. However, the idea of verifying if the email id is valid paypalId during payment is a bit confusing, as even though you dont have an account, you can create one during the checkout process.

Paypal Invoice Response

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.

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.

PayPal subscriptions PDT / IPN - PLEASE

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.

Categories