get currency-converted amount via REST API

1.8k views Asked by At

We currently process USD payments via paypal's REST API using their ruby gem. I would like to accept other currencies and have set our account to auto-convert foreign currency payments to USD. I can successfully process these payments and can see in the sandbox web interface that they were converted, but it's unclear to me how to look the conversion transactions up via the API. Can anyone shed any light on this? See screenshot and completed payment + sale record below.

enter image description here

    Response[200]: OK, Duration: 0.858s
{
              "id" => "PAY-0XK33729VB648561PKV5SG6A",
          "intent" => "sale",
           "payer" => {
        "payment_method" => "paypal",
                "status" => "VERIFIED",
            "payer_info" => {
                       "email" => "[email protected]",
                  "first_name" => "Fake",
                   "last_name" => "Fakerson",
                    "payer_id" => "F2JC8YDQ6HDUA",
            "shipping_address" => {
                         "line1" => "1 Main St",
                          "city" => "San Jose",
                         "state" => "CA",
                   "postal_code" => "95131",
                  "country_code" => "US",
                "recipient_name" => "Fake Fakerson"
            }
        }
    },
    "transactions" => [
        [0] {
                       "amount" => {
                "currency" => "EUR",
                   "total" => "5.00",
                 "details" => {
                    "subtotal" => "5.00"
                }
            },
                  "description" => "Unlimited School - I'm a course",
            "related_resources" => [
                [0] {
                    "sale" => {
                                                 "id" => "24439073LW446012K",
                                             "amount" => {
                            "currency" => "EUR",
                               "total" => "5.00"
                        },
                                       "payment_mode" => "INSTANT_TRANSFER",
                                              "state" => "completed",
                             "protection_eligibility" => "ELIGIBLE",
                        "protection_eligibility_type" => "ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE",
                                    "transaction_fee" => {
                            "currency" => "EUR",
                               "value" => "0.50"
                        },
                                     "parent_payment" => "PAY-0XK33729VB648561PKV5SG6A",
                                        "create_time" => "2015-06-12T18:22:48Z",
                                        "update_time" => "2015-06-12T18:23:19Z",
                                              "links" => [
                            [0] {
                                  "href" => "https://api.sandbox.paypal.com/v1/payments/sale/24439073LW446012K",
                                   "rel" => "self",
                                "method" => "GET"
                            },
                            [1] {
                                  "href" => "https://api.sandbox.paypal.com/v1/payments/sale/24439073LW446012K/refund",
                                   "rel" => "refund",
                                "method" => "POST"
                            },
                            [2] {
                                  "href" => "https://api.sandbox.paypal.com/v1/payments/payment/PAY-0XK33729VB648561PKV5SG6A",
                                   "rel" => "parent_payment",
                                "method" => "GET"
                            }
                        ]
                    }
                }
            ]
        }
    ],
           "state" => "approved",
     "create_time" => "2015-06-12T18:22:48Z",
     "update_time" => "2015-06-12T18:23:19Z",
           "links" => [
        [0] {
              "href" => "https://api.sandbox.paypal.com/v1/payments/payment/PAY-0XK33729VB648561PKV5SG6A",
               "rel" => "self",
            "method" => "GET"
        }
    ]
}
1

There are 1 answers

0
Eshan On

I don't think so that REST API has any API for fetching the currency conversion only at this moment .

However , you can use the PayPal's Classic API to achieve your goal . See the example below :

NVP Request:

USER=XXXX&PWD=XXXXX&SIGNATURE=XXXXXXXX&VERSION=109.0&METHOD=TransactionSearch&STARTDATE=2014-06-01T00:00:00Z&ENDDATE=2015-06-05T00:00:00Z&TRANSACTIONCLASS=CurrencyConversions

NVP Response:

L_TIMESTAMP0=2015-04-21T20:53:39Z
L_TIMESTAMP1=2015-04-21T20:53:39Z
L_TIMESTAMP2=2014-11-11T18:40:45Z
L_TIMESTAMP3=2014-11-11T18:40:45Z
L_TIMEZONE0=GMT
L_TIMEZONE1=GMT
L_TIMEZONE2=GMT
L_TIMEZONE3=GMT
L_TYPE0=Currency Conversion (credit)
L_TYPE1=Currency Conversion (debit)
L_TYPE2=Currency Conversion (credit)
L_TYPE3=Currency Conversion (debit)
L_NAME0=From British Pound
L_NAME1=To U.S. Dollar
L_NAME2=From U.S. Dollar
L_NAME3=To British Pound
L_TRANSACTIONID0=76K70596XX6169325
L_TRANSACTIONID1=7P3811819E363281J
L_TRANSACTIONID2=2GF65791PP4273901
L_TRANSACTIONID3=2K135972TE2156124
L_STATUS0=Completed
L_STATUS1=Completed
L_STATUS2=Completed
L_STATUS3=Completed
L_AMT0=4060.54
L_AMT1=-2626.32
L_AMT2=6.36
L_AMT3=-10.36
L_CURRENCYCODE0=USD
L_CURRENCYCODE1=GBP
L_CURRENCYCODE2=GBP
L_CURRENCYCODE3=USD
L_FEEAMT0=0.00
L_FEEAMT1=0.00
L_FEEAMT2=0.00
L_FEEAMT3=0.00
L_NETAMT0=4060.54
L_NETAMT1=-2626.32
L_NETAMT2=6.36
L_NETAMT3=-10.36
TIMESTAMP=2015-06-12T22:48:14Z
CORRELATIONID=f01a7f7fb27f2
ACK=Success
VERSION=109.0
BUILD=16964802