worldpay支付网关api显示方法不允许错误

时间:2019-11-14 05:49:41

标签: php worldpay

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

1 个答案:

答案 0 :(得分:0)

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