Refactor: No need export action on subscribe-show

This commit is contained in:
tudinhtu98 2023-02-13 11:47:29 +07:00
parent af8b27d8d9
commit bc174ee358
3 changed files with 8 additions and 17 deletions

View File

@ -79,28 +79,28 @@ export default Component.extend({
if (authenticationResult && !authenticationResult.error) { if (authenticationResult && !authenticationResult.error) {
return Transaction.finalize(transactionId, planId).then( return Transaction.finalize(transactionId, planId).then(
() => { () => {
this.advanceSuccessfulTransaction(plan); this._advanceSuccessfulTransaction(plan);
e.complete("success"); e.complete("success");
console.log(`Success: ${authenticationResult.paymentIntent.id}`); console.log(`Success: ${authenticationResult.paymentIntent.id}`);
} }
); );
} else if (authenticationResult.error) { } else if (authenticationResult.error) {
console.log("Payment fail"); console.log("Payment fail", authenticationResult.error);
e.complete("fail"); e.complete("fail");
} }
} }
); );
} else { } else {
this.advanceSuccessfulTransaction(plan); this._advanceSuccessfulTransaction(plan);
e.complete("success"); e.complete("success");
console.log(`Success`); console.log(`Success`);
} }
}) })
.catch((result) => { .catch((result) => {
e.complete("fail"); e.complete("fail");
console.log("Payment fail"); console.log("Catch Payment fail");
this.dialog.alert( this.dialog.alert(
result.jqXHR.responseJSON?.errors[0] || result.errorThrown result.jqXHR?.responseJSON?.errors[0] || result.errorThrown
); );
}); });

View File

@ -83,15 +83,6 @@ export default Controller.extend({
}, },
actions: { actions: {
alert(path) {
this.alert(path)
},
handleAuthentication(plan, transaction) {
this.handleAuthentication(plan, transaction)
},
advanceSuccessfulTransaction(plan) {
this._advanceSuccessfulTransaction(plan)
},
stripePaymentHandler() { stripePaymentHandler() {
this.set("loading", true); this.set("loading", true);
const plan = this.get("model.plans") const plan = this.get("model.plans")

View File

@ -46,13 +46,13 @@
}} }}
{{subscribe-google-pay {{subscribe-google-pay
alert=alert
stripe=stripe stripe=stripe
plans=model.plans plans=model.plans
selectedPlan=selectedPlan selectedPlan=selectedPlan
promoCode=promoCode promoCode=promoCode
advanceSuccessfulTransaction=(action "advanceSuccessfulTransaction") alert=alert
handleAuthentication=(action "handleAuthentication") _advanceSuccessfulTransaction=_advanceSuccessfulTransaction
handleAuthentication=handleAuthentication
}} }}
{{/if}} {{/if}}