我正在尝试将此 curl 调用转换为 guzzle:
curl https://core.spreedly.com/v1/gateways/CAL6uXHtGfDsxV2kW6apTP5JhG/purchase.xml \
-u 'Ll6fAtoVY5hTGlJEmtpo5YTS:RKOCG5D8jhgfdDSg524u5iF22XD4Io5VXmyzdCptrvHFTTSy' \
-H 'Content-Type: application/xml' \
-d '<transaction>
<payment_method_token>ZgPNHes541EMlBN86glRDKRexzq</payment_method_token>
<amount>100</amount>
<currency_code>USD</currency_code>
</transaction>'
我知道使用它这么多,所以任何帮助将不胜感激
这是我尝试过的,但我总是收到此错误“客户端错误响应 [状态代码] 422 [原因短语] 无法处理的实体”
$xml = '<transaction>\n';
$xml .= '<payment_method_token>$payment_method_token</payment_method_token>\n';
$xml .= '<amount>100</amount>\n';
$xml .= '<currency_code>USD</currency_code>\n'
$xml .= '<transaction>\n';
$headers = ['Content-Type' => 'application/xml', 'auth' => ['Ll6fAtoVY5hTGlJEmtpo5YTS', 'RKOCG5D8jhgfdDSg524u5iF22XD4Io5VXmyzdCptrvHFTTSy']];
$client = new Client('https://core.spreedly.com/v1/gateways/CAL6uXHtGfDsxV2kW6apTP5JhG/purchase.xml');
$requestCurl = $client->post('', $headers, $xml,[]);
$response = $requestCurl->send()->xml();
dd($response);
谢谢!