Using the Stripe Payment Form in Meteor

I am trying to use the payment form in Meteor:

When creating a Stripe form:

<form action="" method="POST">
 <script
   src="https://checkout.stripe.com/v2/checkout.js" class="stripe-button"
   data-key=x
   data-amount="2000"
   data-name="Demo Site"
   data-description="2 widgets ($20.00)"
   data-image="/128x128.png">
 </script>

He does not work,

I understand that Meteor does not run the script in .html files. And I can use Stripe.js.

But is there a way to use the form instead of dealing with Stripe.js?

+5
source share
1 answer

I assume you say Stripe Checkout . See the section "Custom buttons".

Add a script tag to test Stripe in <head>your template file.

<head>
    <script src="https://checkout.stripe.com/v2/checkout.js"></script>
</head>

Then add a button, anchor, or other clickable tag template to the template.

<template name="payment">
    <button>Pay</button>
</template>

Then add an event to open the form in the Stripe text box when you click the button.

Template.payment.events({
    'click button': function(e) {
        e.preventDefault();

        StripeCheckout.open({
            key: 'YOUR PUBLIC KEY',
            amount: 5000,
            name: 'The Store',
            description: 'A whole bag of awesome ($50.00)',
            panelLabel: 'Pay Now',
            token: function(res) {
                // Do something with res.id
                // Store it in Mongo and/or create a charge on the server-side
                console.info(res);
            }
        });
    }
});

Stripe "" . id , .

+14

All Articles