访问以下链接以创建正式环境的订阅计划:
PayPal 正式环境
访问以下链接以创建沙盒环境的订阅计划:
PayPal 沙盒环境
在进入页面后,您可以创建产品及计划(请注意,沙盒环境的计划不会在此处显示)。
您可以根据流程创建产品及计划。
您也可以通过 API 创建产品及计划。
访问以下链接以获取 API 文档:
PayPal API 文档
首先,在您的 PayPal 账号中获取 clientId 和 Secret,然后获取 access_token。
请求地址:
沙盒: https://api.sandbox.paypal.com/v1/oauth2/token
正式: https://api.paypal.com/v1/oauth2/token
bash
curl -v -X POST https://api-m.sandbox.paypal.com/v1/catalogs/products
-H "Content-Type: application/json"
-H "Authorization: Bearer Access-Token"
-H "PayPal-Request-Id: PRODUCT-18062020-001"
-d '{
"name": "视频流服务",
"description": "视频流服务",
"type": "SERVICE",
"category": "SOFTWARE",
"image_url": "",
"home_url": "https://example.com/home"
}'
name: 产品名称
description: 产品说明
type: 产品类型(PHYSICAL: 实物商品;DIGITAL: 数码商品;SERVICE: 服务)
category: 产品类别
image_url: 产品 logo
home_url: 产品主站地址
bash
curl -v -X POST https://api-m.sandbox.paypal.com/v1/billing/plans
-H "Content-Type: application/json"
-H "Authorization: Bearer Access-Token"
-H "PayPal-Request-Id: PLAN-18062019-001"
-d '{
"product_id": "PROD-XXCD1234QWER65782",
"name": "视频流服务计划",
"description": "视频流服务基本计划",
"status": "ACTIVE",
"billing_cycles": [
{
"frequency": {
"interval_unit": "MONTH",
"interval_count": 1
},
"tenure_type": "REGULAR",
"sequence": 1,
"total_cycles": 12,
"pricing_scheme": {
"fixed_price": {
"value": "6",
"currency_code": "USD"
}
}
}
],
"payment_preferences": {
"auto_bill_outstanding": true,
"setup_fee": {
"value": "6",
"currency_code": "USD"
},
"setup_fee_failure_action": "CONTINUE",
"payment_failure_threshold": 3
},
"taxes": {
"percentage": "0",
"inclusive": false
}
}'
product_id: 产品 ID
name: 计划名称
description: 计划说明
status: 计划状态
billing_cycles: 计费周期
payment_preferences: 付款首选项
taxes: 税务信息
bash
curl -v -X POST https://api-m.sandbox.paypal.com/v1/billing/subscriptions
-H "Content-Type: application/json"
-H "Authorization: Bearer "
-H "PayPal-Request-Id: SUBSCRIPTION-21092019-001"
-d '{
"plan_id": "P-5ML4271244454362WXNWU5NQ",
"start_time": "2025-07-21T00:00:00Z",
"quantity": "20",
"shipping_amount": {
"currency_code": "USD",
"value": "10.00"
},
"application_context": {
"brand_name": "walmart",
"locale": "en-US",
"shipping_preference": "SET_PROVIDED_ADDRESS",
"user_action": "SUBSCRIBE_NOW",
"payment_method": {
"payer_selected": "PAYPAL",
"payee_preferred": "IMMEDIATE_PAYMENT_REQUIRED"
},
"return_url": "https://example.com/returnUrl",
"cancel_url": "https://example.com/cancelUrl"
}
}'
plan_id: 计划 ID
start_time: 第二次扣款时间(ISO8601 格式)
quantity: 订阅中的产品数量
shipping_amount: 交易的货币和金额
application_context: 应用上下文信息
bash
curl -v -X GET https://api-m.sandbox.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G
-H "Content-Type: application/json"
-H "Authorization: Bearer Access-Token"
此处选择的为个人选择。