Paypal's transaction object with failing transactions - paypal

We are using Paypal Pro to do direct credit card processing. What happens when I put 2 transactions in a request, and the credit card approves one transaction object, but declines the other because of lack of funds. Does PayPal throw away the entire transaction and returns an error?
Take the following code straight from paypals rest api for node.js
var payment_details = {
"intent": "sale",
"payer": {
"payment_method": "credit_card",
"funding_instruments": [{
"credit_card": {
"type": "visa",
"number": "4417119669820331",
"expire_month": "11",
"expire_year": "2018",
"cvv2": "874",
"first_name": "Joe",
"last_name": "Shopper",
"billing_address": {
"line1": "52 N Main ST",
"city": "Johnstown",
"state": "OH",
"postal_code": "43210",
"country_code": "US" }}}]},
"transactions": [{
"amount": {
"total": "7.47",
"currency": "USD",
"details": {
"subtotal": "7.41",
"tax": "0.03",
"shipping": "0.03"}},
"description": "This is the payment transaction description." }]};
paypal_sdk.payment.create(payment_details, function(error, payment){
if(error){
console.error(error);
} else {
console.log(payment);
}
});
What happens when we put 2 transaction objects in there, will we have to handle the case of the credit card declining on the second transaction?

This is what we ended up using. We used the items feild to tell paypal about the multiple items in the transaction. Items is an array of items:
items.push({
quantity: "1",
name: classList[i].name,
price: price.toFixed(2),
currency: "USD"
});
var create_payment_json = {
"intent": "sale",
"payer": {
"payment_method": "paypal"
},
"redirect_urls": {
"return_url": "http://"+config.host+"/payment/success/"+paymentId,
"cancel_url": "http://"+config.host+"/payment/cancel/"+paymentId
},
"transactions": [{
"item_list": {
"items": items
},
"amount": {
"currency": "USD",
"total": (total.toFixed(2))
},
"description": description
}]
};

Related

Is Google Pay PayPal depreceated?

So my problem is, PayPal suggested a request type that is depreceated, and I don't know what API to use so my integration with Google Pay works with Paypal. This is the api PayPal suggested: Google Pay Integration . The API returns this:
`{
"name": "INTERNAL_SERVICE_ERROR",
"message": "An internal service error has occurred",
"information_link": "https://developer.paypal.com/docs/api/payments/#errors",
"debug_id": "41a6f4507a2df"
}`
body is this:
` {
"intent": "sale",
"payer": {
"payment_method": "paypal",
"funding_instruments": [
{
"credit_card_token": {
"credit_card_id": "CARD-1MD19612EW4364010KGFNJQI",
"external_customer_id": "joe_shopper408-334-8890"
}
}
],
"payer_info": {
"email": "sb-coy8y5423854#personal.example.com",
"payer_id": "AR6cGL6IXfI_BwzZGeBcpES7ilv1FZqJlYeMr3TZnp-07woQCczOi1oTjiiz4HQLqQgrMVPE6Ng2QafR"
}
},
"transactions": [
{
"amount": {
"total": "30.11",
"currency": "USD",
"details": {
"subtotal": "30.00",
"tax": "0.07",
"shipping": "0.03",
"handling_fee": "1.00",
"shipping_discount": "-1.00",
"insurance": "0.01"
}
},
"description": "The payment transaction description.",
"invoice_number": "48787589673",
"payment_options": {
"allowed_payment_method": "INSTANT_FUNDING_SOURCE"
},
"soft_descriptor": "ECHI5786786",
"item_list": {
"items": [
{
"name": "hat",
"description": "Brown hat.",
"quantity": "5",
"price": "3",
"tax": "0.01",
"sku": "1",
"currency": "USD"
},
{
"name": "handbag",
"description": "Black handbag.",
"quantity": "1",
"price": "15",
"tax": "0.02",
"sku": "product34",
"currency": "USD"
}
],
"shipping_address": {
"recipient_name": "Brian Robinson",
"line1": "4th Floor",
"line2": "Unit #34",
"city": "San Jose",
"country_code": "US",
"postal_code": "95131",
"phone": "011862212345678",
"state": "CA"
}
}
}
],
"note_to_payer": "Contact us for any questions on your order.",
"redirect_urls": {
"return_url": "https://yourwebsite.com/return",
"cancel_url": "https://yourwebsite.com/cancel"
}
} `
Any tips in what request I should use? I'm making the test with a credit card token because my country doesn't have google pay and paypal suport. But I need the PayPal API that accepts Google Pay direct token.
Edit:
I used this guide and it informs this API url: api-m.sandbox.paypal.com/v1/payments/payment
But it always returns the error described. The V2 request is totally different and don't have support (in the payments) for capture. Need a diferent paypal api request but I don't know what to use.

Checkout.js + Server-Side -> country_code and phone issues using REST API /v1/payments/payment

Without avail, I cannot get the country_code (CA) or phone to fill up after successfully calling create payment.
Country always show up as "United States" and Phone is "+1".
With or without shipping_address, shipping_preference: NO_SHIPPING. Using so-called examples (which might be outdated or not correctly documented), and the API documentation, which would be great to have examples included...
This is the create-payment query in json. I'm getting the same structure back with the following additions:
id:PAY-xxx
state:created
phone in payer_info (but no country_code as expected from the API)
created_time
...and...
PayPal's links in links.
Which indicate that the call was successful.
Either I should ditch "/v1/payments/payment" for something else I'm not aware of, or Paypal API is not up-to-date.
----- json create-payment query -----
{
"intent": "sale",
"payer": {
"payment_method": "paypal",
"payer_info": {
"email": "<snip>",
"first_name": "Bob",
"last_name": "Smith",
"billing_address": {
"line1": "1 notre dame",
"line2": "",
"city": "Montreal",
"country_code": "CA",
"postal_code": "H1H 1H1",
"phone": "011862212345678",
"state": "QC"
}
}
},
"application_context": {
"brand_name": "Server-side Test",
"locale": "fr_CA",
"landing_page": "Billing"
},
"transactions": [
{
"description": "The payment transaction description.",
"invoice_number": "5b5a38cb35bb7",
"custom": "merchant custom data",
"payment_options": {
"allowed_payment_method": "INSTANT_FUNDING_SOURCE"
},
"amount": {
"total": "5.75",
"currency": "CAD",
"details": {
"subtotal": "5",
"tax": "0.75"
}
},
"item_list": {
"items": [
{
"name": "item 1",
"description": "item 1 description",
"quantity": "1",
"price": "1",
"tax": "0.15",
"currency": "CAD"
},
{
"name": "item 2",
"description": "item 2 description",
"quantity": "2",
"price": "2",
"tax": "0.6",
"currency": "CAD"
}
],
"shipping_address": {
"recipient_name": "Bob Smith",
"line1": "1 notre dame",
"line2": "",
"city": "Montreal",
"country_code": "CA",
"postal_code": "H1H 1H1",
"phone": "011862212345678",
"state": "QC"
}
}
}
],
"redirect_urls": {
"return_url": "http:\/\/<snip>\/return.php",
"cancel_url": "http:\/\/<snip>\/cancel.php"
}
}

Pay pal Java api - Payment by credit card - Singapore (CURRENCY_NOT_ALLOWED)

I am using paypal java api for credit card payment with SGD but i am getting the below error.
Error code : 400 with response : {"name":"CURRENCY_NOT_ALLOWED","message":"Currency is not supported","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#CURRENCY_NOT_ALLOWED","debug_id":"d5473b485675e"}
My sample Request is
{
"intent": "sale",
"payer": {
"payment_method": "credit_card",
"funding_instruments": [
{
"credit_card": {
"number": "1111111111111111",
"type": "mastercard",
"expire_month": 11,
"expire_year": 2018,
"cvv2": 111,
"first_name": "Joe",
"last_name": "Shopper",
"billing_address": {
"line1": "52 N Main ST",
"city": "Singapore",
"country_code": "SG",
"postal_code": "120210"
}
}
}
]
},
"transactions": [
{
"amount": {
"currency": "SGD",
"total": "7",
"details": {
"shipping": "1",
"subtotal": "5",
"tax": "1"
}
},
"description": "This is the payment transaction description."
}
]
}
SGD is not supported for Direct Credit Card Payments.
Supported Currencies: USD, GBP,CAD,EUR and JPY
https://developer.paypal.com/docs/integration/direct/rest_api_payment_country_currency_support/
The only option for Singapore merchants to accept direct credit card is to use Hosted Sole Solution

Multiple transaction

How can I do multiple transaction in Paypal.
I tried using following JSON request
{
"intent": "sale",
"payer": {
"payment_method": "credit_card",
"funding_instruments": [
{
"credit_card": {
"number": "5500005555555559",
"type": "mastercard",
"expire_month": 12,
"expire_year": 2018,
"cvv2": 111,
"first_name": "Joe",
"last_name": "Shopper"
}
}
]
},
"transactions": [
{
"amount": {
"total": "7.47",
"currency": "USD"
},
"description": "This is the payment transaction description."
},{
"amount": {
"total": "9.71",
"currency": "USD"
},
"description": "This is the payment transaction description 2."
}
]
}
But it gives the following response
{
"name": "VALIDATION_ERROR",
"details": [
{
"field": "transactions",
"issue": "Only single payment transaction currently supported"
}
],
"message": "Invalid request - see details",
"information_link": "https://developer.paypal.com/webapps/developer/docs/api/#VALIDATION_ERROR",
"debug_id": "b18a0e6fdfe1d"
}

PayPal REST API does not take the customized shipping address

I am following the PayPal REST API Reference at https://developer.paypal.com/webapps/developer/docs/api/ to create and execute payments.
To create a payment, I send the following data to PayPal. The data contain "shipping_address". The payment is created successfully.
{
"intent": "sale",
"payer": {
"payment_method": "paypal"
},
"redirect_urls": {
"return_url": "http://www.somethingabc.com/approve",
"cancel_url": "http://www.somethingabc.com/cancel"
},
"transactions": [{
"amount": {
"currency": "USD",
"total": "10.00",
"details": {
"shipping": "0.00",
"subtotal": "10.00",
"tax": "0.00"
}
},
"item_list": {
"items": [{
"quantity": "1",
"name": "Apples",
"price": "10.00",
"currency": "USD"
}],
"shipping_address": {
"recipient_name": "John",
"type": "residential",
"line1": "441 Waterdale RD",
"city": "Heidelberg West",
"country_code": "AU",
"postal_code": "3081",
"state": "VICTORIA"
}
}
}]
}
Then, I redirect the web browser to the approval_url (e.g., https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-343434SADSDSAD34) given in the PayPal response for the user to login and approve the payment. The user logins and a PayPal review web page appears. I expect that this review page should show the customized shipping address which I have provided previously when the payment was created. However, the PayPal review web page shows the PayPal owner's address instead.
So, my question is how to force the PayPal review web page to show the customized shipping address instead of the PayPal owner's address? If this can't be done, how can I get the shipping address which the user has selected on the PayPal review web page (when I call the API to execute the payment, the selected shipping address is not included in the payer_info object!).
Thanks.
After testing your code I cannot find any errors. The response I get when completing the payment:
{
"id": "PAY-xxxxxxx",
"create_time": "2014-05-01T23:54:00Z",
"update_time": "2014-05-01T23:59:35Z",
"state": "approved",
"intent": "sale",
"payer": {
"payment_method": "paypal",
"payer_info": {
"email": "test#paypal.com",
"first_name": "John",
"last_name": "Smith",
"payer_id": "GPV2878GCMNGE",
"shipping_address": {
"line1": "441 Waterdale RD",
"city": "Heidelberg West",
"state": "Victoria",
"postal_code": "3081",
"country_code": "AU"
}
}
},
"transactions": [
{
"amount": {
"total": "10.00",
"currency": "USD",
"details": {
"subtotal": "10.00"
}
},
"item_list": {
"items": [
{
"name": "Apples",
"price": "10.00",
"currency": "USD",
"quantity": "1"
}
],
"shipping_address": {
"recipient_name": "John",
"line1": "441 Waterdale RD",
"city": "Heidelberg West",
"state": "VICTORIA",
"postal_code": "3081",
"country_code": "AU"
}
},
.....
}
If there you are not seeing this I would reach out to Paypal's Technical Support and file a trouble ticket. As this is the response you should get.
You will need to create an Experience Profile with the address_override option set to 1. The customer will then be unable to change the shipping address you have passed to PayPal.
You would include the experience_profile_id in your JSON request when initiating the sale.