请与Neteller共享接收付款的代码。
我可以设法从accessToken获得Oauth2,但其余的调用返回时会出现错误400,这是一个糟糕的请求。
下面是如何使用Guzzle获得accessToken的方法:
$request = $client->post('https://test.api.neteller.com/v1/oauth2/token', [
'headers' => ['Authorization' => 'Basic ' . base64_encode($client_id . ':' . $client_secret)],
'body' => ['grant_type' => 'client_credentials'],
'allow_redirects' => false
]);
$response = $request->json();
$accessToken = $response['accessToken'];但是下面的代码给了我错误:
$request = $client->post('https://test.api.neteller.com/v1/transferIn', [
'headers' => [
'Authorization' => 'Bearer ' . $accessToken,
'Content-Type' => 'application/json'
],
'body' => [
'paymentMethod' => [
'type' => 'neteller',
'value' => 'netellertest_eur@neteller.com'
],
'transaction' => [
'merchantRefId' => 'P54bd91375d4fe',
'amount' => '5000',
'currency' => 'USD'
],
'verificationCode' => '234124'
]
]);我做错了什么?如果您有接收付款的代码,请共享代码。
干杯,阿尔
发布于 2015-02-13 08:34:46
看起来,您试图在正文中发送post字段,而不是API所期望的JSON。作为一个相当原始的例子,更接近这一点的东西应该能起作用:
$request = $client->post('https://test.api.neteller.com/v1/transferIn', [
'headers' => [
'Authorization' => 'Bearer ' . $accessToken,
'Content-Type' => 'application/json'
],
'body' => '{
"paymentMethod": {
"type": "neteller",
"value": "netellertest_eur@neteller.com"
},
"transaction": {
"merchantRefId": "P54bd91375d4fe",
"amount": 5000,
"currency": "USD"
},
"verificationCode": "234124"
}'
]);当然,一旦准备好将代码集成到应用程序中,您就需要使用类似于json_encode的东西来构建自己的身体。
https://stackoverflow.com/questions/28493591
复制相似问题