【问题标题】:worldpay payment gateway api showing method not allowed errorworldpay 支付网关 api 显示方法不允许错误
【发布时间】:2020-03-10 00:31:10
【问题描述】:

我尝试使用这种 api 格式在 worldpay 支付网关中进行标记化。我得到了方法不允许的响应。这个方法有什么错误。

https://api.worldpay.com/v1/tokens?clientkey=mykey&name=namee&expiryMonth=2&expiryyear=2025&issuenumber=1&startmonth=2&startyear=2018&cardnumber=4444333322221111&type=Card&cvc=123

我在尝试时遇到了这个错误。

{"httpStatusCode":405,
"customCode":"HTTP_METHOD_NOT_ALLOWED",
"message":"Request method 'GET' not supported",
"description":"Requested HTTP method is not supported",
"errorHelpUrl":null,
"originalRequest":"api.worldpay.com/v1/…"}

【问题讨论】:

  • 向我们展示一些在尝试实现所需功能时发生的代码和错误。
  • 我收到类似这样的错误 " {"httpStatusCode":405,"customCode":"HTTP_METHOD_NOT_ALLOWED","message":"请求方法 'GET' 不支持","description":"请求的 HTTP方法不受支持","errorHelpUrl":null,"originalRequest":"api.worldpay.com/v1/…"}
  • 这正是它所说的。您不应该在 api 上使用 GET 方法。请阅读它的文档并使用POST 或文档中提到的任何内容。

标签: php worldpay


【解决方案1】:

您必须发送POST 请求而不是GET 请求。使用cURL

例子:

// set post fields values
$post = [
    'clientkey' => 'your_key',
    'name' => 'Some Name', // etc.
];

$ch = curl_init('https://api.worldpay.com/v1/tokens');
curl_setopt($ch, CURLOPT_POST, 1);    
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);

$response = curl_exec($ch);

// close the connection, release resources used
curl_close($ch);

//do something with $response 

【讨论】:

    猜你喜欢
    • 2017-02-27
    • 2018-11-07
    • 2013-08-28
    • 2017-12-29
    • 2015-07-19
    • 2016-02-25
    • 2014-12-23
    • 2015-03-20
    • 2016-08-07
    相关资源
    最近更新 更多