discourse-subscriptions/assets/javascripts/discourse/components/donation-form.js.es6

53 lines
1.2 KiB
Plaintext
Raw Normal View History

2019-09-11 06:19:50 -04:00
import { default as computed } from "ember-addons/ember-computed-decorators";
export default Ember.Component.extend({
@computed("confirmation.card.last4")
last4() {
return this.get("confirmation.card.last4");
},
init() {
this._super(...arguments);
const settings = Discourse.SiteSettings;
2019-09-11 21:51:28 -04:00
const amounts = Discourse.SiteSettings.discourse_patrons_amounts.split("|");
2019-09-11 06:19:50 -04:00
this.setProperties({
confirmation: false,
2019-09-11 21:21:27 -04:00
currency: settings.discourse_donations_currency,
amounts,
amount: amounts[0]
2019-09-11 06:19:50 -04:00
});
},
actions: {
closeModal() {
2019-09-11 17:14:16 -04:00
this.set("paymentError", false);
this.set("confirmation", false);
2019-09-11 06:19:50 -04:00
},
2019-09-12 23:46:32 -04:00
handleConfirmStripeCard(paymentMethod, receiptEmail) {
this.set("receiptEmail", receiptEmail);
2019-09-11 17:14:16 -04:00
this.set("confirmation", paymentMethod);
2019-09-11 06:19:50 -04:00
},
confirmStripeCard() {
2019-09-12 23:46:32 -04:00
const data = {
paymentMethodId: this.confirmation.id,
amount: this.amount,
receiptEmail: this.receiptEmail
};
this.stripePaymentHandler(data).then(
2019-09-11 17:14:16 -04:00
paymentIntent => {
if (paymentIntent.error) {
this.set("paymentError", paymentIntent.error);
} else {
2019-09-11 17:43:27 -04:00
this.paymentSuccessHandler();
2019-09-11 17:14:16 -04:00
}
2019-09-11 06:19:50 -04:00
}
2019-09-11 17:14:16 -04:00
);
}
}
2019-09-11 06:19:50 -04:00
});