【问题标题】:Paypal sandbox INVALID_RESOURCE_ID RESOURCE_NOT_FOUNDPaypal 沙箱 INVALID_RESOURCE_ID RESOURCE_NOT_FOUND
【发布时间】: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


    【解决方案1】:

    P-97A61885CU957844JMFV

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


    实时计划 ID 将永远无法在沙盒环境中创建订阅,也无法在实时环境中创建沙盒。这两个环境是完全独立的。

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

    【讨论】:

      猜你喜欢
      • 2020-07-17
      • 1970-01-01
      • 2010-12-19
      • 2012-11-09
      • 2020-06-17
      • 1970-01-01
      • 1970-01-01
      • 2013-05-17
      相关资源
      最近更新 更多