代码之家  ›  专栏  ›  技术社区  ›  Lukas Liesis

贝宝快捷结帐:我应该如何检查是否完成交易和金钱转移?

  •  1
  • Lukas Liesis  · 技术社区  · 6 年前

    我有贝宝快捷结帐在客户端和回调后,与支付ID,我想检查在NodeJS方面的ID被激发。我使用JS SDK调用RESTfull API:

    https://developer.paypal.com/docs/api/payments/v1/#payment_get

    我在下面看到这样的物体。

    州政府批准 transactions[0].related_resources[0].sale.state === 悬而未决的

    {
                "id": "PAY-7SN4959762125513LLPOWTDA",
                "intent": "sale",
                "state": "approved",
                "cart": "2A9434180T1061602",
                "payer": {
                    "payment_method": "paypal",
                    "status": "VERIFIED",
                    "payer_info": {
                        "email": "pp-test@gmail.com",
                        "first_name": "Some",
                        "last_name": "Surname",
                        "payer_id": "E76V3DRUQZYZW",
                        "shipping_address": {
                            "recipient_name": "Some Surname"
                        },
                        "phone": "0455346902",
                        "country_code": "FR"
                    }
                },
                "transactions": [
                    {
                        "amount": {
                            "total": "27.96",
                            "currency": "EUR",
                            "details": {
                                "subtotal": "27.96"
                            }
                        },
                        "payee": {
                            "merchant_id": "FJ96CP2E7QWMY"
                        },
                        "description": "The payment for services.",
                        "custom": "ws-1XWCLNRbVdWavMVZgH2cSE",
                        "invoice_number": "in-1h7KSgdCh35Gdpi_Yk7PO_",
                        "item_list": {
                            "items": [],
                            "shipping_address": {
                                "recipient_name": "Some Surname"
                            }
                        },
                        "related_resources": [
                            {
                                "sale": {
                                    "id": "7UB08136N5814360K",
                                    "state": "pending",
                                    "amount": {
                                        "total": "27.96",
                                        "currency": "EUR",
                                        "details": {
                                            "subtotal": "27.96"
                                        }
                                    },
                                    "payment_mode": "INSTANT_TRANSFER",
                                    "reason_code": "RECEIVING_PREFERENCE_MANDATES_MANUAL_ACTION",
                                    "protection_eligibility": "ELIGIBLE",
                                    "protection_eligibility_type": "ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE",
                                    "parent_payment": "PAY-7SN4959762125513LLPOWTDA",
                                    "create_time": "2018-11-03T09:25:53Z",
                                    "update_time": "2018-11-03T09:25:53Z",
                                    "links": [
                                        {
                                            "href": "https://api.sandbox.paypal.com/v1/payments/sale/7UB08136N5814360K",
                                            "rel": "self",
                                            "method": "GET"
                                        },
                                        {
                                            "href": "https://api.sandbox.paypal.com/v1/payments/sale/7UB08136N5814360K/refund",
                                            "rel": "refund",
                                            "method": "POST"
                                        },
                                        {
                                            "href": "https://api.sandbox.paypal.com/v1/payments/payment/PAY-7SN4959762125513LLPOWTDA",
                                            "rel": "parent_payment",
                                            "method": "GET"
                                        }
                                    ]
                                }
                            }
                        ]
                    }
                ],
                "create_time": "2018-11-03T09:25:32Z",
                "links": [
                    {
                        "href": "https://api.sandbox.paypal.com/v1/payments/payment/PAY-7SN4959762125513LLPOWTDA",
                        "rel": "self",
                        "method": "GET"
                    }
                ],
                "httpStatusCode": 200
            }
    
    1 回复  |  直到 6 年前
        1
  •  0
  •   Lukas Liesis    6 年前

    我终于发现:

    “批准”状态仅仅意味着买家登录了他们的帐户 请求,一旦您检查 “相关资源”部分,应该说“已完成”,其中 指示已捕获交易金额。显示的“id”

    https://www.paypal-community.com/t5/REST-APIs/IPN-vs-actions-payment-execute-result/td-p/1564037