贝宝沙箱 INVALID_RESOURCE_ID RESOURCE_NOT_FOUND

Paypal sandbox INVALID_RESOURCE_ID RESOURCE_NOT_FOUND

我在沙盒版本上 运行 时遇到资源未找到错误,但在实时 运行 时它可以找到。 有人可以告诉我如何解决错误吗?

这是我的代码

$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;

P-97A61885CU957844JMFV

使用适当的沙箱帐户为沙箱环境创建这样的计划 ID(和产品 ID),并改用这些沙箱 ID。您可以通过 https://www.sandbox.paypal.com/billing(使用沙盒帐户的凭据登录)或通过 API(使用沙盒帐户的客户端 ID 和密码)

执行此操作

实时计划 ID 永远不会在沙盒环境中创建订阅,也不会在实时环境中创建沙盒。两种环境完全不同。

在 developer.paypal.com 控制面板中管理您的 sandbox accounts and sandbox apps