Skip to content

Instantly share code, notes, and snippets.

@Akiyamka
Last active April 15, 2018 12:31
Show Gist options
  • Select an option

  • Save Akiyamka/afec4865307e883e98f05e1d41c31020 to your computer and use it in GitHub Desktop.

Select an option

Save Akiyamka/afec4865307e883e98f05e1d41c31020 to your computer and use it in GitHub Desktop.
const processors = {
paypal: {
checker: urlParams.PayerID && urlParams.paymentId && urlParams.token,
resolver: () => {
this.savePaypalPayment(urlParams).then(
() => this.toast.success('Payment is successfull'),
e => this.toast.error(e || 'Payment is not successfull'),
);
},
},
webmoney: {
checker: Object.keys(urlParams).includes('webmoney_success'),
resolver: () => {
if (JSON.parse(urlParams.webmoney_success)) {
this.toast.success('Payment is successfull');
} else {
this.toast.error('Payment is canceled');
}
},
},
};
};
const currentPaymentRedirect = Object.values(processors).find(
proc => proc.checker,
);
if (currentPaymentRedirect) {
currentPaymentRedirect.resolver();
this.sendMetricks();
// this.router.navigateToRoute('ROUTE_CAMPAIGNS');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment