2019-09-11 20:19:50 +10: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-10-10 13:52:55 +11:00
|
|
|
const amounts = settings.discourse_patrons_amounts.split("|");
|
2019-09-11 20:19:50 +10:00
|
|
|
|
|
|
|
this.setProperties({
|
|
|
|
confirmation: false,
|
2019-09-12 11:21:27 +10:00
|
|
|
currency: settings.discourse_donations_currency,
|
|
|
|
amounts,
|
|
|
|
amount: amounts[0]
|
2019-09-11 20:19:50 +10:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
closeModal() {
|
2019-09-12 07:14:16 +10:00
|
|
|
this.set("paymentError", false);
|
|
|
|
this.set("confirmation", false);
|
2019-09-11 20:19:50 +10:00
|
|
|
},
|
|
|
|
|
2019-09-13 13:46:32 +10:00
|
|
|
handleConfirmStripeCard(paymentMethod, receiptEmail) {
|
|
|
|
this.set("receiptEmail", receiptEmail);
|
2019-09-12 07:14:16 +10:00
|
|
|
this.set("confirmation", paymentMethod);
|
2019-09-11 20:19:50 +10:00
|
|
|
},
|
|
|
|
|
|
|
|
confirmStripeCard() {
|
2019-09-13 13:46:32 +10:00
|
|
|
const data = {
|
2019-09-13 14:34:06 +10:00
|
|
|
payment_method_id: this.confirmation.id,
|
2019-09-13 13:46:32 +10:00
|
|
|
amount: this.amount,
|
2019-09-13 14:34:06 +10:00
|
|
|
receipt_email: this.receiptEmail
|
2019-09-13 13:46:32 +10:00
|
|
|
};
|
|
|
|
|
2019-09-13 13:52:41 +10:00
|
|
|
this.stripePaymentHandler(data).then(paymentIntent => {
|
|
|
|
if (paymentIntent.error) {
|
|
|
|
this.set("paymentError", paymentIntent.error);
|
|
|
|
} else {
|
2019-09-14 18:31:11 +10:00
|
|
|
this.paymentSuccessHandler(paymentIntent.id);
|
2019-09-11 20:19:50 +10:00
|
|
|
}
|
2019-09-13 13:52:41 +10:00
|
|
|
});
|
2019-09-12 07:14:16 +10:00
|
|
|
}
|
|
|
|
}
|
2019-09-11 20:19:50 +10:00
|
|
|
});
|