2013-10-20 83 views
1

我是PayPal集成的新手,我试图创建第一笔付款,通过他们的模拟器(https://devtools-paypal.com/apiexplorer/PayPalRestAPIs)向PayPal Rest API发送以下请求:“单一交易中目前只支持单一付款交易”

{ 
"intent": "sale", 
"payer": { 
    "payment_method": "paypal", 
    "funding_instruments": [ 
     { 
      "credit_card": { 
       "number": "5277726581534042", 
       "type": "mastercard", 
       "expire_month": "9", 
       "expire_year": "2018", 
       "links": [ 
        { 
         "targetSchema": { 
          "readonly": "true" 
         }, 
         "schema": { 
          "readonly": "true" 
         } 
        } 
       ] 
      } 
     } 
    ], 
    "payer_info": { 
     "email": "[email protected]" 
    } 
}, 
"transactions": [ 
    { 
     "amount": { 
      "currency": "USD", 
      "total": "10" 
     }, 
     "payee": { 
      "email": "[email protected]" 
     } 
    } 
], 
"redirect_urls": { 
    "return_url": "yandex.ru", 
    "cancel_url": "google.com" 
}, 
"links": [ 
    { 
     "href": "http://google.com", 
     "rel": "http://yandex.ru", 
     "targetSchema": { 
      "readonly": "true" 
     }, 
     "schema": { 
      "readonly": "true" 
     } 
    } 
] 
} 

的reasponse我得到的是:

{ 
"name": "VALIDATION_ERROR", 
"details": [ 
    { 
     "field": "transactions", 
     "issue": "Only single payment transaction currently supported" 
    } 
], 
"message": "Invalid request - see details", 
"information_link": "https://developer.paypal.com/webapps/developer/docs/api/#VALIDATION_ERROR", 
"debug_id": "08c2dc7a41f64" 

}
我只是不知道如何使它工作..

贝宝只是说,IM发送2个金..

任何帮助将高度赞赏

回答

0

你试图使一个卡或PayPal钱包付款?
也就是说,您是计划直接向卡充值还是将用户重定向至PayPal?
在您当前的请求中,您将包含来自两个选项的数据。这可能是API Explorer的一个问题,如果这是它给你的。

试试这个:

curl -v https://api.sandbox.paypal.com/v1/payments/payment \ 
-H 'Content-Type:application/json' \ 
-H 'Authorization:Bearer EEwJ6tF9x5WCIZDYzyZGaz6Khbw7raYRIBV_WxVvgmsG' \ 
-d '{ 
    "intent":"sale", 
    "redirect_urls":{ 
    "return_url":"http://example.com/your_redirect_url/", 
    "cancel_url":"http://example.com/your_cancel_url/" 
    }, 
    "payer":{ 
    "payment_method":"paypal" 
    }, 
    "transactions":[ 
    { 
     "amount":{ 
     "total":"7.47", 
     "currency":"USD" 
     } 
    } 
    ] 
}' 

或者用于刷卡支付:

curl -v https://api.sandbox.paypal.com/v1/payments/payment \ 
-H "Content-Type:application/json" \ 
-H "Authorization:Bearer EEwJ6tF9x5WCIZDYzyZGaz6Khbw7raYRIBV_WxVvgmsG" \ 
-d '{ 
    "intent": "sale", 
    "payer": { 
    "payment_method": "credit_card", 
    "funding_instruments": [ 
     { 
     "credit_card": { 
      "number": "5500005555555559", 
      "type": "mastercard", 
      "expire_month": 12, 
      "expire_year": 2018, 
      "cvv2": 111, 
      "first_name": "Joe", 
      "last_name": "Shopper" 
     } 
     } 
    ] 
    }, 
    "transactions": [ 
    { 
     "amount": { 
     "total": "7.47", 
     "currency": "USD" 
     }, 
     "description": "This is the payment transaction description." 
    } 
    ] 
}' 

(替换的Authorization头用自己的访问令牌)。