Paypal API
  1. Plans
Paypal API
  • Authorization
    • Generate access_token
      POST
    • Terminate access_token
      POST
    • User Info
      GET
    • Generate client_token
      POST
  • Orders
    • Create order
      POST
    • Show order details
      GET
    • Update order
      PATCH
    • Authorize payment for order
      POST
    • Capture payment for order
      POST
  • Payments
    • Show details for authorized payment
      GET
    • Reauthorize authorized payment
      POST
    • Void authorized payment
      POST
    • Capture authorized payment
      POST
    • Show captured payment details
      GET
    • Refund captured payment
      POST
    • Show refund details
      GET
  • Invoices
    • Invoices
      • Generate invoice number
      • Create draft invoice
      • Show invoice details
      • List invoices
      • Generate QR code
      • Fully update invoice
      • Send invoice
      • Send invoice reminder
      • Cancel sent invoice
      • Delete invoice
      • Search for invoices
      • Record payment for invoice
      • Delete external payment
      • Record refund for invoice
      • Delete external refund
    • Templates
      • List templates
      • Create template
      • Show template details
      • Fully update template
      • Delete template
  • Subscriptions
    • Catalog Products
      • Create product
      • List products
      • Show product details
      • Update product
    • Plans
      • Create plan
        POST
      • List plans
        GET
      • Show plan details
        GET
      • Update plan
        PATCH
      • Deactivate plan
        POST
      • Activate plan
        POST
      • Update pricing
        POST
    • Subscriptions
      • Create subscription
      • Show subscription details
      • Update subscription
      • Revise plan or quantity of subscription
      • Suspend subscription
      • Activate subscription
      • Cancel subscription
      • Capture authorized payment on subscription
      • List transactions for subscription
  • Payouts
    • Create batch payout
    • Show payout batch details
    • Show payout item details
    • Cancel unclaimed payout item
  • Webhooks
    • List available events
    • Create webhook
    • List webhooks
    • Show webhook details
    • List event notifications
    • List event subscriptions for webhook
    • Show event notification details
    • Trigger a sample event
    • Verify webhook signature
    • Resend event notification
    • Simulate webhook event
    • Update webhook
    • Delete webhook
  • Shipment Tracking
    • Add tracking information for multiple PayPal transactions
    • Show tracking information
    • Update or cancel tracking information for PayPal transaction
  • Transaction Search
    • List transactions
    • List all balances
  • 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)
    • Manage Accounts
      • Create managed account
      • Search managed account through external id
      • Search managed account by Seller Id
      • Partially updates information for a managed account
      • Shows collection of registered wallet domains
  1. Plans

Create plan

POST
/v1/billing/plans
Creates a plan that defines pricing and billing cycle details for subscriptions.

请求参数

Authorization
在 Header 添加参数
Authorization
,其值为在 Basic 之后拼接空格,以及经过 Base64 编码的 username:password
示例:
Authorization: Basic *****************
Header 参数
Content-Type
string 
必需
The Content-Type header field is used to specify the nature of the data in the body of an entity. PayPal REST APIs support application/json.
示例值:
application/json
PayPal-Request-Id
string 
必需
The server stores keys for 72 hours.
示例值:
{{$guid}}
Prefer
string 
必需
The preferred server response upon successful completion of the request. Value is:
  • return=minimal. The server returns a minimal response to optimize communication between the API caller and the server. A minimal response includes the id, 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
上一页
Update product
下一页
List plans
Built with