I am using PayPal Express checkout for payment. I need the SALUTATION of the user along with other shipping details. But it seems that only FIRSTNAME and LASTNAME are got from the response. What should be done to get the SALUTATION in the response as well.
This is the response got from GetExpressCheckoutDetails
TOKEN:EC%2d9F317807RE7947807
BILLINGAGREEMENTACCEPTEDSTATUS:0
CHECKOUTSTATUS:PaymentActionCompleted
TIMESTAMP:2016%2d05%2d12T11%3a54%3a16Z
CORRELATIONID:c50a6ba8b3002
ACK:Success
VERSION:93
BUILD:000000
EMAIL:nihal%40gmail%2ecom
PAYERID:2CLDDRMSKLDMA
PAYERSTATUS:unverified
FIRSTNAME:Nihal
LASTNAME:Mohammad
COUNTRYCODE:IN
SHIPTONAME:Nihal
SHIPTOSTREET:Chakkorathukulam
SHIPTOSTREET2:Nadakkavu
SHIPTOCITY:Calicut
SHIPTOSTATE:KOZHIKODE
SHIPTOZIP:670006
SHIPTOCOUNTRYCODE:IN
SHIPTOCOUNTRYNAME:India
ADDRESSSTATUS:Unconfirmed
CURRENCYCODE:USD
AMT:10%2e00
SHIPPINGAMT:0%2e00
HANDLINGAMT:0%2e00
TAXAMT:0%2e00
INSURANCEAMT:0%2e00
SHIPDISCAMT:0%2e00
PAYMENTREQUEST_0_CURRENCYCODE:USD
PAYMENTREQUEST_0_AMT:10%2e00
PAYMENTREQUEST_0_SHIPPINGAMT:0%2e00
PAYMENTREQUEST_0_HANDLINGAMT:0%2e00
PAYMENTREQUEST_0_TAXAMT:0%2e00
PAYMENTREQUEST_0_INSURANCEAMT:0%2e00
PAYMENTREQUEST_0_SHIPDISCAMT:0%2e00
PAYMENTREQUEST_0_TRANSACTIONID:2KR64654T7820071F
PAYMENTREQUEST_0_INSURANCEOPTIONOFFERED:false
PAYMENTREQUEST_0_SHIPTONAME:Nihal
PAYMENTREQUEST_0_SHIPTOSTREET:Chakkorathukulam
PAYMENTREQUEST_0_SHIPTOSTREET2:Nadakkavu
PAYMENTREQUEST_0_SHIPTOCITY:Calicut
PAYMENTREQUEST_0_SHIPTOSTATE:KOZHIKODE
PAYMENTREQUEST_0_SHIPTOZIP:670006
PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE:IN
PAYMENTREQUEST_0_SHIPTOCOUNTRYNAME:India
PAYMENTREQUEST_0_ADDRESSSTATUS:Unconfirmed
PAYMENTREQUESTINFO_0_TRANSACTIONID:2KR64654T7820071F
PAYMENTREQUESTINFO_0_ERRORCODE:0
In PayPal documentation they say it is available in response.
see here
Its a simple problem. I was using the merchant account for US region. And the US region does not need the SALUTATION part for their address. That was why the response was not returning the salutation part i guess.
Related
I'm using PayPal Express Checkout on a sandbox account, and i'm trying to link up the Unique Transaction ID on the "customer" paypal site with the completed transaction via Express Checkout.
My DoExpressCheckoutPayment returned:
TOKEN=EC%2d2KG36160AM8868619&
SUCCESSPAGEREDIRECTREQUESTED=false&
TIMESTAMP=2015%2d01%2d29T09%3a45%3a09Z&
CORRELATIONID=44060412ed341&
ACK=Success&
VERSION=93&BUILD=15009693&
INSURANCEOPTIONSELECTED=false&
SHIPPINGOPTIONISDEFAULT=false&
PAYMENTINFO_0_TRANSACTIONID=011446947E558235S&
PAYMENTINFO_0_TRANSACTIONTYPE=expresscheckout&
PAYMENTINFO_0_PAYMENTTYPE=instant&
PAYMENTINFO_0_ORDERTIME=2015%2d01%2d29T09%3a45%3a08Z&
PAYMENTINFO_0_AMT=7%2e98&
PAYMENTINFO_0_FEEAMT=0%2e47&
PAYMENTINFO_0_TAXAMT=0%2e00&
PAYMENTINFO_0_CURRENCYCODE=GBP&
PAYMENTINFO_0_PAYMENTSTATUS=Completed&
PAYMENTINFO_0_PENDINGREASON=None&
PAYMENTINFO_0_REASONCODE=None&
PAYMENTINFO_0_PROTECTIONELIGIBILITY=Ineligible&
PAYMENTINFO_0_PROTECTIONELIGIBILITYTYPE=None&
PAYMENTINFO_0_SECUREMERCHANTACCOUNTID=W9SM36U76AXSS&
PAYMENTINFO_0_ERRORCODE=0&
PAYMENTINFO_0_ACK=Success
Then my GetExpressCheckoutDetails returned:
TOKEN=EC%2d2KG36160AM8868619&
BILLINGAGREEMENTACCEPTEDSTATUS=0&
CHECKOUTSTATUS=PaymentActionCompleted&
TIMESTAMP=2015%2d01%2d29T09%3a45%3a33Z&
CORRELATIONID=80e00a0067bea&
ACK=Success&
VERSION=93&
BUILD=15009693&
EMAIL=test1%40sud%2eco2euk&
PAYERID=H54VEN293PLFL&
PAYERSTATUS=verified&
FIRSTNAME=Test&
LASTNAME=User&
COUNTRYCODE=GB&
CURRENCYCODE=GBP&
AMT=7%2e98&
SHIPPINGAMT=0%2e00&
HANDLINGAMT=0%2e00&
TAXAMT=0%2e00&
INSURANCEAMT=0%2e00&
SHIPDISCAMT=0%2e00&
PAYMENTREQUEST_0_CURRENCYCODE=GBP&
PAYMENTREQUEST_0_AMT=7%2e98&
PAYMENTREQUEST_0_SHIPPINGAMT=0%2e00&
PAYMENTREQUEST_0_HANDLINGAMT=0%2e00&
PAYMENTREQUEST_0_TAXAMT=0%2e00&
PAYMENTREQUEST_0_INSURANCEAMT=0%2e00&
PAYMENTREQUEST_0_SHIPDISCAMT=0%2e00&
PAYMENTREQUEST_0_TRANSACTIONID=011446947E558235S&
PAYMENTREQUEST_0_INSURANCEOPTIONOFFERED=false&
PAYMENTREQUESTINFO_0_TRANSACTIONID=011446947E558235S&
PAYMENTREQUESTINFO_0_ERRORCODE=0
But the customer site says:
PayPal Express Checkout Payment Sent (Unique Transaction ID 7PK53077PJ222701T)
Oh..the (painful) memories :) That aforementioned "oddity" also exists elsewhere - e.g. eBay transactions
IINM, you'll need to send your own "custom ID" - the Invoice Id mentioned above (which is displayed to the end user) so both ends have some visual reference to a transaction.
In the REST API (unsure in Classic, haven't tried), if you send an Order, the Order Number (finally) is shared on both ends (same for both). Though it wouldn't hurt to still send your own "custom Id"/"Invoice Id".
Buyer/Customer Paypal UI:
Seller/Merchant Paypal UI:
Hth...
I am currently testing credit card payments using the PayPal payments pro Rest API.
I keep getting the following error:
Exception in HttpConnection Execute: Invalid HTTP response The remote server returned an error: (400) Bad Request. --->
I created and activated my PayPal test account and as following:
Credit card
Credit card number:
ccnumber here
Credit card type:
Visa
Expiration date:
3/2019
When I enter the above information in my payment form and submit I keep getting the 400 bad request error.
I have gotton this to work before with the PayPAl joe shopper account but lost the test cc number.
I am 100% sure I have authenticated with the oauth2 credentials
What is the likely cause of this error?:
I am entering a random payer first name and last name .
Does the name have to exsist?
What could be causing the error
If anything goes wrong in the data given, paypal api will return a 400 - Bad request error.
When I got the error(PHP SDK), I caught the exception and $ex->getData() returned a json which contains the details about the bad request, in my case the currency code I given was wrong.
try {
$payment->create($apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
var_dump(json_decode($ex->getData()));
exit(1);
}
Like others here have said, there are several things that can cause the (HTTP 400 - Bad Request).
In my case it was due to using the same invoice number. For temporary testing I just used the ShoppingCartID that I generated with a guid. You could also use a Random number generator as well. Ultimately you will need to generate an invoice number to the clients specifications.
-Good luck
I just had the same problem (HTTP 400 - Bad Request). The cause is a REST API request with "errors". In my case I had two causes:
I passed amount details to an Amount object but the sum of subtotal, shipping an tax was not equal to the amount total.
I passed amount currency values including a fracture, but passed not exactly two decimals but only one. Obviously the REST API is a bit touchy and accepts only either no or two decimals.
I passed an item_list in the Transaction object but the sum of the prices in the Item object was not equal to the subtotal given in the amount details.
I don't know a way of finding the actual cause of the error (if there is one).
In your case it could be the name of the payer that you add. Try without.
Edit:
I just tried out: It is indeed the payer info. I passed a payer_info with first and lastname and got HTTP 400 (without everything worked). I assume that payer_info must not be set by us but is set by PayPal when returning a Payment object.
Payer payer = new Payer { payment_method = "paypal", payer_info = new PayerInfo {
first_name = "Zaphod", last_name = "Beeblebrox"} }; // => HTTP 400 - Bad Request
firstly find out what exactly what Your error is
payment = PayPal::SDK::REST::DataTypes::Payment.new(...)
payment.create
# got Response[400]: Bad Request here
payment.error
# got {"name"=>"VALIDATION_ERROR", "details"=>[{"field"=>"transactions", "issue"=>"
then find out what Your issue here to get more info
https://developer.paypal.com/webapps/developer/docs/api/#validation-issues
I had the same issue. In my case it was Credit Card issue which might be over used. So I have taken new Credit card Number from this site Testing Credit card and replaced with the old one.
Here is Credit Card Information that I used
credit_card = new CreditCard()
{
billing_address = new Address()
{
city = "Johnstown",
country_code = "US",
line1 = "52 N Main ST",
postal_code = "43210",
state = "OH"
},
cvv2 = "874",
expire_month = 11,
expire_year = 2018,
first_name = "Joe",
last_name = "Shopper",
number = "4024007185826731", //New Credit card Number, Only Card type should match other details does not matter
type = "visa"
}
Note: All the Credit Card mentioned in PayPal site are not working, giving same issue for me. If it working for you then it's good otherwise use new testing Credit Card Number. Hope this will help someone.
Thank you! Enjoy Coding!
I too got struck with this issue, there might be many other possible root cause for this failure but then in my case all my passing argument is correct, but then it failed in sandbox environment, I just changed Payment option from PayPal Balance to Visa then it started working.
I recently had a 400 bad request error as well. In my case, I was processing a refund using RefundRequest, and it appears that PayPal recently changed the constraints on the "reason" field (although it isn't documented that I can find) so my lengthy descriptions of what was being returned were no longer acceptable. I found the error only because I saw another field where PayPal was now requiring that it be only single-byte alphanumeric characters. What actually helped though, was shortening the data I was putting through as a reason to simply "Returned items".
Obviously this is an old thread, and I'm sure the original problem was solved long ago, but if using some of the above methods to determine more information about an error don't yield results I would suggest submitting a request with the bare minimum of information until you can get it to go through. Then, start adding additional fields/information back to see if you can identify which field contains the information causing the bad request. That would have worked for my issue, at least.
Understand your errors
PayPal returns detailed data on every exception (except 500 INTERNAL_SERVER_ERROR), explaining what was the exact error you are seeing. You can retrieve that as follows:
Update your exception handling to catch PayPalConnectionException and print $ex->getData() as shown below:
try {
$payment->create($apiContext);
} catch (PayPal\Exception\PayPalConnectionException $ex) {
echo $ex->getCode(); // Prints the Error Code
echo $ex->getData(); // Prints the detailed error message
die($ex);
} catch (Exception $ex) {
die($ex);
}
It is due to the wrong currency or amount you have given.
I faced the issue in React JS
I was doing this. in the createOrder method.
purchase_units: [{
amount: {
currency_code: 'PHP',
value: totalAmount
}
}],
that was the issue. If i gave any currency other than USD i will get the 400 Error. So i removed the currency_code from here
And I moved the currency declaration into my component declaration.
like this.
options={{
clientId: " Your_ID " ,
currency: "PHP"
}}
Here you can give any currency you want. This solves my 400 Error
If you use Paypal Sandbox for testing Driver and on first try with buggy code it shows the client a 400 Bad request error.
Reason:- Paypal sent JWT auth and it was stored in the client's local storage.
Suggestion:- Try to clear the client's local storage cache (You only need to clear the Paypal Token).
This works for me, I hope it works for you :)
I'm building a book store and I am building the checkout using PayPal Payflow . This is the checkout flow:
Shipping info --> Billing info |verify CC using Paypal| --> Order summary --> Submit |authorize CC using Paypal|
Shipping info: fill out shipping address, nothing special here
Billing info: fill out your billing address + credit card info. Don't save the credit card info since it's against standards, instead just send the CC number, expiration date, and CVV directly to PayPal to verify. PayPal approves.
Order summary: The order sees the summary of his order before he submits the order. He presses submit and another request to PayPal is sent to authorize the funds.
However, the CC info vanishes after #2, so how would I persist that data to #3 so that I can send it to PayPal again?
Can I just use the ORIGID to point to the PNREF ? The documentation says I have to do a full request with the whole params list (including CC info, CVV, exp date, etc).
TRXTYPE=A&TENDER=C&PWD=x1y2z3&PARTNER=PayPal&VENDOR=SuperMerchant&USER=S
uperMerchant&ACCT=5555555555554444&EXPDATE=0308&AMT=123.00&COMMENT1=Seco
nd purchase&COMMENT2=Low risk customer&INVNUM=123456789&STREET=5199
MAPLE&ZIP=94588
Or am I just misunderstanding what authorization means? Isn't authorization actually reserving funds in the user's CC? So that shouldn't be done until the user presses submit order right?
I figured it out.
The documentation here: https://www.paypalobjects.com/webstatic/en_US/developer/docs/pdf/pp_payflowpro_guide.pdf
on page 40 mentions it briefly, but doesn't go into much detail about this checkout flow even though it seems pretty common.
My assumption was right, in that I could just do an address verification request first with all the CC info, and use the PNREF returned. I save the PNREF id in my session and reuse it to submit a request that looks like this:
def authorize_transaction(pnref)
make_request(authorization_data(pnref))
end
def authorization_data(pnref)
{
"TRXTYPE" => "A",
"TENDER" => "C",
"USER" => PAYPAL_API["user"],
"PWD" => PAYPAL_API["pwd"],
"VENDOR" => PAYPAL_API["user"],
"PARTNER" => "Paypal",
"AMT" => purchase.total_price,
"ORIGID" => pnref,
"VERBOSITY" => "HIGH"
}
end
And receive the desired response:
{"RESULT"=>"0", "PNREF"=>"A10A6A9C08E1", "RESPMSG"=>"Approved", "AUTHCODE"=>"752PNI", "AVSADDR"=>"Y", "AVSZIP"=>"Y", "HOSTCODE"=>"A", "PROCAVS"=>"Y", "VISACARDLEVEL"=>"12", "TRANSTIME"=>"2014-01-31 11:53:56", "FIRSTNAME"=>"net", "LASTNAME"=>"theory", "AMT"=>"15.64", "ACCT"=>"1111", "EXPDATE"=>"0115", "CARDTYPE"=>"0", "IAVS"=>"N"}
I do not know if the issue is in code or the paypal account settings. Paypal displays correctly the shipping cost, it displays the correct total (item price + shipping),
but in fact, the transactions includes only the item price, not the shipping costs.
I have been unable to find out what is wrong. if paypal can display it correctly, why cant it include it properly in the transaction ?
here is the request sent to paypal:
$padata = '&CURRENCYCODE='.urlencode($PayPalCurrencyCode).
'&PAYMENTACTION=Sale'.
'&ALLOWNOTE=1'.
'&PAYMENTREQUEST_0_CURRENCYCODE='.urlencode($PayPalCurrencyCode).
'&PAYMENTREQUEST_0_AMT='.urlencode($TotalPrice).
'&PAYMENTREQUEST_0_ITEMAMT='.urlencode($ItemTotalPrice).
'&L_PAYMENTREQUEST_0_QTY0='. urlencode($ItemQty).
'&L_PAYMENTREQUEST_0_AMT0='.urlencode($ItemPrice).
'&PAYMENTREQUEST_0_SHIPPINGAMT='.urlencode($deliveryCost).
'&L_PAYMENTREQUEST_0_NAME0='.urlencode($ItemName).
'&L_PAYMENTREQUEST_0_NUMBER0='.urlencode($ItemNumber).
'&AMT='.urlencode($ItemTotalPrice).
'&RETURNURL='.urlencode($PayPalReturnURL ).
'&CANCELURL='.urlencode($PayPalCancelURL);
The param for shipping that I used is :
PAYMENTREQUEST_0_SHIPPINGAMT
is it correct ? is a complementary one needed ?
Are you supplying all of your PAYMENTREQUEST_0_* and L_PAYMENTREQUEST_0_* variables in your DoExpressCheckoutPayment call as well as your SetExpressCheckout call?
SetExpressCheckout will control what the buyer sees when they go to check out on PayPal. DoExpressCheckoutPayment will control what the buyer is actually charged for. Therefore, if you want your shipping charge to be included in the transaction, you need to make sure that it's included in both calls.
for the records, correct params for DoExpressCheckoutPayment :
$padata = '&TOKEN='.urlencode($token).
'&PAYERID='.urlencode($playerid).
'&PAYMENTACTION='.urlencode("SALE").
'&PAYMENTREQUEST_0_CURRENCYCODE='.urlencode($PayPalCurrencyCode).
'&PAYMENTREQUEST_0_SHIPPINGAMT='.urlencode($deliveryCost).
'&PAYMENTREQUEST_0_AMT='.urlencode($TotalPrice).
'&PAYMENTREQUEST_0_ITEMAMT='.urlencode($ItemTotalPrice).
'&CURRENCYCODE='.urlencode($PayPalCurrencyCode);
I am using adaptive api to make a chained payment. The code looks
ChainedPay chainedPay = new ChainedPay(numberOfReceivers);
//set values (such as return url, cancel url, ipn url etc for the chainedPay object
....
Receiver primaryReceiver = new Receiver();
// set the receiver's value such as amount etc.
...
chainedPay.setPrimaryReceiver(primaryReceiver);
Receiver rec1 = new Receiver();
//set the second receiver's value
...
chainedPay.addToSecondaryReceivers(rec1);
//Make the request
chainedPay.makeRequest(); like this:
I do get the IPN message back when the payment is approved. But I want to be able to send a value such as a transactionId that exists in my system in the pay request, and have the IPN post it back to me, so I can look up the transaction by its id in my ipn listener, and use that information to deliver digital good to the user. I can't figure out where to set that value in the pay request.
Before using adaptive payment api call, if I want to pass the transaction id to the IPN, I would set it in the item_number field in a field in the form of the buy button and that would get passed through. Is there something similar in the adaptive api?
Thanks,
Tim
Try using the trackingid parameter. I am using the XML version and I pass it as follows
sRequest.Append("</trackingId>");
sRequest.Append(trackingID);
sRequest.Append("</trackingId>"); You may get a property as tracking id in PayRequest class.
I am passing the orderId via the trackingId field in the PayRequest
Ex:
PayRequest payRequest = new PayRequest(requestEnvelope, actionType, cancelUrl, currencyCode, receiverList, returnUrl);
payRequest.ipnNotificationUrl = System.Configuration.ConfigurationManager.AppSettings["PaypalNotifyUrl"];
payRequest.trackingId = orderId.ToString();
Then in the IPN handler, I retrieve it from the Request object.