2015-09-25 75 views
0

我正在使用https://github.com/paypal/PayPal-node-SDK。對於網絡支付(瀏覽器),它可以工作。但是,對於移動(的iOS /安卓)沒有,試圖執行付款給PAYMENT_STATE_INVALIDPayPal執行付款返回PAYMENT_STATE_INVALID

{ [Error: Response Status : 400] 
    response: 
    { name: 'PAYMENT_STATE_INVALID', 
    message: 'This request is invalid due to the current state of the payment', 
    information_link: 'https://developer.paypal.com/webapps/developer/docs/api/#PAYMENT_STATE_INVALID', 
    debug_id: '2432d6f51f033', 
    httpStatusCode: 400 }, 
    response_stringified: '{"name":"PAYMENT_STATE_INVALID","message":"This request is invalid due to the current state of the payment","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#PAYMENT_STATE_INVALID","debug_id":"2432d6f51f033","httpStatusCode":400}', 
    httpStatusCode: 400 } 

我的網絡和移動之間注意到的區別是:

對於網絡貝寶返回paymentId和payerId,我可以執行時使用。對於手機,我只收到paymentId,所以我會通過調用Paypal來查詢payerId。

(我得到付款人ID支付信息)

{ id: 'PAY-7S571696JF513951VKYCRD5Q', 
    create_time: '2015-09-25T09:20:54Z', 
    update_time: '2015-09-25T09:21:02Z', 
    state: 'approved', 
    intent: 'sale', 
    payer: 
    { payment_method: 'paypal', 
    status: 'VERIFIED', 
    payer_info: 
     { email: '...', 
     first_name: 'test', 
     last_name: 'buyer', 
     payer_id: 'HBT36U55GA6R8' } }, 
    transactions: 
    [ { amount: [Object], 
     description: '...', 
     related_resources: [Object] } ], 
    links: 
    [ { href: 'https://api.sandbox.paypal.com/v1/payments/payment/PAY-7S571696JF513951VKYCRD5Q', 
     rel: 'self', 
     method: 'GET' } ], 
    httpStatusCode: 200 } 

執行付款前,對於網絡,我注意到付款狀態爲「創造」。對於移動它的「批准」。與網絡相比,移動設備似乎處於更加正確的狀態?但失敗。這是爲什麼?


更多信息下面

(移動支付JSON)

{ 
    "id":"PAY-4A020366MP615491MKYCRYCA", 
    "create_time":"2015-09-25T10:03:52Z", 
    "update_time":"2015-09-25T10:03:59Z", 
    "state":"approved", 
    "intent":"sale", 
    "payer":{ 
     "payment_method":"paypal", 
     "status":"VERIFIED", 
     "payer_info":{ 
     "email":"...", 
     "first_name":"test", 
     "last_name":"buyer", 
     "payer_id":"HBT36U55GA6R8" 
     } 
    }, 
    "transactions":[ 
     { 
     "amount":{ 
      "total":"40.00", 
      "currency":"SGD", 
      "details":{ 
       "subtotal":"40.00" 
      } 
     }, 
     "description":"...", 
     "related_resources":[ 
      { 
       "sale":{ 
        "id":"2WD385798K879144N", 
        "create_time":"2015-09-25T10:03:52Z", 
        "update_time":"2015-09-25T10:03:59Z", 
        "amount":{ 
        "total":"40.00", 
        "currency":"SGD" 
        }, 
        "payment_mode":"INSTANT_TRANSFER", 
        "state":"completed", 
        "protection_eligibility":"INELIGIBLE", 
        "parent_payment":"PAY-4A020366MP615491MKYCRYCA", 
        "transaction_fee":{ 
        "value":"1.86", 
        "currency":"SGD" 
        }, 
        "links":[ 
        { 
         "href":"https://api.sandbox.paypal.com/v1/payments/sale/2WD385798K879144N", 
         "rel":"self", 
         "method":"GET" 
        }, 
        { 
         "href":"https://api.sandbox.paypal.com/v1/payments/sale/2WD385798K879144N/refund", 
         "rel":"refund", 
         "method":"POST" 
        }, 
        { 
         "href":"https://api.sandbox.paypal.com/v1/payments/payment/PAY-4A020366MP615491MKYCRYCA", 
         "rel":"parent_payment", 
         "method":"GET" 
        } 
        ] 
       } 
      } 
     ] 
     } 
    ], 
    "links":[ 
     { 
     "href":"https://api.sandbox.paypal.com/v1/payments/payment/PAY-4A020366MP615491MKYCRYCA", 
     "rel":"self", 
     "method":"GET" 
     } 
    ], 
    "httpStatusCode":200 
} 

(網絡支付JSON)

{ 
    "id":"PAY-7GT16633EV511960JKYCSI6Y", 
    "create_time":"2015-09-25T10:39:55Z", 
    "update_time":"2015-09-25T10:39:55Z", 
    "state":"created", 
    "intent":"sale", 
    "payer":{ 
     "payment_method":"paypal", 
     "status":"VERIFIED", 
     "payer_info":{ 
     "email":"...", 
     "first_name":"test", 
     "last_name":"buyer", 
     "payer_id":"HBT36U55GA6R8", 
     "shipping_address":{ 
      "line1":"123 Thomson Rd. ", 
      "city":"Singapore", 
      "postal_code":"308123", 
      "country_code":"SG", 
      "recipient_name":"buyer test" 
     } 
     } 
    }, 
    "transactions":[ 
     { 
     "amount":{ 
      "total":"20.00", 
      "currency":"SGD", 
      "details":{ 
       "subtotal":"20.00" 
      } 
     }, 
     "description":"...", 
     "item_list":{ 
      "items":[ 
       { 
        "name":"X", 
        "price":"10.00", 
        "currency":"SGD", 
        "quantity":"2" 
       } 
      ] 
     }, 
     "related_resources":[ 

     ] 
     } 
    ], 
    "links":[ 
     { 
     "href":"https://api.sandbox.paypal.com/v1/payments/payment/PAY-7GT16633EV511960JKYCSI6Y", 
     "rel":"self", 
     "method":"GET" 
     }, 
     { 
     "href":"https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-1MX622874M8475431", 
     "rel":"approval_url", 
     "method":"REDIRECT" 
     }, 
     { 
     "href":"https://api.sandbox.paypal.com/v1/payments/payment/PAY-7GT16633EV511960JKYCSI6Y/execute", 
     "rel":"execute", 
     "method":"POST" 
     } 
    ], 
    "httpStatusCode":200 
} 

回答

1

對於移動SDK,它處理重定向和在移動應用程序中執行付款。因此,您將通過HATEOAS鏈接返回付款信息和退款信息。該交易已經完成。

對於網絡,您仍然需要重定向客戶,然後執行付款,這聽起來像您已經在做,並且工作正常。

TL; DR:移動SDK已經執行了付款。

+0

注意。是的,還要補充我應該驗證移動支付。 –