Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Stripe payment form in Meteor

I'm trying to use Strip Payment Form in Meteor:

When putting the 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>

It is not working,

I get it that Meteor doesn't run script in the .html files. And that I can use the Stripe.js.

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

like image 885
Alon Gutman Avatar asked Apr 24 '13 17:04

Alon Gutman


People also ask

How do you customize a Stripe checkout form?

Apply branding You can customize the look and feel of Checkout in the Stripe Dashboard. Go to Branding Settings where you can: Upload a logo or icon. Customize the Checkout page's background color, button color, font, and shapes.

What is a form payment in Stripe?

A form in WP Full Stripe is a set of input fields submitted by the customer that results in a payment or credit card saved in Stripe. A form comprises the following fields, most of which are optional: Email address* Payment amount (amount selector)**


1 Answers

I assume you're talking about Stripe Checkout. See the section on Custom Buttons.

Add the script tag for Stripe Checkout in the <head> of your template file.

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

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

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

Then add an event to open the form in Stripe's modal window when your button is clicked.

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 will use the "token" function as its callback when the response is returned. The id attribute of that response object is the credit card token, which you use to charge the customer.

like image 109
Harry Love Avatar answered Sep 24 '22 01:09

Harry Love