Skip to content

Repo cannot run anymore : updated stripe payment-intent#4

Open
romain130492 wants to merge 3 commits into
code-nebula:masterfrom
romain130492:chore/stripe-update
Open

Repo cannot run anymore : updated stripe payment-intent#4
romain130492 wants to merge 3 commits into
code-nebula:masterfrom
romain130492:chore/stripe-update

Conversation

@romain130492

@romain130492 romain130492 commented Jun 20, 2021

Copy link
Copy Markdown

Description

The purpose of this PR is to update the repo with the recent changes that were made to stripe API (Payment Intent)
Without theses changes the repo cannot be run !

Comment thread api/stripe-functions.js
async function getProductsAndPlans() {
return Promise.all([
stripe.products.list({}), // Default returns 10 products, sorted by most recent creation date
stripe.products.list({ type:'service' }), // Default returns 10 products, sorted by most recent creation date

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before without this change the array of product was empty,
We need to add type:service in order to get our products.
discussion here

Comment thread api/stripe-functions.js
}],
// trial_from_plan: true,
expand: ["latest_invoice.payment_intent"],
payment_behavior:'allow_incomplete'

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We now need to add a payment_behavior, otherwise the default behavior is an error returned by stripe.
Then we cannot get any response object with payment_intent.

Hence we have to add that key : payment_behavior that we can set to allow_incomplete

Additional info here

Comment thread router/index.js
req.body.paymentMethodId,
customerInfo,
);
} catch (err) {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a try/catch, i was not getting any error before,,

Comment thread views/register.html
/* Do NOT share or embed your client_secret anywhere */
const { client_secret, status } = payment_intent;
if (status === "requires_action" || status === "requires_payment_method") {
if (status === "requires_action" || status === "requires_payment_method" || status === "requires_source_action" ) {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the status we get when setting payment_behavior: allow_incomplete is now requires_source_action

Comment thread views/register.html Outdated
<script>
/* Replace with Publishable Stripe Key */
var stripe = Stripe('pk_test_***********************');
var stripe = Stripe('pk_test_sN8QMwBCcsybtkQMue7JrgLT00yNdFd4d4');

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😓 I removed that one in the next commit

@romain130492 romain130492 changed the title updated stripe payment intent Repo cannot run anymore : updated stripe payment-intent Jun 20, 2021
@romain130492

Copy link
Copy Markdown
Author

@code-nebula Hey, i made a pull request for you repo,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant