Hi,
I need some helps, advices, for the integration of braintree to meteor, i follow this tutorial:
And I use this boilerplate:
Fisrt i put this code in app/client/imports/app/components/payment-braintree/payment-braintree.html
{{#if paymentProcessing}}
{{ >loading}}
{{else}}
<form id="checkout" method="post">
<div id="payment-form"></div>
<button type="submit" class="btn btn-primary btn-block">Subscribe</button>
</form>
{{/if}}
But i dont really understand this code, and why there is bootstrap button?
And:
import { Template } from 'meteor/templating';
import { Session } from 'meteor/session';
import { Meteor } from 'meteor/meteor';
import braintree from 'braintree-web';
import { Router } from 'meteor/iron:router';
Template.subscribe.helpers({
plan() {
return Session.get('plan');
},
paymentProcessing() {
return Session.get('paymentProcessing');
},
});
Template.subscribe.onCreated(() => {
Meteor.call('getClientToken', (err, clientToken) => {
if (err) {
throw new Meteor.Error(err.statusCode, 'Error getting client token from braintree');
}
braintree.setup(clientToken, 'dropin', {
container: 'payment-form',
paymentMethodNonceReceived(event, nonce) {
Session.set('paymentProcessing', true);
const plan = Session.get('plan');
Meteor.call('subscribeToPlan', nonce, plan, (error, result) => {
Session.set('paymentProcessing', false);
if (error) {
sweetAlert(error.message, 'error');
} else {
sweetAlert({
title: 'Subscription Successful',
text: `You are now subscribed to the ${plan} plan`,
type: 'success',
}, () => {
Router.go('apps');
});
}
});
},
});
});
});
I dont understand the “Router”.
Also, in what file do i need to put this code?
Could somebody give me an exemple of code’s adaptation for the Template helpers?
Thanks in advance.