- create manual subscription:
POST /manual/subscriptions
{
"kid": "user_kid",
"metadata": {
"daily_classic_coffee_count": 1,
"daily_specialty_coffee_count": 1,
"total_classic_coffee_count": 365,
"total_specialty_coffee_count": 365,
"name": "Installment Subscription"
},
"interval": "yearly",
"fixed_credit": false,
"active": true,
"out_of_credits": false,
"subscription_id": "subscription_givin_id",
"payment_method_id": "971525619098_2021-11-20_17--15--33",
"period_start": "2021-11-20",
"period_end": "2022-11-20",
"payment": {
"amount_due": 3540.00,
"amount_paid": 3540.00
}
}
interval:yearlyormonthly
fixed_credit,out_of_creditsandactivearefalse,falseandtruerespectively.
- delete manual subscription:
DELETE /manual/subscriptions/:id
-- id: subscription id.
- fetch manual subscriptions:
GET /manual/subscriptions
-- subscription_id
-- kid
- Fetch all coupons:
GET /coupon - Delete a coupon by code:
DELETE /coupon/:code - Update a coupon by code:
PUT /coupon/:codebody:
{
"active": false,
"interval": "yearly"
}- Create new coupon:
POST /couponbody:
{
"code": "coupon_unique_code_name",
"percent_off": 25,
"max_limit": 1,
"expiry": "2021-11-30",
"applies_to": [
"classic_coffee",
"specialty_coffee"
],
"interval": "monthly"
}
applies_tomust be a value in [classic_coffee,specialty_coffee].
intervalmust be eithermonthlyoryearly.coupon
codeequalsidon Stripe dashboard.
When creating a coupon on Stripe dashboard the default interval is yearly, if you want to change the default interval value, you must call the Update a coupon by code api with the new interval.
to create a new subscription using the newly created coupon use Create new Subscription api and add coupon_id string field and a value of the coupon id/code.
"field_name": data type
{
"kid": String,
"subscription_id": String,
"interval": String,
"payment_method_id": String,
"total_paid": Number,
"name": String,
"coupon_id": String,
"daily_classic_coffee_count": Number,
"daily_specialty_coffee_count":Number,
"total_classic_coffee_count":Number,
"total_specialty_coffee_count":Number,
"user_metadata": Object,
"created_at": DateTime,
}
const user_metadata = {
first_name: user.first_name || '',
last_name: user.last_name || '',
phone_number: user.phone_number,
kid: user.kid,
birth_date: user.birth_date || '',
email: user.email || '',
emirate: user.emirate || ''
}
request body:
{
"metadata" : {
"daily_classic_coffee_count" : 2,
"daily_specialty_coffee_count" : 0,
"total_classic_coffee_count" : 60,
"total_specialty_coffee_count" : 0,
"name" : "Subscription 16"
},
"interval" : "yearly",
"fixed_credit" : false,
"active" : true,
"out_of_credits" : false,
"subscription_id" : "sub_1Js77vL4r9sVX2wgzkU8MdJO",
"kid" : "kid-041-04568540",
"customer_id" : "cus_KVInzhxKyGUw5E",
"payment_method_id" : "pm_1Jr6JHL4r9sVX2wg5gzeXGQF",
"period_start": "2005-10-21",
"period_end": "2005-10-21",
"payment" : {
"amount_due" : 73800,
"amount_paid" : 73800
}
}- Create new Subscription:
POST: /payment/api/cutomer/subscription/create
NEW request body:
{
"payment_method_id": "payment method id from stripe",
"interval": "monthly", //yearly
"coupon_id": "the is of your pomo code id",
"products": [
{
"id": "classic_coffee",
"quantity": 1
},
{
"id": "specialty_coffee",
"quantity": 1
}
],
"metadata": {
"name": "Subscription 16"
}
}- Create new Subscription:
POST: /payment/api/cutomer/subscription/create
NEW request body:
{
"payment_method_id": "pm_1JmhvTL4r9sVX2wga6KH4mQk",
"interval": "yearly", //or: monthly
"promo_code_id": "promo_code", // promo code -> code
"products": [
{
"id": "specialy_cup",
"quantity": 1 // = daily_specialty_coffee_count
},
{
"id": "classic_cup",
"quantity": 1 // = daily_classic_coffee_count
}
],
"metadata": {
"name": "New subscription",
"daily_specialty_coffee_count": 1,
"daily_classic_coffee_count": 1
}
}Changed to be
payment_methods
- Fetch all customer payment methods:
GET /payment/api/cutomer/payment_methods - Fetch payment method with id:
GET /payment/api/cutomer/payment_methods/:id - Add new Payment method to customer:
POST /payment/api/cutomer/payment_methods/add - Delete/Datatch payment method from customer:
DELETE /payment/api/cutomer/payment_methods/:id
- Fetch customer's subscription details:
GET: /payment/api/cutomer/subscription/:id - Fetch customer's subscriptions:
GET: /payment/api/cutomer/subscription - Cancel customer's subscription:
DELETE /payment/api/cutomer/subscription/:id - Create new Subscription:
POST: /payment/api/cutomer/subscription/create
{
"payment_method_id": "pm_1JmhvTL4r9sVX2wga6KH4mQk",
"products": [
{
"id": "prod_KQrleXUoFL7vnZ",
"unit_amount_decimal": 500,
"quantity": 5
}
],
"metadata": {
"name": "Sub 5",
"dailyClassicCoffeeCount": 5,
"dailySpecialtyCoffeeCount": 10
}
}