通过REST API获取货币转换金额

时间:2015-06-12 19:02:52

标签: paypal paypal-sandbox paypal-rest-sdk

我们目前使用他们的ruby gem通过paypal的REST API处理美元付款。我想接受其他货币并设置我们的帐户以自动兑换外币到美元。我可以成功处理这些付款,并且可以在沙箱网络界面中看到它们已被转换,但我不清楚如何通过API查看转换事务。任何人都可以对此有所了解吗?请参阅下面的截图和完成的付款+销售记录。

enter image description here

    Response[200]: OK, Duration: 0.858s
{
              "id" => "PAY-0XK33729VB648561PKV5SG6A",
          "intent" => "sale",
           "payer" => {
        "payment_method" => "paypal",
                "status" => "VERIFIED",
            "payer_info" => {
                       "email" => "jack@example.com",
                  "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 个答案:

答案 0 :(得分:1)

我不认为REST API目前只有用于获取货币转换的API。

但是,您可以使用PayPal的Classic API来实现您的目标。请参阅以下示例:

NVP请求:

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