1.3.0 • Published 2 months ago
@storecraft/payments-stripe v1.3.0
Stripe payment gateway for StoreCraft
Stripe integration
npm i @storecraft/payments-stripe
Howto
import { Stripe } from '@storecraft/payments-stripe';
import { Stripe as StripeCls } from 'stripe';
const config = {
//`stripe` publishable key. if missing, it will be inferred from env variable
publishable_key: env.process.STRIPE_PUBLISHABLE_KEY // 'pk_....',
// `stripe` private secret. if missing, it will be inferred from env variable
secret: process.env.STRIPE_SECRET_KEY //'sk_.....',
// (Optional) `stripe` private `webhook` secret.
// if missing, it will be inferred from env variable
webhook_endpoint_secret: process.env.STRIPE_WEBHOOK_SECRET // 'whsec_.....',
// config options for `stripe`
stripe_config: {
httpClient: StripeCls.createFetchHttpClient()
},
// configure `intent` creation
stripe_intent_create_params: {
currency: 'usd',
automatic_payment_methods: {
enabled: true,
},
payment_method_options: {
card: {
// authorize and capture flow
capture_method: 'manual',
},
},
}
}
new Stripe(config);
// or, env variables will be inferred by
// - `STRIPE_PUBLISHABLE_KEY`
// - `STRIPE_SECRET_KEY`
// - `STRIPE_WEBHOOK_SECRET`
new Stripe();
In Storecraft App
import { App } from '@storecraft/core';
import { MongoDB } from '@storecraft/database-mongodb';
import { NodePlatform } from '@storecraft/core/platform/node';
import { GoogleStorage } from '@storecraft/storage-google';
import { PaypalStandard } from '@storecraft/payments-paypal-standard'
const app = new App(config)
.withPlatform(new NodePlatform())
.withDatabase(new MongoDB())
.withStorage(new GoogleStorage())
.withPaymentGateways({
stripe: new Stripe() // config can be inferred from env variables
})
.init();
Developer info and test
First, some resources from stripe
Test Webhooks
First, consult Stripe Webhooks Docs
Then, Install the stripe
cli.
stripe listen --skip-verify --forward-to localhost:8000/api/payments/gateways/stripe/webhook
This will print the webhook
SECRET
Ready! Your webhook signing secret is '{{WEBHOOK_SIGNING_SECRET}}' (^C to quit)
Copy the WEBHOOK_SIGNING_SECRET
and put it in the config
of the gateway.
Now, start interacting, and test some payments.
todo:
- Add tests
Author: Tomer Shalev (tomer.shalev@gmail.com)
1.0.17
3 months ago
1.0.16
3 months ago
1.2.5
2 months ago
1.3.0
2 months ago
1.0.15
3 months ago
1.0.14
4 months ago
1.0.13
4 months ago
1.0.11
4 months ago
1.0.12
4 months ago
1.0.9
5 months ago
1.0.8
5 months ago
1.0.7
7 months ago
1.0.6
8 months ago
1.0.10
5 months ago
1.0.5
9 months ago
1.0.4
9 months ago
1.0.3
9 months ago
1.0.2
9 months ago
1.0.1
11 months ago
1.0.0
12 months ago