php - worldpay 支付网关 api 显示方法不允许错误
问题描述
我在 worldpay 支付网关中尝试了这种 api 格式的标记化。我得到了方法不允许的响应。这种方法有什么错误。
我在尝试时遇到了这个错误。
{"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/…"}
解决方案
您必须发送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
推荐阅读
- python - Django migrate 返回 1064 - 您的 SQL 语法有错误
- visual-studio-code - 使水平滚动条在 Visual Studio 代码中更明显
- javascript - 如何通过javascript清除应用程序的撤消历史记录
- java - iocp.setPresolve(GLPKConstants.GLP_ON); 出现错误
- node.js - 使用 node.js 编辑 .env 文件
- sql - 在 12 个月的滚动期内(从当月回溯 11 个月)每月每位医生的不同患者数
- javascript - 在 react.js 中映射一个充满 html 元素的对象
- c# - 最新的声纳不只显示 c# 结果 javascript
- python - 检查输入时出错:预期 conv2d_input 有 4 个维度,但得到了形状为 (28708, 1) 的数组
- php - Laravel 将 NULL 放在引号内