【发布时间】:2021-12-05 06:16:41
【问题描述】:
在沙盒版本上运行时出现资源未找到错误,但在实时运行时可以找到。 有人可以告诉我如何解决这个错误吗?
这是我的代码
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api-m.sandbox.paypal.com/v1/billing/subscriptions');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\n \"plan_id\": \"P-97A61885CU957844JMFV\",\n \"start_time\": \"2021-10-19T00:00:00Z\",\n \"shipping_amount\": {\n \"currency_code\": \"USD\",\n \"custom_id\": \"xxxxdxxx\",\n \"value\": \"10.00\"\n },\n \"subscriber\": {\n \"name\": {\n \"given_name\": \"John\",\n \"surname\": \"Doe\"\n },\n \"email_address\": \"customer@example.com\",\n \"shipping_address\": {\n \"name\": {\n \"full_name\": \"John Doe\"\n },\n \"address\": {\n \"address_line_1\": \"2211 N First Street\",\n \"address_line_2\": \"Building 17\",\n \"admin_area_2\": \"San Jose\",\n \"admin_area_1\": \"CA\",\n \"postal_code\": \"95131\",\n \"country_code\": \"US\"\n }\n }\n },\n \"application_context\": {\n \"brand_name\": \"SAMPLEBRAND\",\n \"locale\": \"en-US\",\n \"shipping_preference\": \"SET_PROVIDED_ADDRESS\",\n \"user_action\": \"SUBSCRIBE_NOW\",\n \"payment_method\": {\n \"payer_selected\": \"PAYPAL\",\n \"payee_preferred\": \"IMMEDIATE_PAYMENT_REQUIRED\"\n },\n \"return_url\": \"https://sample.com/webhook_paypal.php\",\n \"cancel_url\": \"https://sample.com/webhook_paypal.php\"\n }\n}");
$headers = array();
$headers[] = 'Content-Type: application/json';
$headers[] = 'Authorization: Bearer '.$token;
$headers[] = 'Paypal-Request-Id: SUBSCRIPTION-21092019-001';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
echo $result;
【问题讨论】:
标签: paypal