paypal.subscriptions
Module paypal.subscriptions
API
Definitions

ballerinax/paypal.subscriptions Ballerina library
Overview
PayPal is a global online payment platform enabling individuals and businesses to securely send and receive money, process transactions, and access merchant services across multiple currencies.
The ballerinax/paypal.subscriptions
package provides a Ballerina connector for interacting with the PayPal Subscriptions API v1, allowing you to create, manage, and monitor subscription-based billing plans and subscriptions in your Ballerina applications.
Setup Guide
To use the PayPal Subscriptions connector, you must have access to a PayPal Developer account.
Step 1: Create a business account
-
Open the PayPal Developer Dashboard.
-
Create a business account.
Note: Some PayPal options and features may vary by region or country; check availability before creating an account.
Step 2: Create a REST API app
- Navigate to the "Apps and Credentials" tab and create a new merchant app.
- Provide a name for the application and select the Business account created earlier.
Step 3: Obtain Client ID and Client Secret
-
After creating the app, you will see your Client ID and Client Secret. Copy and securely store these credentials.
Quickstart
To use the paypal.subscriptions
connector in your Ballerina application, update the .bal
file as follows:
Step 1: Import the module
Import the paypal.subscriptions
module.
import ballerinax/paypal.subscriptions as paypal;
Step 2: Instantiate a new connector
-
Create a
Config.toml
file and configure the obtained credentials and URLs:clientId = "<your-client-id>" clientSecret = "<your-client-secret>" serviceUrl = "<paypal-service-url>" tokenUrl = "<paypal-token-url>"
-
Create a
paypal:ConnectionConfig
with the credentials and initialize the connector:configurable string clientId = ?; configurable string clientSecret = ?; configurable string serviceUrl = ?; configurable string tokenUrl = ?; final paypal:Client paypal = check new ({ auth: { clientId, clientSecret, tokenUrl } }, serviceUrl);
Step 3: Invoke a connector operation
Create a subscription plan
public function main() returns error? { paypal:PlanRequestPOST plan = { product_id: "PROD-1234567890", name: "Basic Subscription Plan", status: "ACTIVE", billing_cycles: [ { frequency: { interval_unit: "MONTH", interval_count: 1 }, tenure_type: "REGULAR", sequence: 1, total_cycles: 0, pricing_scheme: { fixed_price: { value: "10.00", currency_code: "USD" } } } ], payment_preferences: { auto_bill_outstanding: true, setup_fee: { value: "0.00", currency_code: "USD" }, setup_fee_failure_action: "CONTINUE", payment_failure_threshold: 3 } }; paypal:Plan response = check paypal->/plans.post(plan); }
Step 4: Run the Ballerina application
bal run
Examples
The PayPal Subscriptions
connector provides practical examples illustrating usage in various scenarios. Explore these examples, covering the following use cases:
- Create and List Plans: Create a subscription plan and list all available plans.
- Monitor and Manage Subscription Status: Retrieve a subscription’s status and suspend or reactivate it based on its state.
- Manage Premium Subscription: Create a subscription plan, enroll a customer, and retrieve subscription details for a premium membership.
Clients
paypal.subscriptions: Client
You can use billing plans and subscriptions to create subscriptions that process recurring PayPal payments for physical or digital goods, or services. A plan includes pricing and billing cycle information that defines the amount and frequency of charge for a subscription. You can also define a fixed plan, such as a $5 basic plan or a volume- or graduated-based plan with pricing tiers based on the quantity purchased. For more information, see Subscriptions Overview.
Constructor
Gets invoked to initialize the connector
.
init (ConnectionConfig config, string serviceUrl)
- config ConnectionConfig - The configurations to be used when initializing the
connector
- serviceUrl string "https://api-m.sandbox.paypal.com/v1/billing" - URL of the target service
get plans
function get plans(PlansListHeaders headers, *PlansListQueries queries) returns PlanCollection|error
List plans
Parameters
- headers PlansListHeaders (default {}) - Headers to be sent with the request
- queries *PlansListQueries - Queries to be sent with the request
Return Type
- PlanCollection|error - A successful request returns the HTTP
200 OK
status code and a JSON response body that lists billing plans
post plans
function post plans(PlanRequestPOST payload, PlansCreateHeaders headers) returns Plan|error
Create plan
Parameters
- payload PlanRequestPOST -
- headers PlansCreateHeaders (default {}) - Headers to be sent with the request
Return Type
get plans/[string id]
Show plan details
Return Type
patch plans/[string id]
function patch plans/[string id](PatchRequest payload, map<string|string[]> headers) returns error?
Update plan
Parameters
- payload PatchRequest -
Return Type
- error? - A successful request returns the HTTP
204 No Content
status code with no JSON response body
post plans/[string id]/activate
Activate plan
Return Type
- error? - A successful request returns the HTTP
204 No Content
status code with no JSON response body
post plans/[string id]/deactivate
Deactivate plan
Return Type
- error? - A successful request returns the HTTP
204 No Content
status code with no JSON response body
post plans/[string id]/update-pricing-schemes
function post plans/[string id]/update\-pricing\-schemes(UpdatePricingSchemesListRequest payload, map<string|string[]> headers) returns error?
Update pricing
Parameters
- payload UpdatePricingSchemesListRequest -
Return Type
- error? - A successful request returns the HTTP
204 No Content
status code with no JSON response body
post subscriptions
function post subscriptions(SubscriptionRequestPost payload, SubscriptionsCreateHeaders headers) returns Subscription|error
Create subscription
Parameters
- payload SubscriptionRequestPost -
- headers SubscriptionsCreateHeaders (default {}) - Headers to be sent with the request
Return Type
- Subscription|error - A successful request returns the HTTP
200 OK
status code and a JSON response body that shows subscription details
get subscriptions/[string id]
function get subscriptions/[string id](map<string|string[]> headers, *SubscriptionsGetQueries queries) returns Subscription|error
Show subscription details
Parameters
- queries *SubscriptionsGetQueries - Queries to be sent with the request
Return Type
- Subscription|error - A successful request returns the HTTP
200 OK
status code and a JSON response body that shows subscription details
patch subscriptions/[string id]
function patch subscriptions/[string id](PatchRequest payload, map<string|string[]> headers) returns error?
Update subscription
Parameters
- payload PatchRequest -
Return Type
- error? - A successful request returns the HTTP
204 No Content
status code with no JSON response body
post subscriptions/[string id]/revise
function post subscriptions/[string id]/revise(SubscriptionReviseRequest payload, map<string|string[]> headers) returns SubscriptionReviseResponse|error
Revise plan or quantity of subscription
Parameters
- payload SubscriptionReviseRequest -
Return Type
- SubscriptionReviseResponse|error - A successful request returns the HTTP
200 OK
status code and a JSON response body that shows subscription details
post subscriptions/[string id]/suspend
function post subscriptions/[string id]/suspend(SubscriptionSuspendRequest payload, map<string|string[]> headers) returns error?
Suspend subscription
Parameters
- payload SubscriptionSuspendRequest -
Return Type
- error? - A successful request returns the HTTP
204 No Content
status code with no JSON response body
post subscriptions/[string id]/cancel
function post subscriptions/[string id]/cancel(SubscriptionCancelRequest payload, map<string|string[]> headers) returns error?
Cancel subscription
Parameters
- payload SubscriptionCancelRequest -
Return Type
- error? - A successful request returns the HTTP
204 No Content
status code with no JSON response body
post subscriptions/[string id]/activate
function post subscriptions/[string id]/activate(SubscriptionActivateRequest payload, map<string|string[]> headers) returns error?
Activate subscription
Parameters
- payload SubscriptionActivateRequest -
Return Type
- error? - A successful request returns the HTTP
204 No Content
status code with no JSON response body
post subscriptions/[string id]/capture
function post subscriptions/[string id]/capture(SubscriptionCaptureRequest payload, SubscriptionsCaptureHeaders headers) returns Transaction|error?
Capture authorized payment on subscription
Parameters
- payload SubscriptionCaptureRequest -
- headers SubscriptionsCaptureHeaders (default {}) - Headers to be sent with the request
Return Type
- Transaction|error? - A successful request returns the HTTP
200 OK
status code and a JSON response body that shows subscription details
get subscriptions/[string id]/transactions
function get subscriptions/[string id]/transactions(map<string|string[]> headers, *SubscriptionsTransactionsQueries queries) returns TransactionsList|error
List transactions for subscription
Parameters
- queries *SubscriptionsTransactionsQueries - Queries to be sent with the request
Return Type
- TransactionsList|error - A successful request returns the HTTP
200 OK
status code and a JSON response body that shows subscription details
Records
paypal.subscriptions: AddressDetails
The non-portable additional address details that are sometimes needed for compliance, risk, or other scenarios where fine-grain address information might be needed. Not portable with common third party and open source. Redundant with core fields.
For example, address_portable.address_line_1
is usually a combination of address_details.street_number
, street_name
, and street_type
Fields
- building_name? string - A named locations that represents the premise. Usually a building name or number or collection of buildings with a common name or number. For example, <code>Craven House</code>
- street_number? string - The street number
- street_type? string - The street type. For example, avenue, boulevard, road, or expressway
- sub_building? string - The first-order entity below a named building or location that represents the sub-premises. Usually a single building within a collection of buildings with a common name. Can be a flat, story, floor, room, or apartment
- delivery_service? string - The delivery service. Post office box, bag number, or post office name
- street_name? string - The street name. Just
Drury
inDrury Lane
paypal.subscriptions: AddressPortable
The portable international postal address. Maps to AddressValidationMetadata and HTML 5.1 Autofilling form controls: the autocomplete attribute
Fields
- country_code CountryCode -
- admin_area_1? string - The highest level sub-division in a country, which is usually a province, state, or ISO-3166-2 subdivision. Format for postal delivery. For example,
CA
and notCalifornia
. Value, by country, is:<ul><li>UK. A county.</li><li>US. A state.</li><li>Canada. A province.</li><li>Japan. A prefecture.</li><li>Switzerland. A kanton.</li></ul>
- address_line_1? string - The first line of the address. For example, number or street. For example,
173 Drury Lane
. Required for data entry and compliance and risk checks. Must contain the full address
- admin_area_3? string - A sub-locality, suburb, neighborhood, or district. Smaller than
admin_area_level_2
. Value is:<ul><li>Brazil. Suburb, bairro, or neighborhood.</li><li>India. Sub-locality or district. Street name information is not always available but a sub-locality or district can be a very small area.</li></ul>
- address_details? AddressDetails -
- admin_area_2? string - A city, town, or village. Smaller than
admin_area_level_1
- address_line_3? string - The third line of the address, if needed. For example, a street complement for Brazil, direction text, such as
next to Walmart
, or a landmark in an Indian address
- address_line_2? string - The second line of the address. For example, suite or apartment number
- admin_area_4? string - The neighborhood, ward, or district. Smaller than
admin_area_level_3
orsub_locality
. Value is:<ul><li>The postal sorting code for Guernsey and many French territories, such as French Guiana.</li><li>The fine-grained administrative levels in China.</li></ul>
- postal_code? string - The postal code, which is the zip code or equivalent. Typically required for countries with a postal code or an equivalent. See postal code
paypal.subscriptions: AmountWithBreakdown
The breakdown details for the amount. Includes the gross, tax, fee, and shipping amounts
Fields
- shipping_amount? Money -
- tax_amount? Money -
- fee_amount? Money -
- total_item_amount? Money -
- gross_amount Money -
- net_amount? Money -
paypal.subscriptions: ApplicationContext
The application context, which customizes the payer experience during the subscription approval process with PayPal
Fields
- user_action "CONTINUE"|"SUBSCRIBE_NOW" (default "SUBSCRIBE_NOW") - Configures the label name to
Continue
orSubscribe Now
for subscription consent experience
- return_url string - The URL where the customer is redirected after the customer approves the payment
- brand_name? string - The label that overrides the business name in the PayPal account on the PayPal site
- locale? Language - The language tag for the language in which to localize the error-related strings, such as messages, issues, and suggested actions. The tag is made up of the ISO 639-2 language code, the optional ISO-15924 script tag, and the ISO-3166 alpha-2 country code
- cancel_url string - The URL where the customer is redirected after the customer cancels the payment
- shipping_preference "GET_FROM_FILE"|"NO_SHIPPING"|"SET_PROVIDED_ADDRESS" (default "GET_FROM_FILE") - The location from which the shipping address is derived
- payment_method? PaymentMethod -
paypal.subscriptions: AuthenticationResponse
Results of Authentication such as 3D Secure
Fields
- liability_shift? LiabilityShift -
- three_d_secure? ThreeDSecureAuthenticationResponse -
paypal.subscriptions: BillingCycle
The billing cycle details
Fields
- sequence int - The order in which this cycle is to run among other billing cycles. For example, a trial billing cycle has a
sequence
of1
while a regular billing cycle has asequence
of2
, so that trial cycle runs before the regular cycle
- tenure_type "REGULAR"|"TRIAL" - The tenure type of the billing cycle. In case of a plan having trial cycle, only 2 trial cycles are allowed per plan
- total_cycles int(default 1) - The number of times this billing cycle gets executed. Trial billing cycles can only be executed a finite number of times (value between <code>1</code> and <code>999</code> for <code>total_cycles</code>). Regular billing cycles can be executed infinite times (value of <code>0</code> for <code>total_cycles</code>) or a finite number of times (value between <code>1</code> and <code>999</code> for <code>total_cycles</code>)
- pricing_scheme? PricingScheme -
- frequency Frequency - The frequency of the billing cycle
paypal.subscriptions: BillingCycleOverride
The billing cycle details to override at subscription level. The subscription billing cycle definition has to adhere to the plan billing cycle definition
Fields
- sequence int - The order in which this cycle is to run among other billing cycles. For example, a trial billing cycle has a
sequence
of1
while a regular billing cycle has asequence
of2
, so that trial cycle runs before the regular cycle
- total_cycles? int - The number of times this billing cycle gets executed. Trial billing cycles can only be executed a finite number of times (value between <code>1</code> and <code>999</code> for <code>total_cycles</code>). Regular billing cycles can be executed infinite times (value of <code>0</code> for <code>total_cycles</code>) or a finite number of times (value between <code>1</code> and <code>999</code> for <code>total_cycles</code>)
- pricing_scheme? PricingScheme -
paypal.subscriptions: CaptureStatus
The status of a captured payment
Fields
- status_details? CaptureStatusDetails -
- status? "COMPLETED"|"DECLINED"|"PARTIALLY_REFUNDED"|"PENDING"|"REFUNDED" - The status of the captured payment
paypal.subscriptions: CaptureStatusDetails
The details of the captured payment status
Fields
- reason? "BUYER_COMPLAINT"|"CHARGEBACK"|"ECHECK"|"INTERNATIONAL_WITHDRAWAL"|"OTHER"|"PENDING_REVIEW"|"RECEIVING_PREFERENCE_MANDATES_MANUAL_ACTION"|"REFUNDED"|"TRANSACTION_APPROVED_AWAITING_FUNDING"|"UNILATERAL"|"VERIFICATION_REQUIRED" - The reason why the captured payment status is
PENDING
orDENIED
paypal.subscriptions: Card
The payment card to use to fund a payment. Can be a credit or debit card
Fields
- number string - The primary account number (PAN) for the payment card
- security_code? string - The three- or four-digit security code of the card. Also known as the CVV, CVC, CVN, CVE, or CID. This parameter cannot be present in the request when
payment_initiator=MERCHANT
- name? string - The card holder's name as it appears on the card
- billing_address? AddressPortable -
- id? string - The PayPal-generated ID for the card
- expiry DateYearMonth - The year and month, in ISO-8601
YYYY-MM
date format. See Internet date and time format
- card_type? CardBrand -
- last_digits? string - The last digits of the payment card
paypal.subscriptions: CardResponse
The payment card to use to fund a payment. Card can be a credit or debit card
Fields
- authentication_result? AuthenticationResponse -
- 'type? "CREDIT"|"DEBIT"|"PREPAID"|"UNKNOWN" - The payment card type
- last_digits? string - The last digits of the payment card
- brand? CardBrand - The card network or brand. Applies to credit, debit, gift, and payment cards
paypal.subscriptions: CardResponseWithBillingAddress
The payment card used to fund the payment. Card can be a credit or debit card
Fields
- Fields Included from *CardResponse
- authentication_result AuthenticationResponse
- type "CREDIT"|"DEBIT"|"PREPAID"|"UNKNOWN"
- last_digits string
- brand CardBrand
- anydata...
- Fields Included from *CardResponseWithBillingAddressAllOf2
- name string
- billing_address AddressPortable
- expiry DateYearMonth
- currency_code CurrencyCode
- anydata...
paypal.subscriptions: CardResponseWithBillingAddressAllOf2
Fields
- name? string - The card holder's name as it appears on the card.
- billing_address? AddressPortable - The portable international postal address. Maps to AddressValidationMetadata and HTML 5.1 Autofilling form controls: the autocomplete attribute
- expiry? DateYearMonth - The year and month, in ISO-8601
YYYY-MM
date format. See Internet date and time format
- currency_code? CurrencyCode - The three-character ISO-4217 currency code that identifies the currency
paypal.subscriptions: ConnectionConfig
Provides a set of configurations for controlling the behaviours when communicating with a remote HTTP endpoint.
Fields
- auth OAuth2ClientCredentialsGrantConfig - Configurations related to client authentication
- httpVersion HttpVersion(default http:HTTP_2_0) - The HTTP version understood by the client
- http1Settings ClientHttp1Settings(default {}) - Configurations related to HTTP/1.x protocol
- http2Settings ClientHttp2Settings(default {}) - Configurations related to HTTP/2 protocol
- timeout decimal(default 30) - The maximum time to wait (in seconds) for a response before closing the connection
- forwarded string(default "disable") - The choice of setting
forwarded
/x-forwarded
header
- followRedirects? FollowRedirects - Configurations associated with Redirection
- poolConfig? PoolConfiguration - Configurations associated with request pooling
- cache CacheConfig(default {}) - HTTP caching related configurations
- compression Compression(default http:COMPRESSION_AUTO) - Specifies the way of handling compression (
accept-encoding
) header
- circuitBreaker? CircuitBreakerConfig - Configurations associated with the behaviour of the Circuit Breaker
- retryConfig? RetryConfig - Configurations associated with retrying
- cookieConfig? CookieConfig - Configurations associated with cookies
- responseLimits ResponseLimitConfigs(default {}) - Configurations associated with inbound response size limits
- secureSocket? ClientSecureSocket - SSL/TLS-related options
- proxy? ProxyConfig - Proxy server related options
- socketConfig ClientSocketConfig(default {}) - Provides settings related to client socket configuration
- validation boolean(default true) - Enables the inbound payload validation functionality which provided by the constraint package. Enabled by default
- laxDataBinding boolean(default true) - Enables relaxed data binding on the client side. When enabled,
nil
values are treated as optional, and absent fields are handled asnilable
types. Enabled by default.
paypal.subscriptions: CycleExecution
The regular and trial execution details for a billing cycle
Fields
- sequence int - The order in which to run this cycle among other billing cycles
- cycles_remaining? int - For a finite billing cycle, cycles_remaining is the number of remaining cycles. For an infinite billing cycle, cycles_remaining is set as 0
- tenure_type "REGULAR"|"TRIAL" - The type of the billing cycle
- cycles_completed int - The number of billing cycles that have completed
- current_pricing_scheme_version? int - The active pricing scheme version for the billing cycle
- total_cycles? int - The number of times this billing cycle gets executed. Trial billing cycles can only be executed a finite number of times (value between <code>1</code> and <code>999</code> for <code>total_cycles</code>). Regular billing cycles can be executed infinite times (value of <code>0</code> for <code>total_cycles</code>) or a finite number of times (value between <code>1</code> and <code>999</code> for <code>total_cycles</code>)
paypal.subscriptions: FailedPaymentDetails
The details for the failed payment of the subscription
Fields
- reason_code? "PAYMENT_DENIED"|"INTERNAL_SERVER_ERROR"|"PAYEE_ACCOUNT_RESTRICTED"|"PAYER_ACCOUNT_RESTRICTED"|"PAYER_CANNOT_PAY"|"SENDING_LIMIT_EXCEEDED"|"TRANSACTION_RECEIVING_LIMIT_EXCEEDED"|"CURRENCY_MISMATCH" - The reason code for the payment failure
- amount Money - The currency and amount for a financial transaction, such as a balance or payment due
- next_payment_retry_time? DateTime -
- time DateTime - The date and time, in Internet date and time format. Seconds are required while fractional seconds are optional.<blockquote><strong>Note:</strong> The regular expression provides guidance but does not reject all invalid dates.</blockquote>
paypal.subscriptions: Frequency
The frequency of the billing cycle
Fields
- interval_count int(default 1) - The number of intervals after which a subscriber is billed. For example, if the
interval_unit
isDAY
with aninterval_count
of2
, the subscription is billed once every two days. The following table lists the maximum allowed values for theinterval_count
for eachinterval_unit
:<table><thead><tr><th><code>Interval unit</code></th><th>Maximum interval count</th></tr></thead><tbody><tr><td><code>DAY</code></td><td align="right">365</td></tr><tr><td><code>WEEK</code></td><td align="right">52</td></tr><tr><td><code>MONTH</code></td><td align="right">12</td></tr><tr><td><code>YEAR</code></td><td align="right">1</td></tr></tbody></table>
- interval_unit "DAY"|"WEEK"|"MONTH"|"YEAR" - The interval at which the subscription is charged or billed
paypal.subscriptions: LastPaymentDetailsAllOf1
Fields
- amount? Money - The currency and amount for a financial transaction, such as a balance or payment due
- time? DateTime - The date and time, in Internet date and time format. Seconds are required while fractional seconds are optional.<blockquote><strong>Note:</strong> The regular expression provides guidance but does not reject all invalid dates.</blockquote>
paypal.subscriptions: LinkDescription
The request-related HATEOAS link information
Fields
- method? "GET"|"POST"|"PUT"|"DELETE"|"HEAD"|"CONNECT"|"OPTIONS"|"PATCH" - The HTTP method required to make the related call
- rel string - The link relation type, which serves as an ID for a link that unambiguously describes the semantics of the link. See Link Relations
- href string - The complete target URL. To make the related call, combine the method with this URI Template-formatted link. For pre-processing, include the
$
,(
, and)
characters. Thehref
is the key HATEOAS component that links a completed call with a subsequent call
paypal.subscriptions: Money
The currency and amount for a financial transaction, such as a balance or payment due
Fields
- value string - The value, which might be:<ul><li>An integer for currencies like
JPY
that are not typically fractional.</li><li>A decimal fraction for currencies likeTND
that are subdivided into thousandths.</li></ul>For the required number of decimal places for a currency code, see Currency Codes
- currency_code CurrencyCode -
paypal.subscriptions: Name
The name of the party
Fields
- full_name? string - When the party is a person, the party's full name
- prefix? string - The prefix, or title, to the party's name
- surname? string - When the party is a person, the party's surname or family name. Also known as the last name. Required when the party is a person. Use also to store multiple surnames including the matronymic, or mother's, surname
- given_name? string - When the party is a person, the party's given, or first, name
- middle_name? string - When the party is a person, the party's middle name. Use also to store multiple middle names including the patronymic, or father's, middle name
- suffix? string - The suffix for the party's name
- alternate_full_name? string - DEPRECATED. The party's alternate name. Can be a business name, nickname, or any other name that cannot be split into first, last name. Required when the party is a business
paypal.subscriptions: OAuth2ClientCredentialsGrantConfig
OAuth2 Client Credentials Grant Configs
Fields
- tokenUrl string(default "https://api-m.sandbox.paypal.com/v1/oauth2/token") - Token URL
paypal.subscriptions: Patch
The JSON patch object to apply partial updates to resources
Fields
- op "add"|"remove"|"replace"|"move"|"copy"|"test" - The operation
- path? string - The <a href="https://tools.ietf.org/html/rfc6901">JSON Pointer</a> to the target document location at which to complete the operation
- 'from? string - The <a href="https://tools.ietf.org/html/rfc6901">JSON Pointer</a> to the target document location from which to move the value. Required for the <code>move</code> operation
- value? anydata - The value to apply. The <code>remove</code> operation does not require a value
paypal.subscriptions: Payer
The customer who approves and pays for the order. The customer is also known as the payer
Fields
- Fields Included from *PayerBase
- Fields Included from *PayerAllOf2
- name Name
- phone PhoneWithType
- birth_date DateNoTime
- tax_info TaxInfo
- address AddressPortable
- anydata...
paypal.subscriptions: PayerAllOf2
Fields
- name? Name - The name of the party
- phone? PhoneWithType - The phone information
- birth_date? DateNoTime - The stand-alone date, in Internet date and time format. To represent special legal values, such as a date of birth, you should use dates with no associated time or time-zone data. Whenever possible, use the standard
date_time
type. This regular expression does not validate all dates. For example, February 31 is valid and nothing is known about leap years
- tax_info? TaxInfo - The tax ID of the customer. The customer is also known as the payer. Both
tax_id
andtax_id_type
are required
- address? AddressPortable - The portable international postal address. Maps to AddressValidationMetadata and HTML 5.1 Autofilling form controls: the autocomplete attribute
paypal.subscriptions: PayerBase
The customer who approves and pays for the order. The customer is also known as the payer
Fields
- email_address? Email -
- payer_id? AccountId -
paypal.subscriptions: PaymentMethod
The customer and merchant payment preferences
Fields
- payer_selected string(default "PAYPAL") - The customer-selected payment method on the merchant site
- payee_preferred? PayeePaymentMethodPreference -
- standard_entry_class_code "TEL"|"WEB"|"CCD"|"PPD" (default "WEB") - NACHA (the regulatory body governing the ACH network) requires that API callers (merchants, partners) obtain the consumer’s explicit authorization before initiating a transaction. To stay compliant, you’ll need to make sure that you retain a compliant authorization for each transaction that you originate to the ACH Network using this API. ACH transactions are categorized (using SEC codes) by how you capture authorization from the Receiver (the person whose bank account is being debited or credited). PayPal supports the following SEC codes
paypal.subscriptions: PaymentPreferences
The payment preferences for a subscription
Fields
- setup_fee? Money -
- setup_fee_failure_action "CONTINUE"|"CANCEL" (default "CANCEL") - The action to take on the subscription if the initial payment for the setup fails
- auto_bill_outstanding boolean(default true) - Indicates whether to automatically bill the outstanding amount in the next billing cycle
- payment_failure_threshold int(default 0) - The maximum number of payment failures before a subscription is suspended. For example, if
payment_failure_threshold
is2
, the subscription automatically updates to theSUSPEND
state if two consecutive payments fail
paypal.subscriptions: PaymentPreferencesOverride
The payment preferences to override at subscription level
Fields
- setup_fee? Money -
- setup_fee_failure_action? "CONTINUE"|"CANCEL" - The action to take on the subscription if the initial payment for the setup fails
- auto_bill_outstanding? boolean - Indicates whether to automatically bill the outstanding amount in the next billing cycle
- payment_failure_threshold? int - The maximum number of payment failures before a subscription is suspended. For example, if
payment_failure_threshold
is2
, the subscription automatically updates to theSUSPEND
state if two consecutive payments fail
paypal.subscriptions: PaymentSource
The payment source definition. To be eligible to create subscription using debit or credit card, you will need to sign up here (https://www.paypal.com/bizsignup/entry/product/ppcp). Please note, its available only for non-3DS cards and for merchants in US and AU regions
Fields
- card? Card - The payment card to use to fund a payment. Can be a credit or debit card
paypal.subscriptions: PaymentSourceResponse
The payment source used to fund the payment
Fields
- card? CardResponseWithBillingAddress - The payment card used to fund the payment. Card can be a credit or debit card
paypal.subscriptions: Phone
The phone number, in its canonical international E.164 numbering plan format
Fields
- country_code string - The country calling code (CC), in its canonical international E.164 numbering plan format. The combined length of the CC and the national number must not be greater than 15 digits. The national number consists of a national destination code (NDC) and subscriber number (SN)
- extension_number? string - The extension number
- national_number string - The national number, in its canonical international E.164 numbering plan format. The combined length of the country calling code (CC) and the national number must not be greater than 15 digits. The national number consists of a national destination code (NDC) and subscriber number (SN)
paypal.subscriptions: PhoneWithType
The phone information
Fields
- phone_type? PhoneType -
- phone_number Phone -
paypal.subscriptions: Plan
The plan details
Fields
- quantity_supported boolean(default false) - Indicates whether you can subscribe to this plan by providing a quantity for the goods or service
- update_time? DateTime -
- create_time? DateTime -
- payment_preferences? PaymentPreferences -
- product_id? string - The ID for the product
- name? string - The plan name
- billing_cycles? BillingCycle[] - An array of billing cycles for trial billing and regular billing. A plan can have at most two trial cycles and only one regular cycle
- description? string - The detailed description of the plan
- taxes? Taxes - The tax details
- links? LinkDescription[] - An array of request-related HATEOAS links
- id? string - The unique PayPal-generated ID for the plan
- status? "CREATED"|"INACTIVE"|"ACTIVE" - The plan status
paypal.subscriptions: PlanCollection
The list of plans with details
Fields
- plans? Plan[] - An array of plans
- links? LinkDescription[] - An array of request-related HATEOAS links
- total_pages? int - The total number of pages
- total_items? int - The total number of items
paypal.subscriptions: PlanOverride
An inline plan object to customise the subscription. You can override plan level default attributes by providing customised values for the subscription in this object
Fields
- payment_preferences? PaymentPreferencesOverride -
- billing_cycles? BillingCycleOverride[] - An array of billing cycles for trial billing and regular billing. The subscription billing cycle definition has to adhere to the plan billing cycle definition
- taxes? TaxesOverride - The tax details
paypal.subscriptions: PlanRequestPOST
The create plan request details
Fields
- quantity_supported boolean(default false) - Indicates whether you can subscribe to this plan by providing a quantity for the goods or service
- payment_preferences PaymentPreferences -
- product_id string - The ID of the product created through Catalog Products API
- name string - The plan name
- billing_cycles BillingCycle[] - An array of billing cycles for trial billing and regular billing. A plan can have at most two trial cycles and only one regular cycle
- description? string - The detailed description of the plan
- taxes? Taxes - The tax details
- status "CREATED"|"INACTIVE"|"ACTIVE" (default "ACTIVE") - The initial state of the plan. Allowed input values are CREATED and ACTIVE
paypal.subscriptions: PlansCreateHeaders
Represents the Headers record for the operation: plans.create
Fields
- PayPal\-Request\-Id? string - The server stores keys for 72 hours
- Prefer string(default "return=minimal") - The preferred server response upon successful completion of the request. Value is:<ul><li><code>return=minimal</code>. The server returns a minimal response to optimize communication between the API caller and the server. A minimal response includes the <code>id</code>, <code>status</code> and HATEOAS links.</li><li><code>return=representation</code>. The server returns a complete resource representation, including the current state of the resource.</li></ul>
paypal.subscriptions: PlansListHeaders
Represents the Headers record for the operation: plans.list
Fields
- Prefer string(default "return=minimal") - The preferred server response upon successful completion of the request. Value is:<ul><li><code>return=minimal</code>. The server returns a minimal response to optimize communication between the API caller and the server. A minimal response includes the <code>id</code>, <code>status</code> and HATEOAS links.</li><li><code>return=representation</code>. The server returns a complete resource representation, including the current state of the resource.</li></ul>
paypal.subscriptions: PlansListQueries
Represents the Queries record for the operation: plans.list
Fields
- product_id? string - Filters the response by a Product ID
- plan_ids? string - Filters the response by list of plan IDs. Filter supports upto 10 plan IDs
- page int(default 1) - A non-zero integer which is the start index of the entire list of items to return in the response. The combination of
page=1
andpage_size=20
returns the first 20 items. The combination ofpage=2
andpage_size=20
returns the next 20 items
- total_required boolean(default false) - Indicates whether to show the total count in the response
- page_size int(default 10) - The number of items to return in the response
paypal.subscriptions: PricingScheme
The pricing scheme details
Fields
- tiers? PricingTier[] - An array of pricing tiers which are used for billing volume/tiered plans. pricing_model field has to be specified
- update_time? DateTime -
- create_time? DateTime -
- pricing_model? "VOLUME"|"TIERED" - The pricing model for tiered plan. The
tiers
parameter is required
- fixed_price? Money -
- version? int - The version of the pricing scheme
paypal.subscriptions: PricingTier
The pricing tier details
Fields
- starting_quantity string - The starting quantity for the tier
- amount Money - The currency and amount for a financial transaction, such as a balance or payment due
- ending_quantity? string - The ending quantity for the tier. Optional for the last tier
paypal.subscriptions: ShippingDetail
The shipping details
Fields
- address? AddressPortable - The portable international postal address. Maps to AddressValidationMetadata and HTML 5.1 Autofilling form controls: the autocomplete attribute
- name? Name - The name of the party
- 'type? "SHIPPING"|"PICKUP_IN_PERSON" - The method by which the payer wants to get their items from the payee e.g shipping, in-person pickup. Either type or options but not both may be present
paypal.subscriptions: Subscriber
The subscriber response information
Fields
- Fields Included from *Payer
- email_address Email
- payer_id AccountId
- name Name
- phone PhoneWithType
- birth_date DateNoTime
- tax_info TaxInfo
- address AddressPortable
- anydata...
- Fields Included from *SubscriberAllOf2
- shipping_address ShippingDetail
- payment_source PaymentSourceResponse
- anydata...
paypal.subscriptions: SubscriberAllOf2
Fields
- shipping_address? ShippingDetail - The shipping details
- payment_source? PaymentSourceResponse - The payment source used to fund the payment
paypal.subscriptions: SubscriberRequest
The subscriber request information
Fields
- Fields Included from *Payer
- email_address Email
- payer_id AccountId
- name Name
- phone PhoneWithType
- birth_date DateNoTime
- tax_info TaxInfo
- address AddressPortable
- anydata...
- Fields Included from *SubscriberRequestAllOf2
- shipping_address ShippingDetail
- payment_source PaymentSource
- anydata...
paypal.subscriptions: SubscriberRequestAllOf2
Fields
- shipping_address? ShippingDetail - The shipping details
- payment_source? PaymentSource - The payment source definition. To be eligible to create subscription using debit or credit card, you will need to sign up here (https://www.paypal.com/bizsignup/entry/product/ppcp). Please note, its available only for non-3DS cards and for merchants in US and AU regions
paypal.subscriptions: Subscription
The subscription details
Fields
- Fields Included from *SubscriptionStatus
- Fields Included from *SubscriptionAllOf2
- id string
- plan_id string
- start_time DateTime
- quantity string
- shipping_amount Money
- subscriber Subscriber
- billing_info SubscriptionBillingInfo
- create_time DateTime
- update_time DateTime
- custom_id string
- plan_overridden boolean
- plan Plan
- links LinkDescription[]
- anydata...
paypal.subscriptions: SubscriptionActivateRequest
The activate subscription request details
Fields
- reason? string - The reason for activation of a subscription. Required to reactivate the subscription
paypal.subscriptions: SubscriptionAllOf2
Fields
- id? string - The PayPal-generated ID for the subscription.
- plan_id? string - The ID of the plan.
- start_time? DateTime - The date and time, in Internet date and time format. Seconds are required while fractional seconds are optional.<blockquote><strong>Note:</strong> The regular expression provides guidance but does not reject all invalid dates.</blockquote>
- quantity? string - The quantity of the product in the subscription.
- shipping_amount? Money - The currency and amount for a financial transaction, such as a balance or payment due
- subscriber? Subscriber - The subscriber response information
- billing_info? SubscriptionBillingInfo - The billing details for the subscription. If the subscription was or is active, these fields are populated
- create_time? DateTime - The date and time, in Internet date and time format. Seconds are required while fractional seconds are optional.<blockquote><strong>Note:</strong> The regular expression provides guidance but does not reject all invalid dates.</blockquote>
- update_time? DateTime - The date and time, in Internet date and time format. Seconds are required while fractional seconds are optional.<blockquote><strong>Note:</strong> The regular expression provides guidance but does not reject all invalid dates.</blockquote>
- custom_id? string - The custom id for the subscription. Can be invoice id.
- plan_overridden? boolean - Indicates whether the subscription has overridden any plan attributes.
- plan? Plan - The plan details
- links? LinkDescription[] - An array of request-related HATEOAS links.
paypal.subscriptions: SubscriptionBillingInfo
The billing details for the subscription. If the subscription was or is active, these fields are populated
Fields
- final_payment_time? DateTime -
- cycle_executions? CycleExecution[] - The trial and regular billing executions
- failed_payments_count int - The number of consecutive payment failures. Resets to
0
after a successful payment. If this reaches thepayment_failure_threshold
value, the subscription updates to theSUSPENDED
state
- next_billing_time? DateTime -
- last_failed_payment? FailedPaymentDetails -
- outstanding_balance Money -
- last_payment? LastPaymentDetails -
paypal.subscriptions: SubscriptionCancelRequest
The cancel subscription request details
Fields
- reason string - The reason for the cancellation of a subscription
paypal.subscriptions: SubscriptionCaptureRequest
The charge amount from the subscriber
Fields
- note string - The reason or note for the subscription charge
- amount Money - The currency and amount for a financial transaction, such as a balance or payment due
- capture_type "OUTSTANDING_BALANCE" - The type of capture
paypal.subscriptions: SubscriptionRequestPost
The create subscription request details
Fields
- shipping_amount? Money -
- start_time? DateTime -
- quantity? string - The quantity of the product in the subscription
- subscriber? SubscriberRequest - The subscriber request information
- custom_id? string - The custom id for the subscription. Can be invoice id
- application_context? ApplicationContext -
- plan? PlanOverride - An inline plan object to customise the subscription. You can override plan level default attributes by providing customised values for the subscription in this object
- plan_id string - The ID of the plan
- auto_renewal boolean(default false) - DEPRECATED. Indicates whether the subscription auto-renews after the billing cycles complete
paypal.subscriptions: SubscriptionReviseRequest
The request to update the quantity of the product or service in a subscription. You can also use this method to switch the plan and update the shipping_amount
and shipping_address
values for the subscription. This type of update requires the buyer's consent
Fields
- shipping_amount? Money -
- quantity? string - The quantity of the product or service in the subscription
- application_context? ApplicationContext -
- shipping_address? ShippingDetail -
- plan? PlanOverride - An inline plan object to customise the subscription. You can override plan level default attributes by providing customised values for the subscription in this object
- plan_id? string - The unique PayPal-generated ID for the plan
paypal.subscriptions: SubscriptionReviseResponse
The response to a request to update the quantity of the product or service in a subscription. You can also use this method to switch the plan and update the shipping_amount
and shipping_address
values for the subscription. This type of update requires the buyer's consent
Fields
- Fields Included from *SubscriptionReviseRequest
- shipping_amount Money
- quantity string
- application_context ApplicationContext
- shipping_address ShippingDetail
- plan PlanOverride
- plan_id string
- anydata...
- Fields Included from *SubscriptionReviseResponseAllOf2
- plan_overridden boolean
- links LinkDescription[]
- anydata...
paypal.subscriptions: SubscriptionReviseResponseAllOf2
Fields
- plan_overridden? boolean - Indicates whether the subscription has overridden any plan attributes.
- links? LinkDescription[] - An array of request-related HATEOAS links.
paypal.subscriptions: SubscriptionsCaptureHeaders
Represents the Headers record for the operation: subscriptions.capture
Fields
- PayPal\-Request\-Id? string - The server stores keys for 72 hours
paypal.subscriptions: SubscriptionsCreateHeaders
Represents the Headers record for the operation: subscriptions.create
Fields
- PayPal\-Request\-Id? string - The server stores keys for 72 hours
- Prefer string(default "return=minimal") - The preferred server response upon successful completion of the request. Value is:<ul><li><code>return=minimal</code>. The server returns a minimal response to optimize communication between the API caller and the server. A minimal response includes the <code>id</code>, <code>status</code> and HATEOAS links.</li><li><code>return=representation</code>. The server returns a complete resource representation, including the current state of the resource.</li></ul>
paypal.subscriptions: SubscriptionsGetQueries
Represents the Queries record for the operation: subscriptions.get
Fields
- fields? string - List of fields that are to be returned in the response. Possible value for fields are last_failed_payment and plan
paypal.subscriptions: SubscriptionStatus
The subscription status details
Fields
- status_change_note? string - The reason or notes for the status of the subscription
- status? "APPROVAL_PENDING"|"APPROVED"|"ACTIVE"|"SUSPENDED"|"CANCELLED"|"EXPIRED" - The status of the subscription
- status_update_time? DateTime -
paypal.subscriptions: SubscriptionsTransactionsQueries
Represents the Queries record for the operation: subscriptions.transactions
Fields
- start_time string - The start time of the range of transactions to list
- end_time string - The end time of the range of transactions to list
paypal.subscriptions: SubscriptionSuspendRequest
The suspend subscription request details
Fields
- reason string - The reason for suspenson of the subscription
paypal.subscriptions: Taxes
The tax details
Fields
- inclusive boolean(default true) - Indicates whether the tax was already included in the billing amount
- percentage Percentage - The percentage, as a fixed-point, signed decimal number. For example, define a 19.99% interest rate as
19.99
paypal.subscriptions: TaxesOverride
The tax details
Fields
- inclusive? boolean - Indicates whether the tax was already included in the billing amount
- percentage? Percentage - The percentage, as a fixed-point, signed decimal number. For example, define a 19.99% interest rate as
19.99
paypal.subscriptions: TaxInfo
The tax ID of the customer. The customer is also known as the payer. Both tax_id
and tax_id_type
are required
Fields
- tax_id_type "BR_CPF"|"BR_CNPJ" - The customer's tax ID type
- tax_id string - The customer's tax ID value
paypal.subscriptions: ThreeDSecureAuthenticationResponse
Results of 3D Secure Authentication
Fields
- authentication_status? ParesStatus -
- enrollment_status? Enrolled -
paypal.subscriptions: Transaction
The transaction details
Fields
- Fields Included from *CaptureStatus
- status_details CaptureStatusDetails
- status "COMPLETED"|"DECLINED"|"PARTIALLY_REFUNDED"|"PENDING"|"REFUNDED"
- anydata...
- Fields Included from *TransactionAllOf2
- id string
- amount_with_breakdown AmountWithBreakdown
- payer_name Name
- payer_email EmailAddress
- time DateTime
- anydata...
- time DateTime -
- amount_with_breakdown AmountWithBreakdown -
- id string -
paypal.subscriptions: TransactionAllOf2
Fields
- id? string - The PayPal-generated transaction ID.
- amount_with_breakdown? AmountWithBreakdown - The breakdown details for the amount. Includes the gross, tax, fee, and shipping amounts
- payer_name? Name - The name of the party
- payer_email? EmailAddress - The internationalized email address.<blockquote><strong>Note:</strong> Up to 64 characters are allowed before and 255 characters are allowed after the <code>@</code> sign. However, the generally accepted maximum length for an email address is 254 characters. The pattern verifies that an unquoted <code>@</code> sign exists.</blockquote>
- time? DateTime - The date and time, in Internet date and time format. Seconds are required while fractional seconds are optional.<blockquote><strong>Note:</strong> The regular expression provides guidance but does not reject all invalid dates.</blockquote>
paypal.subscriptions: TransactionsList
The list transactions for a subscription request details
Fields
- links? LinkDescription[] - An array of request-related HATEOAS links
- total_pages? int - The total number of pages
- transactions? Transaction[] - An array of transactions
- total_items? int - The total number of items
paypal.subscriptions: UpdatePricingSchemeRequest
The update pricing scheme request details
Fields
- billing_cycle_sequence int - The billing cycle sequence
- pricing_scheme PricingScheme -
paypal.subscriptions: UpdatePricingSchemesListRequest
The update pricing scheme request details
Fields
- pricing_schemes UpdatePricingSchemeRequest[] - An array of pricing schemes
Union types
paypal.subscriptions: CardBrand
CardBrand
The card network or brand. Applies to credit, debit, gift, and payment cards
paypal.subscriptions: Enrolled
Enrolled
Status of Authentication eligibility
paypal.subscriptions: PhoneType
PhoneType
The phone type
paypal.subscriptions: LiabilityShift
LiabilityShift
Liability shift indicator. The outcome of the issuer's authentication
paypal.subscriptions: PayeePaymentMethodPreference
PayeePaymentMethodPreference
The merchant-preferred payment methods
paypal.subscriptions: ParesStatus
ParesStatus
Transactions status result identifier. The outcome of the issuer's authentication
Array types
paypal.subscriptions: PatchRequest
PatchRequest
An array of JSON patch objects to apply partial updates to resources
String types
paypal.subscriptions: Email
The internationalized email address.
Note: Up to 64 characters are allowed before and 255 characters are allowed after the@
sign. However, the generally accepted maximum length for an email address is 254 characters. The pattern verifies that an unquoted@
sign exists.
paypal.subscriptions: AccountId
AccountId
The account identifier for a PayPal account
paypal.subscriptions: DateTime
DateTime
The date and time, in Internet date and time format. Seconds are required while fractional seconds are optional.
Note: The regular expression provides guidance but does not reject all invalid dates.
paypal.subscriptions: CurrencyCode
CurrencyCode
The three-character ISO-4217 currency code that identifies the currency
paypal.subscriptions: DateYearMonth
DateYearMonth
The year and month, in ISO-8601 YYYY-MM
date format. See Internet date and time format
paypal.subscriptions: EmailAddress
EmailAddress
The internationalized email address.
Note: Up to 64 characters are allowed before and 255 characters are allowed after the@
sign. However, the generally accepted maximum length for an email address is 254 characters. The pattern verifies that an unquoted@
sign exists.
paypal.subscriptions: DateNoTime
DateNoTime
The stand-alone date, in Internet date and time format. To represent special legal values, such as a date of birth, you should use dates with no associated time or time-zone data. Whenever possible, use the standard date_time
type. This regular expression does not validate all dates. For example, February 31 is valid and nothing is known about leap years
paypal.subscriptions: Language
Language
The language tag for the language in which to localize the error-related strings, such as messages, issues, and suggested actions. The tag is made up of the ISO 639-2 language code, the optional ISO-15924 script tag, and the ISO-3166 alpha-2 country code
paypal.subscriptions: CountryCode
CountryCode
The two-character ISO 3166-1 code that identifies the country or region.
Note: The country code for Great Britain isGB
and notUK
as used in the top-level domain names for that country. Use theC2
country code for China worldwide for comparable uncontrolled price (CUP) method, bank card, and cross-border transactions.
paypal.subscriptions: Percentage
Percentage
The percentage, as a fixed-point, signed decimal number. For example, define a 19.99% interest rate as 19.99
Simple name reference types
paypal.subscriptions: LastPaymentDetails
LastPaymentDetails
The details for the last payment
Import
import ballerinax/paypal.subscriptions;
Other versions
1.0.0
Metadata
Released date: 20 days ago
Version: 1.0.0
License: Apache-2.0
Compatibility
Platform: any
Ballerina version: 2201.12.0
GraalVM compatible: Yes
Pull count
Total: 1
Current verison: 1
Weekly downloads
Keywords
PayPal
Subscriptions
Plans
Billing
Payments
Recurring
Connector
Contributors