AppStitch Stripe
A flexible convenience wrapper for Stripe's API
Install
npm install @appstitch/stripe
Install Peer Dependancies AppStitch Core and AppStitch Types
npm install @appstitch/core
npm install @appstitch/types
Remember
Initialize Appstitch Core
Usage
import { createSubscription } from "@appstitch/stripe";
// OR
import * as stripeClient from "@appstitch/stripe";
Apart from a few exceptions, this library mirror Stripe's API. You can use Stripe's Docs or our JSDocs for reference.
Create a Subscription
stripeClient.createSubsciption({
customer : "cus_ABC123456",
items:[{price : "price_XYZ123456"}],
}).then(result => {
if(result.object === "subscription")
{
// Success
}
})
Create a Payment
stripeClient.createPaymentIntent({
customer: "cus_abc123"
amount : 2500,
currency:"usd",
confirm:true
})
.then(result => {
if(result.object === "payment_intent")
{
// Success
}
})
}
Exceptions
For Retrieve, Delete and Update requests, Stripe Api look something similar to this
// Update
invoices.update(id, {
...options
})
After consideration we went for chose to go for this approach instead. Notice the invoice id is passed with the update options
// Update
updateInvoice({
id,
...options
})
Reference Stripe's Docs and AppStitch Types to find out the attributes for each object/resource