- Authorization
- Orders
- Payments
- Invoices
- Subscriptions
- Catalog Products
- Plans
- Subscriptions
- Payouts
- Webhooks
- Shipment Tracking
- Transaction Search
- Disputes
- List disputes
- Show dispute details
- Accept claim
- Appeal dispute
- Settle dispute
- Update dispute status
- Make offer to resolve dispute
- Provide evidence
- Acknowledge returned item
- Provide supporting information for dispute
- Escalate dispute to claim
- Accept offer to resolve dispute
- Send message about dispute to other party
- Deny offer to resolve dispute
- Partially update dispute
- Onboarding (Limited Release)
Create plan
POST
/v1/billing/plans
请求参数
Authorization
在 Header 添加参数
Authorization
,其值为在 Basic 之后拼接空格,以及经过 Base64 编码的 username:password
示例:
Authorization: Basic *****************
Header 参数
Content-Type
string
必需
示例值:
application/json
PayPal-Request-Id
string
必需
示例值:
{{$guid}}
Prefer
string
必需
return=minimal
. The server returns a minimal response to optimize communication between the API caller and the server. A minimal response includes theid
,status
and HATEOAS links.return=representation
. The server returns a complete resource representation, including the current state of the resource.
示例值:
{{prefer_representation_detailed}}
Body 参数application/json
product_id
string
必需
name
string
必需
description
string
必需
status
string
必需
billing_cycles
array [object {5}]
必需
frequency
object
必需
tenure_type
string
必需
sequence
integer
必需
total_cycles
integer
必需
pricing_scheme
object
必需
payment_preferences
object
必需
auto_bill_outstanding
boolean
必需
setup_fee
object
必需
setup_fee_failure_action
string
必需
payment_failure_threshold
integer
必需
taxes
object
必需
percentage
string
必需
inclusive
boolean
必需
示例
{
"product_id": "{{product_id}}",
"name": "Fresh Clean Tees Plan",
"description": "Each shirt they send out to subscribers is designed with lots of attention to detail",
"status": "ACTIVE",
"billing_cycles": [
{
"frequency": {
"interval_unit": "MONTH",
"interval_count": 1
},
"tenure_type": "TRIAL",
"sequence": 1,
"total_cycles": 1,
"pricing_scheme": {
"fixed_price": {
"value": "1",
"currency_code": "USD"
}
}
},
{
"frequency": {
"interval_unit": "MONTH",
"interval_count": 1
},
"tenure_type": "REGULAR",
"sequence": 2,
"total_cycles": 12,
"pricing_scheme": {
"fixed_price": {
"value": "44",
"currency_code": "USD"
}
}
}
],
"payment_preferences": {
"auto_bill_outstanding": true,
"setup_fee": {
"value": "10",
"currency_code": "USD"
},
"setup_fee_failure_action": "CONTINUE",
"payment_failure_threshold": 3
},
"taxes": {
"percentage": "10",
"inclusive": false
}
}
示例代码
Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://api-m.sandbox.paypal.com/v1/billing/plans' \
--header 'PayPal-Request-Id: ' \
--header 'Prefer: ' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic Og==' \
--data-raw '{
"product_id": "{{product_id}}",
"name": "Fresh Clean Tees Plan",
"description": "Each shirt they send out to subscribers is designed with lots of attention to detail",
"status": "ACTIVE",
"billing_cycles": [
{
"frequency": {
"interval_unit": "MONTH",
"interval_count": 1
},
"tenure_type": "TRIAL",
"sequence": 1,
"total_cycles": 1,
"pricing_scheme": {
"fixed_price": {
"value": "1",
"currency_code": "USD"
}
}
},
{
"frequency": {
"interval_unit": "MONTH",
"interval_count": 1
},
"tenure_type": "REGULAR",
"sequence": 2,
"total_cycles": 12,
"pricing_scheme": {
"fixed_price": {
"value": "44",
"currency_code": "USD"
}
}
}
],
"payment_preferences": {
"auto_bill_outstanding": true,
"setup_fee": {
"value": "10",
"currency_code": "USD"
},
"setup_fee_failure_action": "CONTINUE",
"payment_failure_threshold": 3
},
"taxes": {
"percentage": "10",
"inclusive": false
}
}'
返回响应
🟢201201 - Create Plan With Minimal Request
application/json
Body
id
string
必需
product_id
string
必需
name
string
必需
status
string
必需
usage_type
string
必需
billing_cycles
array [object {5}]
必需
pricing_scheme
object
可选
frequency
object
可选
tenure_type
string
可选
sequence
integer
可选
total_cycles
integer
可选
payment_preferences
object
必需
service_type
string
必需
auto_bill_outstanding
boolean
必需
setup_fee
object
必需
setup_fee_failure_action
string
必需
payment_failure_threshold
integer
必需
quantity_supported
boolean
必需
create_time
string
必需
update_time
string
必需
links
array [object {4}]
必需
href
string
必需
rel
string
必需
method
string
必需
encType
string
必需
示例
{
"id": "P-9VG97050CC249134MMIBO43A",
"product_id": "1644357377",
"name": "Monthly Plan",
"status": "ACTIVE",
"usage_type": "LICENSED",
"billing_cycles": [
{
"pricing_scheme": {
"version": 1,
"fixed_price": {
"currency_code": "USD",
"value": "12.99"
},
"create_time": "2022-02-08T22:27:56Z",
"update_time": "2022-02-08T22:27:56Z"
},
"frequency": {
"interval_unit": "MONTH",
"interval_count": 1
},
"tenure_type": "REGULAR",
"sequence": 1,
"total_cycles": 1
}
],
"payment_preferences": {
"service_type": "PREPAID",
"auto_bill_outstanding": true,
"setup_fee": {
"currency_code": "USD",
"value": "0.0"
},
"setup_fee_failure_action": "CANCEL",
"payment_failure_threshold": 0
},
"quantity_supported": false,
"create_time": "2022-02-08T22:27:56Z",
"update_time": "2022-02-08T22:27:56Z",
"links": [
{
"href": "https://api.sandbox.paypal.com/v1/billing/plans/P-9VG97050CC249134MMIBO43A",
"rel": "self",
"method": "GET",
"encType": "application/json"
},
{
"href": "https://api.sandbox.paypal.com/v1/billing/plans/P-9VG97050CC249134MMIBO43A",
"rel": "edit",
"method": "PATCH",
"encType": "application/json"
},
{
"href": "https://api.sandbox.paypal.com/v1/billing/plans/P-9VG97050CC249134MMIBO43A/deactivate",
"rel": "self",
"method": "POST",
"encType": "application/json"
}
]
}
🟢201201 - Create Plan With Detailed Request
🟢201201 - Create Plan With Detailed Response
🟠401401 Unauthorized - Invalid Token
🟠404404 Not Found - Product Not Found
🟠422422 Unprocessable Entity - Fixed Price Not Supported
修改于 2023-08-16 07:18:59