When the payment widget is called, after a successful transaction, the pay
function should be executed, but in the console I see the error this.pay() is not a function
. What could be the problem?
A widget function
openWidget() {
// @ts-ignore
let widget = new PaytureWidget({
Key : "Merchant",
Amount : this.model.sum,
Product : "Payment №1",
Domain : 2,
OnTransactionCompleted : function(success: any) {
this.pay()
}
})
}
And pay()
if needed:
async pay() {
const mapProduct = (product: ShoppingCartProduct): UserProduct => {
return {
productId: product.id,
count: product.multiplicator,
price: product.price
}
}
const userProducts = this.sumupProducts.map(mapProduct)
const accountBalance = await this.userProductsDataService.addProducts(userProducts);
if (accountBalance !== -1) {
this.paymentEventService.emitSuccess(accountBalance);
this.model.products = this.model.products.filter(x => !x.checked);
this.sumupProducts = [];
this.model.sum = this.getShoppingCartSum();
this.eventService.emit(StarOneEventType.ChangedNumberOfProductsInShoppingCart);
} else {
this.paymentEventService.emitFail("Payment Fail");
}
}