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.
Related
I'm using PayPal Adaptive Payments (a deprecated integration method) with PHP.
When calling the "Pay" request, I always used to set the return URL to:
https://my-website/my-return-page.php?payKey=${payKey}
Then, when the payment is succesful, PayPal should redirect the user to something like:
https://my-website/my-return-page.php?payKey=AP-ABCDEF123456
But now, the PayPal API is throwing an error:
The URL https://my-website/my-return-page.php?payKey=${payKey} is malformed
There was no change in our end, it just stopped working.
I need the payKey in the return URL, so I can check the paymentDetails.
adding &payKey=${payKey}
Oh, based on the answer you linked you were sending that actual text as-is and PayPal was dynamically replacing that with the value.
It doesn't seem that syntax is supported anymore; it's not documented.
What I would recommend is generate your own unique ID, and pass that as ?id=abcde12345. Then when you first get the payKey from the initial Pay API response, associate this payKey with your own id (e.g. abcde12345). It could be the same as the TrackingID or Invoice ID, if you happen to use either parameter/feature of Adaptive Payments.
Then, the return should have ?id=abcde12345 and you can look up the payKey and proceed from there with paymentDetails.
You can also report this change in behavior with Adaptive Payments as a PayPal bug, but since it's a very old and deprecated product that's likely to be sunset at some point, I'm not sure how much traction re-implementing an undocumented feature would have, so the above workaround of your own id seems like a better plan.
I have the following flow with Paypal:
I create a payment with intent "order", and I redirect the user to Paypal's website.
Once the user returns, I execute the payment.
Then, I authorize the order.
At this point, I can still look up the payment or the order and I get expected result.
Finally, I capture the order.
After I capture the order, I can't lookup the payment with /v1/payments/payment/PAY-XYZ or retrieve the order with /v1/payments/orders/O-ABC. I get a 500 Internal Service Error.
Before you tell me to send debug id to Paypal because I stumbled upon their bug: I tried, but they are not responding. I had them on the phone, sent support requests, etc. I got no reply from them, so I have to turn to community.
After capture, I can still lookup a payment by listing payment resources. Since I store paypal's create time, I send a GET request that looks like:
/v1/payments/payment?start_time=2016-06-21T09:08:56Z&end_time=2016-06-21T09:08:58Z
Sure enough, I can get the payment object back, but that looks awfully hacky to me.
The reason why I need the entire payment object is because I need a definitive information about the status of the payment. E.g. I can stumble upon a network error when I send a capture request and I won't get capture ID, so I can't check what's going on. Or I can miss a webhook event (for any reason, e.g. bug in my code), and the payment can become refunded without me knowing, so it would be ver nice to be able to fetch a payment.
I noticed the REST API documentation here https://developer.paypal.com/docs/api/payments/#payment_get says that I should use that endpoint for incomplete payments, but I don't understand why I can't check the order, or why list payment resources works, but fetching a single payment doesn't.
Retrieving the payment used to work though, so I could look up related_resources of transactions of the response (like I can do now with listing all payments by date).
My question is: what is the recommended way to get the definitive information about a payment?
Also, if someone from Paypal is reading this, here are some debug_id's so you can perhaps look into it: 3ffa3007a7561 (result of https://api.sandbox.paypal.com/v1/payments/orders/O-3PA36862ST053572T) or 85576d66784cd (response from https://api.sandbox.paypal.com/v1/payments/payment/PAY-7N237030X85089344K5UQIKI)
This happens on both sandbox and live.
Thanks,
Dejan
I recently converted from basic Paypal payments to Chained Payments...and I have a few questions if you guys would be so kind to help out.
First, when I setup a PayRequest, I also create an order record in the database. Previously with my basic Paypal implementation, I passed that OrderId in the custom field as part of the form post to Paypal. I would then get that OrderId back in the IPN handler and use it to mark the order as paid or whatever based on the response from Paypal IPN.
Now I am wondering what is a good unique value for my locally created order? Should I use the paykey to look up the order on the IPN callback? Or should I just set the trackingId property of the PayRequest to be the order id and pick up in the IPN callback Request object?
Secondly, there is a returnUrl and ipnNotificationUrl for the PayRequest. Should the returnUrl process the IPN callback or does the ipnNotificationUrl only should do that?
The reason why I ask is because the return url must be able to show the buyer the status of their payment and the transaction info, the same data that I get in the IPN callback.
Thanks for the input guys, once I get these two minor details ironed out, I'll be good to go!
I would add your record ID into the tracking ID parameter of the Pay request like you mentioned. That way you'll get it back in your IPN similar to what you're doing with the custom parameter now.
The IPN notification URL is what you want to set in order to trigger IPNs for the Pay request. You do not want to use the same URL for return because then the script would actually run twice.
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.
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.