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

47 lines
1.1 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
},
handleConfirmStripeCard(paymentMethod) {
2019-09-11 17:14:16 -04:00
this.set("confirmation", paymentMethod);
2019-09-11 06:19:50 -04:00
},
confirmStripeCard() {
const paymentMethodId = this.confirmation.id;
2019-09-11 17:14:16 -04:00
this.stripePaymentHandler(paymentMethodId, this.amount).then(
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
});