首页 > 解决方案 > worldpay 支付网关 api 显示方法不允许错误

问题描述

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

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/…"}

标签: phpworldpay

解决方案


您必须发送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 

推荐阅读