-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Add route, function to update a Stripe PaymentIntent * docs: Add updatePaymentIntent example * docs: Fix typo * refactor: Use PUT method
- Loading branch information
Showing
5 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// Create | ||
export { default as createCheckoutSession } from './create/checkout-session' | ||
export { default as createPaymentIntent } from './create/payment-intent' | ||
// Update | ||
export { default as updatePaymentIntent } from './update/payment-intent' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import Stripe from 'stripe' | ||
|
||
export default async function updatePaymentIntent(req, res, options) { | ||
try { | ||
const stripe = new Stripe(options.secret_key) | ||
|
||
const { id, body } = req.body | ||
|
||
const paymentIntent = await stripe.paymentIntents.update(id, body) | ||
|
||
res.status(200).json(paymentIntent) | ||
} catch ({ statusCode, raw: { message } }) { | ||
res.status(statusCode).json({ message, status: statusCode }) | ||
} | ||
} |