Why is the custom parameter in my PayPal IPN response empty? - paypal

In my PayPal IPN response the custom parameter is empty.
I've tried the following post data:
METHOD=SetExpressCheckout&VERSION=121.0&USER=mark.vanhaaren1987-facilitator_api1.gmail.com&PWD=1411391015&SIGNATURE=AiPC9BjkCyDFQXbSkoZcgqH3hpacAa1vFAMOEAO1ZachEpl5mX2RGSRb&RETURNURL=https%3a%2f%2fdev-api.wedepa.com%2freturn%2freturn%3fwedepaid%3d32-303-true-e3c7a8f25359d0ad625c4389102aa0cabdfb172e&CANCELURL=https%3a%2f%2fdev-api.wedepa.com%2freturn%2freturn%3fwedepaid%3d32-303-true-e3c7a8f25359d0ad625c4389102aa0cabdfb172e&REQCONFIRMSHIPPING=0&LOCALECODE=&EMAIL=pending_accepted%2540klarna.com&LANDINGPAGE=Login&PAYMENTREQUEST_0_SHIPTONAME=Testperson-nl+Approved&PAYMENTREQUEST_0_SHIPTOSTREET=Neherkade+1XI&PAYMENTREQUEST_0_SHIPTOSTREET2=&PAYMENTREQUEST_0_SHIPTOCITY=Gravenhage&PAYMENTREQUEST_0_SHIPTOSTATE=&PAYMENTREQUEST_0_SHIPTOZIP=2521VA&PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE=NL&PAYMENTREQUEST_0_SHIPTOPHONENUM=0612345678&PAYMENTREQUEST_0_AMT=0.56&PAYMENTREQUEST_0_CURRENCYCODE=EUR&PAYMENTREQUEST_0_ITEMAMT=0.56&PAYMENTREQUEST_0_DESC=145000610&PAYMENTREQUEST_0_CUSTOM=303&PAYMENTREQUEST_0_INVNUM=145000610&PAYMENTREQUEST_0_PAYMENTACTION=Sale&PAYMENTREQUEST_0_PAYMENTREQUESTID=303
and
METHOD=SetExpressCheckout&VERSION=121.0&USER=mark.vanhaaren1987-facilitator_api1.gmail.com&PWD=1411391015&SIGNATURE=AiPC9BjkCyDFQXbSkoZcgqH3hpacAa1vFAMOEAO1ZachEpl5mX2RGSRb&RETURNURL=https%3a%2f%2fdev-api.wedepa.com%2freturn%2freturn%3fwedepaid%3d32-303-true-e3c7a8f25359d0ad625c4389102aa0cabdfb172e&CANCELURL=https%3a%2f%2fdev-api.wedepa.com%2freturn%2freturn%3fwedepaid%3d32-303-true-e3c7a8f25359d0ad625c4389102aa0cabdfb172e&REQCONFIRMSHIPPING=0&LOCALECODE=&EMAIL=pending_accepted%2540klarna.com&LANDINGPAGE=Login&PAYMENTREQUEST_0_SHIPTONAME=Testperson-nl+Approved&PAYMENTREQUEST_0_SHIPTOSTREET=Neherkade+1XI&PAYMENTREQUEST_0_SHIPTOSTREET2=&PAYMENTREQUEST_0_SHIPTOCITY=Gravenhage&PAYMENTREQUEST_0_SHIPTOSTATE=&PAYMENTREQUEST_0_SHIPTOZIP=2521VA&PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE=NL&PAYMENTREQUEST_0_SHIPTOPHONENUM=0612345678&PAYMENTREQUEST_0_AMT=0.56&PAYMENTREQUEST_0_CURRENCYCODE=EUR&PAYMENTREQUEST_0_ITEMAMT=0.56&PAYMENTREQUEST_0_DESC=145000610&CUSTOM=303&PAYMENTREQUEST_0_INVNUM=145000610&PAYMENTREQUEST_0_PAYMENTACTION=Sale&PAYMENTREQUEST_0_PAYMENTREQUESTID=303
But in both posts the custom parameter is empty in the IPN data:
mc_gross=0.56&protection_eligibility=Eligible&address_status=unconfirmed&payer_id=WVANQ6YXN3Z44&tax=0.00&address_street=Neherkade+1XI&payment_date=02%3A25%3A07+Apr+05%2C+2015+PDT&payment_status=Completed&charset=windows-1252&address_zip=2521VA&first_name=SandboxTest&mc_fee=0.37&address_country_code=NL&address_name=Testperson-nl+Approved&notify_version=3.8&custom=&payer_status=verified&address_country=Netherlands&address_city=Gravenhage&quantity=1&verify_sign=AWOaXag9big7U1TLyuUBdjQukr3NAId64fyHo.KuCCvftrNBM1o3xHVd&payer_email=mark%40mvhaaren.com&txn_id=7XS68223YK9539538&payment_type=instant&last_name=Account&address_state=&receiver_email=mark.vanhaaren1987-facilitator%40gmail.com&payment_fee=&receiver_id=A3TRBFWRTUBBL&txn_type=express_checkout&item_name=&mc_currency=EUR&item_number=&residence_country=NL&test_ipn=1&handling_amount=0.00&transaction_subject=&payment_gross=&shipping=0.00&ipn_track_id=7f79e2488253
Can somebody see what I am doing wrong?

The PAYMENTREQUEST_0_CUSTOM parameter needs to be in your DoExpressCheckoutPayment call, more than it needs to be in your SetExpressCheckout call.

Related

How do i handle url callbacks on my serverless flutter app?

I am testing a crypto payment system on my flutter app, and after generating a random address for payment, the api is supposed to notify me when the transaction has been confirmed using a callback url. I use firestore for my backend, how do i handle this callback url. I will post a copy of the documentation below.
"Insert your URL address where you want to get callbacks in create_payment request. The parameter name is ipn_callback_url. You will receive payment updates (statuses) to this URL address."
for anyone having a similar challenge, i actually solved this problem by writing a http cloud function to help me handle this, then supplied the url to the function as the callback url to the api. SO yes.... http cloud functions was a solution to this problem
Here's a very simple function that can be used:
exports.paymentConfirmation = functions.https.onRequest(async(req, res)=>{
const requestBody = req.body;
const paymentStatus = requestBody.payment_status;
console.log('this is the payment status: ' + paymentStatus);
Promise.resolve();
}
res.send(null);
})
basically you can do anything you want with the request body you get back. In this case i just logged one of the parameters. After deploying this function to firebase, you have access to its url. Problem solved. So when there's an update from the api u subscribed to, it can send a POST request to that url and that triggers whatever code you've written in the function.

PayPal REST API - already refunded transaction error

In order to gracefully handle a refund request on a transaction that has already been refunded, I should have the possibility to check the exact error code returned by PayPal REST API in case of a POST https://api.sandbox.paypal.com/v1/payments/capture/{captureid}/refund request.
similarly to the classic API I thought (but I was wrong) that in this case an error 10009 could be returned (https://developer.paypal.com/docs/classic/api/errorcodes/).
Actually when I try to request a refund for a payment that has already been captured i got a 400 HTTP status and the JSON body below:
{
"name": "TRANSACTION_REFUSED",
"message": "The request was refused.This transaction has already been fully refunded",
"information_link": "https://developer.paypal.com/webapps/developer/docs/api/#TRANSACTION_REFUSED",
"debug_id": "e3f52374ef2e7"
}
I was wondering if there's a way to to look for this specific error other than inspecting the "message" value included in the JSON response.
Thanks,
Andrea
I believe you already got an answer from the PayPal-Java-SDK GitHub repository issue #148.
In case someone else has the same question, today, the HTTP response code is a general error code, and the message in the body is the best way to identify the cause. Please make a feature request to PayPal Technical Support so this enhancement can be considered for a future release.

How to implement PayPal IPN listener (controller) in Play Framework Scala

I am currently using PayPal buttons in my application written in Scala (Play Framework).
Now I am trying to implement PayPal IPN instead of redirect.
According to PayPal document
https://developer.paypal.com/docs/classic/ipn/gs_IPN/
After the user finished the payment, the flow of events is:
PayPal posts a message to my application's listener with all sorts of variables.
My listener returns an empty HTTP 200 response.
My listener performs an HTTP POST to send the complete, unaltered notification back to PayPal.
PayPal sends a single word back - either VERIFIED or INVALID.
So, my controller's method should look like:
def payPalIpn() = Action { implicit request =>
.... Get all PayPal Variables .......
/* Send empty response with empty HTTP 200 response */
Ok("")
.... Make a POST request to PayPal site with all original PayPal's variables
}
Here is what I stumbled upon - How can I make a POST request after I return OK("")?
Is that even possible in Play?
Appreciate if someone can give me any idea.
Andrei.
This would be an excellent use case for an Akka Actor:
def payPalIpn() = Action { implicit request =>
.... Get all PayPal Variables .......
actorSystem.actorSelection("paypal-ipn-actor") ! ValidateIPN(request.body)
/* Send empty response with empty HTTP 200 response */
Ok("")
}
If I understand it correct, you want to make a POST request to PayPal in your action. For that you can use WS Client library from Play. Detailed tutorial is given at
https://www.playframework.com/documentation/2.4.x/ScalaWS

Express Checkout Paypal failure

I have tried to used postman for Express Checkout, but getting following error:
ACK=Failure&L_ERRORCODE0=81002&L_SHORTMESSAGE0=Unspecified%20Method&L_LONGMESSAGE0=Method%20Specified%20is%20not%20Supported&L_SEVERITYCODE0=Error
I read also few other answers but havent found out any solution.
You are inputting all the parameter and value under Headers.
You should put all the parameters/values under Params, located at the right side the URL endpoint field.
See below:

Paypal integration - GetExpressCheckout

I'm working on PayPal integration (Express Checkout) using SOAP API. After DoExpressCheckout call I call GetExpressCheckoutDetails. In docs I found that the checkout status can be one of the following
PaymentActionNotInitiated
PaymentActionFailed
PaymentActionInProgress
PaymentCompleted
But docs do not actually say what does each of them mean. I understand all but PaymentActionInProgress - how do I handle it? Does it mean that I'll receive IPN call from PayPal when it's completed? Also, can I simulate this response for testing?
Hello Alex Buynyachenko,
A value of PaymentActionNotInitiated occurs when you submit a GetExpressCheckoutDetails API call before the buyer logs into a PayPal account or when they log into their account, return to your website but have not completed the payment yet.
PaymentActionFailed occurs when you've tried to complete the payment but it failed for some reason. The error response information returned would have details on the failure.
PaymentActionInProgress this is returned when you submit the DoExpressCheckoutPayment API call but haven't received a response yet - you shouldn't encounter that one often.
PaymentCompleted is returned after you get a successful DoExpressCheckoutPayment response. I just tested submitting an Authorization to see if I would get "InProgress" or "Completed" and I received a "Completed" value back.
1. Step-1: when I run this below code then it returned [CHECKOUTSTATUS] => PaymentActionNotInitiated
$padata = '&TOKEN='.urlencode(_GET('token'));
$httpParsedResponseAr = $this->PPHttpPost('GetExpressCheckoutDetails', $padata, PPL_API_USER, PPL_API_PASSWORD, PPL_API_SIGNATURE, PPL_MODE);
2. Step-2: Second time when I run this below code then it returned me [CHECKOUTSTATUS] => PaymentActionCompleted
$httpResDoExpChkPay = $this->PPHttpPost('DoExpressCheckoutPayment', $padata);
I think it will help you to better understand.