Global API
...
Subscription
Subscription - Stripe
Create
1min
to create a subscription in stripe, use the action “createsubscription” and pass the subscription data in the requestjson under “subscriptions ” note you can only create one record at a time here is an example of creating a subscription where we are setting every possible field(see https //app archbee io/docs/ lihuunv 7xnqrtzhskkc/hnjmkn99qxwdeafyyifsq subscription stripe docid 2rpakanle63bthfxeufqg for all the available fields) the response will return the response back from stripe, which includes the subscription id ( internalid ) plus the newly created salesforce subscription id ( salesforceid ) map\<string, object> subscriptiondata = new map\<string, object>(); subscriptiondata put('processorcustomerid', 'processorcustomerid'); subscriptiondata put('collectionmethod', 'charge automatically'); subscriptiondata put('processorpaymentmethodid', 'processorpaymentmethodid'); list\<object> items = new list\<object>(); map\<string, object> itemdata = new map\<string, object>(); itemdata put('processorpriceid', 'processorpriceid'); itemdata put('quantity', 2); items add(itemdata); subscriptiondata put('items', items); // initializing the requestjson data to be passed map\<string, object> requestjsonmap = new map\<string, object>(); requestjsonmap put('subscriptions', new list\<object>{subscriptiondata}); string reqjson = json serialize(requestjsonmap); map\<string, object> reqobj = new map\<string, object>(); reqobj put('version','1 0'); reqobj put('action','createsubscription'); reqobj put('processorid', 'processorid'); reqobj put('requestjson',reqjson); // placing a request to breadwinner global api map\<string,object> resp = bw payments breadwinnerpaymentsapi call(reqobj); system debug(resp);{ action=createsubscription, validrequest=true, timestamp=1674648707968, version=1 0, statuscode=200, responsejson={ "subscriptions" \[ { "trialperioddays" null, "trialfromplan" null, "trialend" null, "subscriptionmetadata" null, "status" "active", "startdate" null, "salesforceid" "salesforcesubscriptionid", "salesforcecontact" null, "salesforceaccount" "salesforceaccountid", "prorationbehavior" null, "promotioncode" null, "processorsubscriptionid" "processorsubscriptionid", "processorpaymentmethodid" null, "processororgid" "processororgid", "processorcustomerid" null, "paymentbehaviour" null, "metadata" null, "latestinvoice" "latestinvoice", "items" \[ { "unitamountdecimal" 100 00, "unitamount" 100 00, "salesforcesubscriptionid" "salesforcesubscriptionid", "salesforceid" "salesforcesubscriptionitemid", "quantity" 2, "processorsubscriptionid" "processorsubscriptionid", "processorpriceid" null, "processorid" "processoritemid", "salesforcepriceid" "salesforcepriceid", "name" null, "invoice" null, "errormessage" null, "description" null, "chargecurrency" "usd", "amount" 200 00 } ], "errormessage" null, "description" null, "daysuntildue" null, "salesforcecustomerid" "salesforcecustomerid", "currentperiodstartdate" "2023 01 25t12 11 42 000z", "currentperiodenddate" "2023 02 25t12 11 42 000z", "createdvia" "breadwinner", "createddateinprocessor" "2023 01 25t12 11 42 000z", "coupon" null, "collectionmethod" "charge automatically", "cancelimmediately" null, "cancelatperiodend" null, "cancelat" null, "billingcycleanchor" null, "backdatestartdate" null } ] } }