PayPal REST API not returning payment_info - paypal

I am using the REST API to authorize a PayPal transaction, and when it returns to confirm & execute the payment, I'd like to retrieve & display payer information such as name, address, phone, etc from their PayPal account for a checkout order confirmation page. (To avoid them having to type in all their billing/shipping address info, since this should be available from PayPal.)
Currently the return is only showing this for payer:
PayPal\Api\Payment Object
(
[_propMap:PayPal\Common\PPModel:private] => Array
(
[id] => PAY-2EC51985XH550123JKHG3C4Y
[create_time] => 2013-06-28T15:53:23Z
[update_time] => 2013-06-28T15:53:23Z
[state] => created
[intent] => sale
[payer] => PayPal\Api\Payer Object
(
[_propMap:PayPal\Common\PPModel:private] => Array
(
[payment_method] => paypal
)
)
[transactions] => Array
...
The documentation states:
payer_info object
This object is pre-filled by PayPal when the payment_method is paypal.
(see https://developer.paypal.com/webapps/developer/docs/api/#payerinfo-object)
Even after the payment is executed, I still receive no payer_info object from PayPal. I am wondering if PayPal is only returning the info I prepopulate before sending the user off to PayPal? e.g.:
$payer = new Payer();
$payer->setPayment_method('paypal');
Is there a way to retrieve the user's name/address/phone/etc (what I expected to be available from Payment::get($pay_id)->getPayer()->getPayerInfo()->getShipping_address()) using the REST API?
Or do I have to have the user duplicate their efforts and enter address information on my checkout page? I sure hope not, as this is one of the big advantages of using PayPal as a payment method.

I thought I would post an answer in case anyone else has this issue.
It does appear that the REST API fails to return the shipping information the majority of the time. Especially when using the GET /payments/payment endpoint. However I have seen it return shipping information from the POST /payments/payment/<PAYMENT_ID>/execute endpoint before.
Anyway, following the comments above it looks as if the OP ditched the REST API and went back to Express Checkout. Which is fair enough if you want to get the shipping data up front.
However, if you use the PayPal IPN in conjunction with the REST API it will provide the shipping and billing info on the callback. So you could collect the information at that point.
The only problem I see with doing this is that you can't confirm the address is correct with the user. PayPal however does show this information to the user as they make their way through payment and allows them to change it if necessary. So I believe it's safe to assume the data is accurate.

Related

Relation between payment made with createbutton api and ipn message

Our customers sends their requests for our products via email. Their requests are saved in our database and after we check their requests, we want to send them an email which contains the paypal payment link. To execute this, I am using BMCreateButton method of ButtonManager API of Paypal.
https://developer.paypal.com/docs/classic/api/button-manager/BMCreateButton_API_Operation_NVP/
This method returns EMAILLINK parameter and I am using this parameter in the email to redirect to user to paypal payment page. This method also returns HOSTEDBUTTONID and I am saving this parameter and EMAILLINK parameter to the database to make a relation between the email link(hostedbuttonid) and the user request.
For the payment notifications, I think my only choice is IPN of Paypal. I developed a page to handle the IPN messages from paypal and it works fine but the problem arises when I want to relate between the payment information with the email link that was sent to the customer. I mean I want to know for which request this payment was made. IPN message does not return any information about the HOSTEDBUTTONID. It returns btn_id(different than the HOSTEDBUTTONID), txn_id and ipn_track_id but none of them is useful to relate the customer request( or email sent) with the payment.
Do you have any suggestion about my issue? Or do you think I should use another way for sending the payment email to the user instead of BMCreateButton method of ButtonManager API.
In the BMCreateButton call, where you're setting up the standard PayPal variables for the button, add the CUSTOM parameter. Within that you can pass any value you want (up to 256 char.) and then that same value will come back in the IPN so you can relate it accordingly.
If you have a specific Order ID you could use the INVOICE field instead, and that would come back in IPN as well.

Get PayPal transaction fee without using IPN?

First of all I know there seems to be a few related questions about this which I have read but I can't find a definitive answer to my query. I hope its OK posting this here.
Related: receive more response data in ci-merchant library codeigniter
Related: How do I get the information returned in the IPN after a transaction in PayPal using ci_merchant library?
I basically want to get what the paypal IPN returns with CI Merchant.
Now I am calling purchase_return() which is great and returns something like this:
Merchant_paypal_api_response Object
(
[_status:protected] => complete
[_message:protected] =>
[_reference:protected] => XXXXX
[_data:protected] =>
[_redirect_url:protected] =>
[_redirect_method:protected] => GET
[_redirect_message:protected] =>
[_redirect_data:protected] =>
)
And I know that CI Merchant doesn't actually have a GetExpressCheckoutDetails call which would contain more details about the transaction.
But according to here: https://developer.paypal.com/webapps/developer/docs/classic/express-checkout/integration-guide/ECGettingStarted/ that call wouldn't return anything to do with mc_fee or payment_fee anyway?
So I am simply asking is this at all possible to get the same sort of data that the paypal IPN returns without actually using it obviously.
Seems a bit backward to have to call the paypal IPN as well just to get additional details like mc_fee or payment_fee when I am already using the CI Merchant API method which is supposed to eliminate having to use the IPN? I can't believe the API doesn't return this sort of info.
Am I being completely mental here and missed the obvious? I just want to get the paypal fee for that transaction so I can do some accounting my end.
Is this possible?
Hope someone can shed some light.
Thanks,
You are right, CI-merchant doesn't support the GetExpressCheckoutDetails method, and that method doesn't actually return the fee.
You might have more luck looking into calling the PayPal GetTransactionDetails method, which seems to return the fee. You would need to alter CI-merchant to add this functionality, or just call it separately though.

Paypal Express Checkout fields dont return values

I have the paypal express checkout api running in the sandbox and i'm able to successfully do a transaction and capture the payment. Now I want to store some values in the database. I can get the transactionID, ordertime, payment status from the resArray no problem. But when I try to add additional variables that are listed on the "DoExpressCheckoutPaymentAPI Operation page of the https://cms.paypal.com website, they don't return any value
I correctly send via doExpresscheckout values for the following
PAYMENTREQUEST_0_SOFTDESCRIPTOR = 'My Company Name'
PAYMENTREQUEST_0_ALLOWEDPAYMENTMETHOD = 'Instant Payment Only'
I need to get the value of those as well as
PAYMENTINFO_0_SETTLEAMT
But when i read the resArray returned by DoExpressCheckout, these fields are non-existent.
Is there some way to get these values?
- is settleamt only returned if there is a currency conversion and if not it's not in the returned array?
Also, is there another way to only accept Instant Payments? I can live without the other stuff but I need to set Instant Payments only.
The response is not going to contain everything you pass into the request. Anything you're passing into the request you already have, so if you need to store that data you'll just need to do that using the same values you're passing into the request, be it session data or whatever.
You can refer to page 105 of the PayPal NVP Documentation for details on exactly what you should expect back in the DoExpressCheckout response.

Paypal custom variable solution using php

I'm trying to using paypal as payment for my site.
My site only sell a virtual currency, like "Diamond" in Online game.
So after reading i starting to use Express Checkout for Digital Goods, Is that right ? or i must other payment method ?
Then my question is when using Express Checkout for Digital Goods, how to pass custom variable ?
Let say i want to pay user_id, diamond_id, and some other variable from my database to the paypal api. It seem like paypal don't support custom variable to pass on the api call. I want after user complete the payment, then Paypal notify my server that the payment is complete by user_id and some other variable that i pass, so easy for me to know the detail.
after searching i find some solution,
First solution is to store "TOKEN"(Generated from "SetExpressCheckout" Method) and my custom variable which is belong to the TOKEN in the database, Then after payment complete paypal will notify my server the same TOKEN saved before. So i will query based on the TOKEN.
Second Solution is using get style in RETURNURL variable http://www.mysite.com/successpayment.php?user_id=13&diamond_id=88 So i will easy to grab the GET variable.
Which solution is right ? Is there any solution ? and how to secure the payment confirmation, i mean if someone know and hack my returnurl.
Thanks in advance
There are two parts to be able to successfully identify your order in the whole process:
To identify your order when the user is redirected back via the success or cancel URL, just pass the order id via the query string of the URL.
To identify your order when Paypal sends notifications about the transaction and associated events (refunds, reversals, disputes etc.) via IPN: Paypal does support a pass-through variable, which allows you to associate IPNs to the order record in your DB.
For express checkout you set PAYMENTREQUEST_0_INVNUM in the SetExpressCheckout call
In case you are creating a recurring profile, the parameter is named PROFILEREFERENCE in the CreateRecurringPaymentsProfile call
When you receive an IPN the invoice is passed as 'invoice' or 'rp_invoice_id' respectively
(My general advice, though: use Paypal only if you really have to)

Retrieving Billing Type in PayPal Express Checkout for recurring payments

I'm setting up a payment engine for a custom framework using PayPal Express Checkout. One of the business requirements is adding support for recurring payments. I've found documentation on how to implement this at https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ECRecurringPayments
The thing I don't quite understand is how to retrieve the value of BillingType from the API after I've set it via SetExpressCheckout to "RecurringPayments". It doesn't seem to appear anywhere in the response data I get back from neither GetExpressCheckoutDetails nor DoExpressCheckoutPayment. I need this to know whether I need to create a recurring payments profile or not. So as far as I can tell my only option is to store the value of BillingType in my database and query it again after DoExpressCheckoutPayment. This works for me but I find it odd that this data would not be returned at all by the API. Am I missing something? Or is there another way of correctly implementing recurring payments?
Not all data you send in a request is returned in a response. You already have what you're passing to them...there's really no need for them to pass it back.
You could use session variables to save the data instead of the database, or you could log all of your API requests and refer to those logs when you need to see what you sent, but again, your application is what's telling PayPal whether or not the payment should include billing agreement information...not the other way around.