username:password
Authorization: Basic *****************
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.{
"plan_id": "{{billing_plan_id}}",
"start_time": "{{tomorrow}}",
"shipping_amount": {
"currency_code": "USD",
"value": "10.00"
},
"subscriber": {
"name": {
"given_name": "FooBuyer",
"surname": "Jones"
},
"email_address": "foobuyer@example.com",
"shipping_address": {
"name": {
"full_name": "John Doe"
},
"address": {
"address_line_1": "2211 N First Street",
"address_line_2": "Building 17",
"admin_area_2": "San Jose",
"admin_area_1": "CA",
"postal_code": "95131",
"country_code": "US"
}
}
},
"application_context": {
"brand_name": "Example Inc",
"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/return",
"cancel_url": "https://example.com/cancel"
}
}
curl --location --request POST 'https://api-m.sandbox.paypal.com/v1/billing/subscriptions' \
--header 'PayPal-Request-Id: ' \
--header 'Prefer: ' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic Og==' \
--data-raw '{
"plan_id": "{{billing_plan_id}}",
"start_time": "{{tomorrow}}",
"shipping_amount": {
"currency_code": "USD",
"value": "10.00"
},
"subscriber": {
"name": {
"given_name": "FooBuyer",
"surname": "Jones"
},
"email_address": "foobuyer@example.com",
"shipping_address": {
"name": {
"full_name": "John Doe"
},
"address": {
"address_line_1": "2211 N First Street",
"address_line_2": "Building 17",
"admin_area_2": "San Jose",
"admin_area_1": "CA",
"postal_code": "95131",
"country_code": "US"
}
}
},
"application_context": {
"brand_name": "Example Inc",
"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/return",
"cancel_url": "https://example.com/cancel"
}
}'
{
"status": "APPROVAL_PENDING",
"status_update_time": "2023-04-10T16:57:03Z",
"id": "I-3K9N0AULDABT",
"plan_id": "P-3U540844AX2546419MQYHLVQ",
"start_time": "2023-04-10T16:57:03Z",
"quantity": "1",
"subscriber": {},
"create_time": "2023-04-10T16:57:03Z",
"plan_overridden": false,
"links": [
{
"href": "https://www.sandbox.paypal.com/webapps/billing/subscriptions?ba_token=BA-6NS85567LW887234V",
"rel": "approve",
"method": "GET"
},
{
"href": "https://api-m.sandbox.paypal.com/v1/billing/subscriptions/I-3K9N0AULDABT",
"rel": "edit",
"method": "PATCH"
},
{
"href": "https://api-m.sandbox.paypal.com/v1/billing/subscriptions/I-3K9N0AULDABT",
"rel": "self",
"method": "GET"
}
]
}