paypal - Paypal 沙箱 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 和密码)进行操作
Live Plan ID 将永远无法在沙盒环境中创建订阅,也无法在实时环境中创建沙盒订阅。这两个环境是完全分开的。
推荐阅读
- machine-translation - Luong 注意和 Bahdanau。我们什么时候应该使用 Luong 或 Bahdanau?
- javascript - 将圆圈排列成行
- python-asyncio - 在 Aiohttp 应用程序中管理长时间运行的任务
- vbscript - 预期的语句结束。如何分配两个参数?
- javascript - 浏览器 - 防止显示自动完成框?
- c# - 如何从 YAML 数组切换到映射?
- angular - 如何从 div 中引用 ng-template?
- jenkins - 我可以从共享库中使用 jenkins post 步骤吗?
- java - 如何使用 Java 中的 math.random() 函数让计算机在我的 Connect4 游戏中选择随机列?
- mysql - 如何检测数据库断开连接,并使用 go-xorm 有效地重新连接 mysql、tiDB 等数据库?