양식 내에서 chargify API 로그 결제에 POST를 실행하는 중 문제가 발생합니다.PHP curl/json 관련 문제 POST
그러나 오류를 반환하기 때문에 POST가 실제로 GET으로 보내지는 것으로 보입니다.
내가 잘못하고있는 것에 대해 조언 해 줄 사람이 있습니까? Postman은 JSON을 POST로 보내면 잘 작동하지만 PHP에서 작동하지는 않습니다.
:이 하나 개의 코드를 사용했습니다
//find invoice id # using invoice number search form
$invoiceNumber = fRequest::get('invoicenumber');
$json = file_get_contents('https://<maskedforprivacy>.chargify.com/invoices.json?number=' . $invoiceNumber);
$returnedInvData = fJSON::decode($json);
$invoiceId = $returnedInvData[0]->invoice->id;
// grab form data as payment info to send to chargify
$paymentAmount = fRequest::Get('amount');
$memo = fRequest::Get('memo');
if ((isset($invoiceNumber,$paymentAmount,$memo))) {
$url = 'https://<maskedforprivacy>.chargify.com/subscriptions/' . $invoiceId . '/payments.json';
$params = array(
'payment' => array(
'amount' => $paymentAmount,
'memo' => (string)$memo
),
);
// encode as json
$content = FJSON::encode($params);
// send to chargify
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER,
array("Content-type: application/json"));
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $content);
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($status != 201) {
die("Error: call to URL $url failed with status $status, response $json_response, curl_error " . curl_error($curl) . ", curl_errno " . curl_errno($curl));
}
curl_close($curl);
$response = json_decode($json_response, true);
}
출력물을 게시하십시오. –
오류 404.하지만 우물은 괜찮습니다. 우체부를 사용하고 본체에 json을 보내면 아무 문제가 없습니다. – firecasey