Create Subscription
Create a new Subscription for a User. User must have a valid customer ID of Payment Provider set. Requires billing details with at least a country code and postal code if country is one of US, CA, UA, IN.
Note: User must have a valid customer ID of Payment Provider set and this customer must have a valid default payment method set (Payment Provider dashboard).
curl --request POST \
--url https://api.fungies.io/v0/subscriptions/create \
--header 'Content-Type: application/json' \
--header 'x-fngs-public-key: <api-key>' \
--header 'x-fngs-secret-key: <api-key>' \
--data '{
"userId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"userEmail": "jsmith@example.com",
"backdateStartDate": 4503599627370495,
"billingCycleAnchor": 4503599627370495,
"trialEnd": 4503599627370495,
"skipTrial": false,
"skipNotifications": false,
"items": [
{
"name": "Premium Plan",
"unitPrice": 10000,
"currency": "USD",
"quantity": 1,
"offerId": "123e4567-e89b-12d3-a456-426614174000",
"price": 8.988465674311579e+307,
"value": 8.988465674311579e+307
}
]
}'
{
"status": "<string>",
"data": {
"subscription": {
"object": "subscription",
"id": "<string>",
"status": "all",
"createdAt": 4503599627370495,
"currentIntervalEnd": 4503599627370495,
"currentIntervalStart": 4503599627370495,
"cancelAtIntervalEnd": false,
"canceledAt": null,
"userId": null,
"user": null,
"orderId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"orderNumber": "<string>",
"order": {
"object": "order",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"number": "<string>",
"status": "PENDING"
},
"lastPaymentId": null,
"lastPaymentNumber": null,
"lastPayment": null
}
}
}
Body
Name of the Item. Required if Offer ID is not provided. Can be used to override the Offer name.
"Premium Plan"
New unit price in cents (min: 100). Required if Offer ID is not provided. Can be used to override the Offer price.
100 < x <= 9007199254740991
10000
Valid currency code. Required if value is provided. Required if Offer ID is not provided. Can be used to override the Offer currency.
Note: Currently needs to match Workspace currency.
AFN
, ALL
, DZD
, AOA
, ARS
, AMD
, AWG
, AUD
, AZN
, BSD
, BDT
, BBD
, BZD
, BMD
, BOB
, BAM
, BWP
, BRL
, BHD
, GBP
, BND
, BGN
, BIF
, BYN
, KHR
, CAD
, CVE
, KYD
, KWD
, XAF
, XPF
, CLP
, CNY
, COP
, KMF
, CDF
, CRC
, HRK
, CZK
, DKK
, DJF
, DOP
, XCD
, EGP
, ETB
, EUR
, FKP
, FJD
, GMD
, GEL
, GIP
, GTQ
, GNF
, GYD
, HTG
, HNL
, HKD
, HUF
, ISK
, INR
, IDR
, ILS
, JMD
, JPY
, JOD
, KZT
, KES
, KGS
, LAK
, LBP
, LSL
, LRD
, MOP
, MKD
, MGA
, MWK
, MYR
, MVR
, MRO
, MUR
, MXN
, MDL
, MNT
, MAD
, MZN
, MMK
, NAD
, NPR
, ANG
, TWD
, NZD
, NIO
, NGN
, NOK
, OMR
, PKR
, PAB
, PGK
, PYG
, PEN
, PHP
, PLN
, QAR
, RON
, RUB
, RWF
, SHP
, SVC
, WST
, STD
, SAR
, RSD
, SCR
, SLL
, SGD
, SBD
, SOS
, ZAR
, KRW
, LKR
, SRD
, SZL
, SEK
, CHF
, TJS
, TZS
, THB
, TND
, TOP
, TTD
, TRY
, UGX
, UAH
, AED
, UYU
, USD
, UZS
, VUV
, VEF
, VND
, XOF
, YER
, ZMW
, SLE
, XCG
, SSP
, VES
, MRU
, STN
, VED
"USD"
Optional quantity (default: 1).
1 <= x <= 1.7976931348623157e+308
1
Optional valid Offer ID. Adds Offer reference to the Item.
Note: name, value and currency are derived from the Offer if not provided.
- name: Offer name with full specification
- value: Offer price
- currency: Offer currency
"123e4567-e89b-12d3-a456-426614174000"
Deprecated. Use value instead.
100 <= x <= 1.7976931348623157e+308
Deprecated. Use unitPrice instead.
100 <= x <= 1.7976931348623157e+308
0 <= x <= 9007199254740991
0 <= x <= 9007199254740991
0 <= x <= 9007199254740991
Response
"success"
all
, active
, canceled
, incomplete
, incomplete_expired
, past_due
, trialing
, paused
, unpaid
0 <= x <= 9007199254740991
0 <= x <= 9007199254740991
0 <= x <= 9007199254740991
PENDING
, PAID
, FAILED
, UNPAID
, CANCELLED
, REFUNDED
, PARTIALLY_REFUNDED
, EXPIRED
order
subscription
0 <= x <= 9007199254740991
one_time
, subscription_initial
, subscription_update
, subscription_interval
, subscription_extra
, claim_free
PENDING
, PAID
, FAILED
, UNPAID
, CANCELLED
, REFUNDED
, PARTIALLY_REFUNDED
, EXPIRED
payment
curl --request POST \
--url https://api.fungies.io/v0/subscriptions/create \
--header 'Content-Type: application/json' \
--header 'x-fngs-public-key: <api-key>' \
--header 'x-fngs-secret-key: <api-key>' \
--data '{
"userId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"userEmail": "jsmith@example.com",
"backdateStartDate": 4503599627370495,
"billingCycleAnchor": 4503599627370495,
"trialEnd": 4503599627370495,
"skipTrial": false,
"skipNotifications": false,
"items": [
{
"name": "Premium Plan",
"unitPrice": 10000,
"currency": "USD",
"quantity": 1,
"offerId": "123e4567-e89b-12d3-a456-426614174000",
"price": 8.988465674311579e+307,
"value": 8.988465674311579e+307
}
]
}'
{
"status": "<string>",
"data": {
"subscription": {
"object": "subscription",
"id": "<string>",
"status": "all",
"createdAt": 4503599627370495,
"currentIntervalEnd": 4503599627370495,
"currentIntervalStart": 4503599627370495,
"cancelAtIntervalEnd": false,
"canceledAt": null,
"userId": null,
"user": null,
"orderId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"orderNumber": "<string>",
"order": {
"object": "order",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"number": "<string>",
"status": "PENDING"
},
"lastPaymentId": null,
"lastPaymentNumber": null,
"lastPayment": null
}
}
}