stripe-node | Node.js library for the Stripe API | Ecommerce library
kandi X-RAY | stripe-node Summary
kandi X-RAY | stripe-node Summary
The Stripe Node library provides convenient access to the Stripe API from applications written in server-side JavaScript. For collecting customer and payment information in the browser, use Stripe.js.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- generate the pagination method
- Create a new Stripe instance .
- Generate request options
- Parse the event details .
- Calls the request .
- Verifies that the provided signature has been valid .
- Creates a stripe method
- Given an array of items return a function which is called on each item in series .
- Creates a function that calls to autoParams from a list of items .
- Wraps asyncIterator into a promise .
stripe-node Key Features
stripe-node Examples and Code Snippets
from django.http import HttpResponseRedirect
from rauth.service import OAuth2Service
stripe_connect_service = OAuth2Service(
name = 'stripe',
client_id = admin_client_id_key,
client_secret = admin_publisher_secret_key,
authorize_url =
const fastify = require('fastify')({ logger: true })
fastify
.register(require('fastify-stripe'), {
apiKey: 'sk_test_...',
name: 'test',
timeout: 24000 // in ms (this is 24 seconds)
})
.register(require('fastify-stripe'), {
api
// default.json
{
"stripe": {
"apiKey": "sk_test_MP5bNSfgUyBG2cq3bCntjfLm",
"webhooks": {
"signature": {
"verify": true,
"secret": "whsec_sZYN4b3x00PWFvTejfY5xudYx4D8TvW9"
}
}
}
}
// app.js
const stripe =
Community Discussions
Trending Discussions on stripe-node
QUESTION
Been stuck on this error for a while now and I've followed stripes documentation and express example on github, but still have no success.
I am using express in Firebase functions:
...ANSWER
Answered 2022-Apr-15 at 17:45This is a common issue. If you're sure the secret is correct, then something is modifying the inbound request body. You need the raw body. Take a look at this Github issue for common solutions.
QUESTION
Similar to this question, using a more recent version of SvelteKit.
Context: SvelteKit PR #3384 started passing standard Request
objects to endpoints and removed rawBody
.
The question linked above has a good answer for how to use rawBody
to call Stripe's constructEvent
to verify the signature of an incoming webhook request, but now that the unmodified body is no longer exposed (as far as I can tell), I'm left wondering how to update my webhook handler.
I've tried calling constructEvent
with the results of request.text()
, request.json()
, request.arrayBuffer()
(converted to a string), request.blob().text()
, and the plain request.body
converted to a string, yet none of them worked. It always throws the same error:
ANSWER
Answered 2022-Feb-08 at 13:58So I've looked into the node-fetch source code because that's what svelte-kit uses to shim the dev server with and all environments that don't support Fetch
and there is a method that the standard Request
class doesn't have and that's Request.buffer()
. With this method I was able to solve that issue. This will only be available in node or serverless environments that don't support fetch natively (nearly every environment except cloudflare).
QUESTION
Note: I'm using the Node.js
SDK, but I assume all Stripe SDKs are thin wrappers around their REST API.
How can I handle card authentication/3D-Secure/next steps when working with subscriptions and receiving a status == incomplete
after creating a new subscription?
The documentation isn't very clear about it. It seems that Subscription
objects are a higher-order abstraction over PaymentIntent
objects, with recurring charges, free trial days, things like this.
However, it seems to be impossible to actually work with a PaymentIntent
once you've created a subscription. And the only way to retrieve a PaymentIntent
seems to be by using its associated pi_
ID.
Thanks in advance.
...ANSWER
Answered 2022-Jan-24 at 16:35Have you seen the Build a subscription guide on Stripe's documentation? Specifically this section, where you collect payment details and confirm the Payment Intent returned on the Subscription object in your applications front-end.
QUESTION
I'm trying to get the line_items of the checkout session in Stripe so that I can send an email consisting of the product download link but unfortunately, When I try to retrieve the line_items
in the checkout_session
I get a null value.
Frontend: Next.js
Here is my code in /pages/api/webhooks/index.ts
:
Check the line: 77
...ANSWER
Answered 2021-Nov-12 at 06:52As noted in the API reference, the line_items
of a Session are "expandable" and not included by default. This means that they are not included in the object when delivered in a webhook event, and you must explicitly request the value via expansion when retrieving the object.
To get these, you'll need to retrieve the Session and request the line_items
be included in the response:
QUESTION
I'm trying to set up a Stripe webhook in Sails, checking the webhook signature as described here. The signature is being returned in the same format as the Stripe example, but every test webhook returns:
...ANSWER
Answered 2021-Aug-09 at 21:39The answer was here: https://stackoverflow.com/a/68236261/6569847
Update the commented out bodyParser under config/http.js to:
QUESTION
I have figured out the problem thanks to the extensive answer from @user9014097. This section in particular describes my mistake/oversight:
The formatting of the message plays a role in determining the MAC. Every difference, e.g. a line break, a blank etc. changes the signature and results in a failed verification. Check if you might have changed the message or its format a little bit.
After stringifying the request body it works like a charm!
With cloudflare workers you can get the original body in plain text like this: const payload = await event.request.text();
I am trying to manually verify the signature for Stripe webhooks. I am not working in node.js so the stripe-node package is not an option for me unfortunately. I have followed the "Verifying signatures manually" steps on https://stripe.com/docs/webhooks/signatures#verify-manually. So far I've produced the following:
- body: event.request.body (from cloudflare workers' fetch event)
- header: event.request.headers.get('Stripe-Signature')
ANSWER
Answered 2021-Jul-08 at 04:24While you can't use the entire Stripe Node library in a Cloudflare Worker you can use the webhook signature piece.
QUESTION
According to the RFC Put
is used to update an existing resource.
But, the Stripe API uses Post
to update objects. Why is this?
For example, in the Stripe Node Library
...ANSWER
Answered 2020-Nov-12 at 04:04Interesting question! From your link:
The PUT method requests that the enclosed entity be stored under the supplied Request-URI. If the Request-URI refers to an already existing resource, the enclosed entity SHOULD be considered as a modified version of the one residing on the origin server. [emphasis mine]
This means you must PUT
the entire resource (changes and and non-changes alike). Very few APIs are designed that way.
From the spec for POST:
The POST method is used to request that the origin server accept the entity enclosed in the request as a new subordinate of the resource identified by the Request-URI in the Request-Line. POST is designed to allow a uniform method to cover the following functions:
- Annotation of existing resources;
Many/most APIs have adopted POST
as the way to update objects.
Some additional thoughts here: https://stackoverflow.com/a/25909372/379538
QUESTION
I am learning how to setup react to send a request to node to communicate with stripe's api to do a payment. I have followed a recent tutorial and am running into an error on the node server:
...ANSWER
Answered 2020-Nov-02 at 23:10You are seeing that error because the Stripe API is expecting that you pass the idempotency key under the idempotencyKey
property, whereas in your code is being passed as idempontencyKey
:
This looks to be a simple typo, the rest of your integration looks good!
QUESTION
I keep getting this error:
...ANSWER
Answered 2020-Sep-29 at 02:29You're not getting the raw body the way you're doing it. You need to 'exclude' your webhook route from the express.json() body parser like is described here: https://github.com/stripe/stripe-node/blob/master/examples/webhook-signing/node-express/express.js
So instead of
QUESTION
Error:
"message": "No signatures found matching the expected signature for payload. Are you passing the raw request body you received from Stripe? https://github.com/stripe/stripe-node#webhook-signing",
I've tried req.rawBody
, but the same result. I ve also tried all the solutions available on stack overflow and github.
ANSWER
Answered 2020-Mar-27 at 14:08Using bodyParser.json()
will modify the body such that the signatures are not verifiable. You need to ensure this middleware is not being applied for your webhook /hook
endpoint.
One way to do this with Express is to simply define the webhook endpoint before you apply the middleware (in the sequence of building your routes).
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install stripe-node
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page