INTERNAL_SERVICE_ERROR on PayPal order pay - paypal

Question updated - more details added.
I get a 500 (INTERNAL_SERVICE_ERROR) error from PayPal when I try to pay for an order.
I get ok from create order, and get the orderID - order status CREATED.
The order is approved by buyer - successfully and order status become APPROVED.
Order created by https://api.sandbox.paypal.com/v1/checkout/orders
Approved using paypal https://www.paypalobjects.com/api/checkout.js
{
"id": "53T50821FM697283T",
"gross_total_amount": {
"value": "26.66",
"currency": "ILS"
},
"purchase_units": [
{
"reference_id": "20180318-64466",
"amount": {
"currency": "ILS",
"total": "26.66"
},
"payee": {
"email": "d0535318380-classeeks#gmail.com"
},
"items": [
{
"name": "Meeting",
"sku": "20180318-64466",
"description": "Meeting 1/26/2018 1:00 AM-1/26/2018 2:20 AM. aaaaa",
"price": "26.66",
"currency": "ILS",
"quantity": 1
}
],
"shipping_address": {
"recipient_name": "Andrey Dyachenko",
"line1": "ישראליס 5 דירה 4",
"city": "תל-אביב",
"country_code": "IL",
"postal_code": "61014",
"state": "",
"type": "HOME_OR_WORK"
},
"partner_fee_details": {
"receiver": {
"email": "d0535318380-reciver#gmail.com"
},
"amount": {
"value": "12.66",
"currency": "ILS"
}
}
}
],
"payer_info": {
"email": "d0535318380-buyer#gmail.com",
"first_name": "Andrey",
"last_name": "Dyachenko",
"payer_id": "BZDA9RCZXKYQY",
"country_code": "IL",
"shipping_address": {
"recipient_name": "Andrey Dyachenko",
"line1": "ישראליס 5 דירה 4",
"city": "תל-אביב",
"country_code": "IL",
"postal_code": "61014",
"state": "",
"type": "HOME_OR_WORK"
}
},
"metadata": {
"supplementary_data": [
{
"name": "risk_correlation_id",
"value": "53T50821FM697283T"
},
{
"name": "buyer_ipaddress",
"value": "109.65.134.129"
},
{
"name": "external_channel",
"value": "WEB"
}
]
},
"redirect_urls": {
"return_url": "https://classeeks.com/order/details/70368c93-90db-4a8e-bd82-6d611acc2d17",
"cancel_url": "https://classeeks.com/order/details/70368c93-90db-4a8e-bd82-6d611acc2d17"
},
"create_time": "2018-03-18T19:49:11Z",
"links": [
{
"href": "https://api.sandbox.paypal.com/v1/checkout/orders/53T50821FM697283T",
"rel": "self",
"method": "GET"
},
{
"href": "https://api.sandbox.paypal.com/v1/checkout/orders/53T50821FM697283T/capture",
"rel": "capture",
"method": "POST"
}
],
"status": "APPROVED"
}
Next step pay with https://api.sandbox.paypal.com/v1/checkout/orders/53T50821FM697283T/pay
{ "disbursement_mode":"DELAYED" }
Response
{
"name": "INTERNAL_SERVICE_ERROR",
"message": "The server encountered an internal error that prevented it from fulfilling this request.",
"information_link": "https://developer.paypal.com/docs/api/#INTERNAL_SERVICE_ERROR",
"debug_id": "be0c6976ab17a"
}
Based https://demo.paypal.com/us/demo/go?page=cart

If you have created the order successfully, then you can either capture the order directly or create the authorization which places the fund on hold and later you can capture the authorization. Check the doc for PayPal order APIs.

Related

PayPal subscription approval link throws an error

I am using Postman for this. It generates the following link https://www.sandbox.paypal.com/webapps/billing/subscriptions?ba_token=BA-79D58732NX9686808 however when I visit it, I see the following error message:
Things don't appear to be working at the moment. Please try again later.
After getting a token, I created a product then I created a plan and finally, I created a subscription. Am I missing something?
Here is what I have done and the response I have received:
Create Product:
{
"id": "FF-SUBSCRIPTION-SERVICE-BASIC-T1",
"name": "Subscription Basic Plan",
"description": "Basic Service Subscription Plan",
"type": "SERVICE"
}
Create Plan:
{
"product_id": "FF-SUBSCRIPTION-SERVICE-BASIC-T1",
"name": "Subscription Basic Plan",
"description": "Basic Service Subscription Plan",
"status": "ACTIVE",
"payment_preferences": {
"auto_bill_outstanding": true,
"payment_failure_threshold": 5
},
"billing_cycles": [
{
"frequency": {
"interval_unit": "MONTH",
"interval_count": 1
},
"tenure_type": "TRIAL",
"sequence": 1,
"total_cycles": 1
},
{
"frequency": {
"interval_unit": "MONTH",
"interval_count": 1
},
"tenure_type": "REGULAR",
"sequence": 2,
"total_cycles": 0,
"pricing_scheme": {
"fixed_price": {
"value": "14.99",
"currency_code": "USD"
}
}
}
]
}
Create Subscription:
{
"plan_id": "P-1DM03386YX156733CMNORKJQ",
"quantity": "1",
"shipping_amount": {
"currency_code": "USD",
"value": "14.99"
},
"subscriber": {
"name": {
"given_name": "John",
"surname": "Doe"
},
"email_address": "sb-xahhi21980157#personal.example.com"
}
},
"application_context": {
"brand_name": "X",
"locale": "en-US",
"shipping_preference": "SET_PROVIDED_ADDRESS",
"user_action": "SUBSCRIBE_NOW",
"payment_method": {
"payer_selected": "PAYPAL",
"payee_preferred": "IMMEDIATE_PAYMENT_REQUIRED"
},
"return_url": "https://www.example.com/returnUrl",
"cancel_url": "https://www.example.com/cancelUrl"
}
}
The response I receive is as follows:
{
"status": "APPROVAL_PENDING",
"id": "I-N6DFDLTU8HK9",
"create_time": "2022-10-29T11:58:28Z",
"links": [
{
"href": "https://www.sandbox.paypal.com/webapps/billing/subscriptions?ba_token=BA-79D58732NX9686808",
"rel": "approve",
"method": "GET"
},
{
"href": "https://api-m.sandbox.paypal.com/v1/billing/subscriptions/I-N6DFDLTU8HK9",
"rel": "edit",
"method": "PATCH"
},
{
"href": "https://api-m.sandbox.paypal.com/v1/billing/subscriptions/I-N6DFDLTU8HK9",
"rel": "self",
"method": "GET"
}
]
}

PayPal REST Api not returning exchange_rate

I have got a PayPal Advanced Checkout Sandbox set up and capturing the order using the API call below:
/v2/checkout/orders/{{order_id}}/capture
Below are the transaction details I send to create the order:
{
"intent": "CAPTURE",
"payer": {
"address": {
"admin_area_2": "Downton",
"postal_code": "SP5",
"country_code": "GB"
}
},
"purchase_units": [
{
"description": "Test Item",
"custom_id": "12345",
"soft_descriptor": "Purchase Descriptior",
"amount": {
"currency_code": "USD",
"value": "58.80",
"breakdown": {
"item_total": {
"currency_code": "USD",
"value": "49.00"
},
"tax_total": {
"currency_code": "USD",
"value": "9.80"
}
}
},
"items": [
{
"name": "Test Item",
"unit_amount": {
"currency_code": "USD",
"value": "49.00"
},
"tax": {
"currency_code": "USD",
"value": "9.80"
},
"quantity": 1,
"category": "PHYSICAL_GOODS"
}
],
"shipping": {}
}
]
}
And then once it has been paid with a sandbox personal account the order capture response is below:
{
"id": "4FS9138999682320N",
"status": "COMPLETED",
"payment_source": {
"paypal": {
"email_address": "sb-bdd43g21513704#personal.example.com",
"account_id": "V7ZN4NEJRLGZA",
"name": {
"given_name": "John",
"surname": "Doe"
},
"address": {
"country_code": "GB"
}
}
},
"purchase_units": [
{
"reference_id": "default",
"shipping": {
"name": {
"full_name": "John Doe"
},
"address": {
"address_line_1": "Whittaker House",
"address_line_2": "2 Whittaker Avenue",
"admin_area_2": "Richmond",
"admin_area_1": "Surrey",
"postal_code": "TW9 1EH",
"country_code": "GB"
}
},
"payments": {
"captures": [
{
"id": "40V95236PS9814847",
"status": "COMPLETED",
"amount": {
"currency_code": "USD",
"value": "58.80"
},
"final_capture": true,
"seller_protection": {
"status": "ELIGIBLE",
"dispute_categories": [
"ITEM_NOT_RECEIVED",
"UNAUTHORIZED_TRANSACTION"
]
},
"seller_receivable_breakdown": {
"gross_amount": {
"currency_code": "USD",
"value": "58.80"
},
"paypal_fee": {
"currency_code": "USD",
"value": "2.30"
},
"net_amount": {
"currency_code": "USD",
"value": "56.50"
}
},
"custom_id": "12345",
"links": [
{
"href": "https://api.sandbox.paypal.com/v2/payments/captures/40V95236PS9814847",
"rel": "self",
"method": "GET"
},
{
"href": "https://api.sandbox.paypal.com/v2/payments/captures/40V95236PS9814847/refund",
"rel": "refund",
"method": "POST"
},
{
"href": "https://api.sandbox.paypal.com/v2/checkout/orders/4FS9138999682320N",
"rel": "up",
"method": "GET"
}
],
"create_time": "2022-10-31T16:42:07Z",
"update_time": "2022-10-31T16:42:07Z"
}
]
}
}
],
"payer": {
"name": {
"given_name": "John",
"surname": "Doe"
},
"email_address": "sb-bdd43g21513704#personal.example.com",
"payer_id": "V7ZN4NEJRLGZA",
"address": {
"country_code": "GB"
}
},
"links": [
{
"href": "https://api.sandbox.paypal.com/v2/checkout/orders/4FS9138999682320N",
"rel": "self",
"method": "GET"
}
]
}
I get a status: COMPLETED as the response but it is not returning the exchange_rate value even though the payer currency is different to the payee currency.
Does anyone know why this is?
The example is a USD transaction, the payee account received USD.
If the payer used a funding source of a different currency to fund the transaction, this will not be visible to the receiver or API facilitator. Any such sender currency conversion is between the payer and PayPal; all you know (and all you need to know) is you received the requested USD amount via PayPal.

Transaction API doesn't work with the payment

Since two weeks we are trying to implement transaction api v3. with Google
payment option. Once we did a transaction the receipt has been displayed.
When we pressed "order" button we got confirmation that the transaction is
being confirmed but in developer Dotpay panel there were no visible
payments.
After a few transactions action stopped displaying the receipt and it
informed that "something went wrong. Try again later". When we removed googlePaymentOption from
TransactionDecision the receipt has been displayed but we were still not
able to make any transactions.
It lasted for a few days and after that we were able to make transactions again but there were
still no payments visible.
Can you please have a look?
Hereby you can find our transaction logs:
{
"conversationToken": "[\"_actions_on_google\",\"podsumowanie\",\"rezerwuj_dostawe\",\"zmien_zamowienie_lista\",\"start_index\",\"modyfikuj_koszyk\",\"dodaj_produkt\"]",
"expectUserResponse": true,
"expectedInputs": [{
"inputPrompt": {
"richInitialPrompt": {
"items": [{
"simpleResponse": {
"textToSpeech": "Transaction Decision Placeholder."
}
}]
}
},
"possibleIntents": [{
"intent": "actions.intent.TRANSACTION_DECISION",
"inputValueData": {
"#type": "type.googleapis.com/google.actions.transactions.v3.TransactionDecisionValueSpec",
"order": {
"merchantOrderId": "9g1blj8rmvo",
"userVisibleOrderId": "9g1blj8rmvo",
"buyerInfo": {
"email": "janedoe#gmail.com",
"firstName": "Jane",
"lastName": "Doe",
"displayName": "Jane Doe"
},
"createTime": "2020-06-09T14:02:08.812Z",
"lastUpdateTime": "2020-06-09T14:02:08.812Z",
"transactionMerchant": {
"id": "book_store_1",
"name": "Book Store"
},
"contents": {
"lineItems": [{
"id": "memoirs_4",
"name": "Our memoirs",
"priceAttributes": [{
"type": "REGULAR",
"name": "Item Price",
"state": "ACTUAL",
"amount": {
"currencyCode": "PLN",
"amountInMicros": "1000000"
},
"taxIncluded": true
}, {
"type": "TOTAL",
"name": "Total Price",
"state": "ACTUAL",
"amount": {
"currencyCode": "PLN",
"amountInMicros": "1000000"
},
"taxIncluded": true
}],
"notes": ["Special introduction by author."],
"purchase": {
"quantity": 1
}
}]
},
"priceAttributes": [{
"type": "SUBTOTAL",
"name": "Subtotal",
"state": "ESTIMATE",
"amount": {
"currencyCode": "PLN",
"amountInMicros": "1000000"
},
"taxIncluded": true
}, {
"type": "DELIVERY",
"name": "Delivery",
"state": "ACTUAL",
"amount": {
"currencyCode": "PLN"
},
"taxIncluded": true
}, {
"type": "TAX",
"name": "Tax",
"state": "ESTIMATE",
"amount": {
"currencyCode": "PLN"
},
"taxIncluded": true
}, {
"type": "TOTAL",
"name": "Total Price",
"state": "ESTIMATE",
"amount": {
"currencyCode": "PLN",
"amountInMicros": "1000000"
},
"taxIncluded": true
}],
"followUpActions": [{
"type": "VIEW_DETAILS",
"title": "View details",
"openUrlAction": {
"url": "http://example.com"
}
}, {
"type": "CALL",
"title": "Call us",
"openUrlAction": {
"url": "tel:+16501112222"
}
}, {
"type": "EMAIL",
"title": "Email us",
"openUrlAction": {
"url": "mailto:person#example.com"
}
}],
"termsOfServiceUrl": "http://www.example.com",
"note": "The Memoir collection",
"purchase": {
"status": "CREATED",
"type": "RETAIL",
"returnsInfo": {
"daysToReturn": 1,
"policyUrl": "http://www.example.com"
},
"fulfillmentInfo": {
"id": "FULFILLMENT_SERVICE_ID",
"fulfillmentType": "DELIVERY",
"expectedFulfillmentTime": {
"timeIso8601": "2025-09-25T18:00:00.877Z"
},
"price": {
"type": "REGULAR",
"name": "Delivery Price",
"state": "ACTUAL",
"amount": {
"currencyCode": "PLN"
},
"taxIncluded": true
},
"fulfillmentContact": {
"email": "janedoe#gmail.com",
"firstName": "Jane",
"lastName": "Doe",
"displayName": "Jane Doe"
}
},
"purchaseLocationType": "ONLINE_PURCHASE",
"userVisibleStatusLabel": "CREATED"
}
},
"orderOptions": {
"userInfoOptions": {
"userInfoProperties": ["EMAIL"]
}
},
"paymentParameters": {
"googlePaymentOption": {
"facilitationSpec": "{\"apiVersion\":2,\"apiVersionMinor\":0,\"merchantInfo\":{\"merchantName\":\"Frisco\"},\"allowedPaymentMethods\":[{\"type\":\"CARD\",\"parameters\":{\"allowedAuthMethods\":[\"PAN_ONLY\"],\"allowedCardNetworks\":[\"MASTERCARD\",\"VISA\"]},\"tokenizationSpecification\":{\"type\":\"PAYMENT_GATEWAY\",\"parameters\":{\"gateway\":\"dotpay\",\"gatewayMerchantId\":\"705777\"}}}],\"transactionInfo\":{\"totalPriceStatus\":\"FINAL\",\"totalPrice\":\"1.00\",\"currencyCode\":\"PLN\"}}"
}
},
"presentationOptions": {
"actionDisplayName": "PLACE_ORDER"
}
}
}],
"speechBiasingHints": ["$usun", "$dalej", "$events", "$wroc", "$product", "$deleteProduct", "$sztuka", "$dodaj", "$ilosc", "$produkty", "$deleteOrder"]
}],
"responseMetadata": {
"status": {
"message": "Success (200)"
},
"queryMatchInfo": {
"queryMatched": true,
"intent": "777d19a8-c59a-46d2-ae22-212827b5726e"
}
}
} ```
Currently, Google is working with a limited number of partners that can get access to the production Google Pay API. If you're not one of those partners, you're welcome to read the documentation and test the integration using the sandbox environment.
https://developers.google.com/assistant/transactions/physical/dev-guide-physical-gpay
If you are indeed one of these partners, please reach out to your Google contact.

PayPal -error 400 for US and Canada addresses

I am sending this request to PayPal in my checkout:
Request >>>> {
"intent": "authorize",
"payer": {
"payment_method": "paypal"
},
"transactions": [
{
"amount": {
"total": "2386.81",
"currency": "GBP",
"details": {
"subtotal": "1854.81",
"shipping": "532.00",
"tax": "0.00"
}
},
"item_list": {
"shipping_address": {
"recipient_name": "Johnny",
"type": "business",
"line1": "245",
"line2": "5th Avenue ",
"city": "Columbia -",
"country_code": "US",
"postal_code": "MO 65201",
"phone": "001 212 12345678"
}
},
"description": "907 items"
}
],
"redirect_urls": {
"return_url": "http://localhost:3000/payment/paypal-approved",
"cancel_url": "http://localhost:3000/payment/paypal-cancelled"
}
}
but I am getting the following error:
{
"cause": {
"response": {
"name": "UNKNOWN_ERROR",
"message": "An unknown error has occurred",
"information_link": "https://developer.paypal.com/webapps/developer/docs/api/#UNKNOWN_ERROR",
"debug_id": "b005dc4a36cc6",
"httpStatusCode": 400
},
"httpStatusCode": 400
},
"isOperational": true,
"response": {
"name": "UNKNOWN_ERROR",
"message": "An unknown error has occurred",
"information_link": "https://developer.paypal.com/webapps/developer/docs/api/#UNKNOWN_ERROR",
"debug_id": "b005dc4a36cc6",
"httpStatusCode": 400
},
"httpStatusCode": 400
}
if I change the address to any other country, except Canada, the request works.
looking at the documentation, https://developer.paypal.com/docs/api/#address-object, only line1, city and country_code are required.
is there anything specific i am missing, for USA and Canada that i may have missed?
It seems that you are missing state field in your request . Since Canada and US have state field , you need to pass it .
API Request :
{
"intent": "authorize",
"payer": {
"payment_method": "paypal"
},
"transactions": [
{
"amount": {
"total": "2386.81",
"currency": "GBP",
"details": {
"subtotal": "1854.81",
"shipping": "532.00",
"tax": "0.00"
}
},
"item_list": {
"shipping_address": {
"recipient_name": "Johnny",
"type": "business",
"line1": "245",
"line2": "5th Avenue ",
"city": "Columbia",
"country_code": "US",
"state": "MO",
"postal_code": "65201",
"phone": "001 212 12345678"
}
},
"description": "907 items"
}
],
"redirect_urls": {
"return_url": "http://localhost:3000/payment/paypal-approved",
"cancel_url": "http://localhost:3000/payment/paypal-cancelled"
}
}
API Response :
{
"id": "PAY-4NK43903V190842KVLY5JA",
"create_time": "2015-05-16T18:38:28Z",
"update_time": "2015-05-16T18:38:28Z",
"state": "created",
"intent": "authorize",
"payer": {
"payment_method": "paypal",
"payer_info": {
"shipping_address": {}
}
},
"transactions": [
{
"amount": {
"total": "2386.81",
"currency": "GBP",
"details": {
"subtotal": "1854.81",
"shipping": "532.00"
}
},
"description": "907 items",
"item_list": {
"shipping_address": {
"recipient_name": "Johnny",
"line1": "245",
"line2": "5th Avenue ",
"city": "Columbia",
"state": "MO",
"phone": "001 212 12345678",
"postal_code": "65201",
"country_code": "US"
}
},
"related_resources": []
}
],
"links": [
{
"href": "https://api.sandbox.paypal.com/v1/payments/payment/PAY-4NK43903V1908425XKVLY5JA",
"rel": "self",
"method": "GET"
},
{
"href": "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-9XM291481W9678205",
"rel": "approval_url",
"method": "REDIRECT"
},
{
"href": "https://api.sandbox.paypal.com/v1/payments/payment/PAY-4NK43903V1908425XKVLY5JA/execute",
"rel": "execute",
"method": "POST"
}
]
}

Keep receiving 404 Error with Rest API when doing a capture

This is an edit to my original post. I think the paypal rest api sandbox is down.
The error just started and I haven't had it before:
here is the capture URL:
https://api.sandbox.paypal.com/v1/payments/payment/PAY-8EN83459YH6921921KJ4QNHQ
Its a 404 error. Here is the body:
{
name: "INVALID_RESOURCE_ID"
message: "The requested resource ID was not found"
information_link: "https://developer.paypal.com/webapps/developer/docs/api/#INVALID_RESOURCE_ID"
debug_id: "e56bae98dcc26"
}
The payment was properly created and I used the same credentials and the payment link provided in the returned payment creation response.
Here was the response from the original payment creation call:
{
"id": "PAY-8EN83459YH6921921KJ4QNHQ",
"create_time": "2013-11-05T14:54:22Z",
"update_time": "2013-11-05T14:54:30Z",
"state": "approved",
"intent": "authorize",
"payer": {
"payment_method": "credit_card",
"funding_instruments": [
{
"credit_card": {
"type": "visa",
"number": "xxxxxxxxxxxx0331",
"expire_month": "11",
"expire_year": "2018",
"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.",
"related_resources": [
{
"authorization": {
"id": "0UH21242UH1119007",
"create_time": "2013-11-05T14:54:22Z",
"update_time": "2013-11-05T14:54:30Z",
"state": "authorized",
"amount": {
"total": "7.47",
"currency": "USD",
"details": {
"subtotal": "7.41",
"tax": "0.03",
"shipping": "0.03"
}
},
"parent_payment": "PAY-8EN83459YH6921921KJ4QNHQ",
"valid_until": "2013-12-04T14:54:22Z",
"links": [
{
"href": "https:\/\/api.sandbox.paypal.com\/v1\/payments\/authorization\/0UH21242UH1119007",
"rel": "self",
"method": "GET"
},
{
"href": "https:\/\/api.sandbox.paypal.com\/v1\/payments\/authorization\/0UH21242UH1119007\/capture",
"rel": "capture",
"method": "POST"
},
{
"href": "https:\/\/api.sandbox.paypal.com\/v1\/payments\/authorization\/0UH21242UH1119007\/void",
"rel": "void",
"method": "POST"
},
{
"href": "https:\/\/api.sandbox.paypal.com\/v1\/payments\/payment\/PAY-8EN83459YH6921921KJ4QNHQ",
"rel": "parent_payment",
"method": "GET"
}
]
}
}
]
}
],
"links": [
{
"href": "https:\/\/api.sandbox.paypal.com\/v1\/payments\/payment\/PAY-8EN83459YH6921921KJ4QNHQ",
"rel": "self",
"method": "GET"
}
]
}
There is a reported problem at the moment with REST API. PayPal are working on it.
I was hitting my head against the wall for a while thinking that this PayPal bug was the cause of my problems. However, it turns out that PayPal generates the same error when you are using the wrong configuration in your client. In my case, I had the Android library set to use ENVIRONMENT_NO_NETWORK, and not ENVIRONMENT_SANDBOX. This produces real-looking transaction IDs, which (of course) are not registered with the server.