diff --git a/src/views/pay.blade.php b/src/views/pay.blade.php index f494500..90105ac 100644 --- a/src/views/pay.blade.php +++ b/src/views/pay.blade.php @@ -19,6 +19,7 @@ class MoamalataPay { this.amount = amount; this.merchantReference = merchantReference; this.debug = debug; + this.isCompleteCalled = false } log(data) { @@ -68,6 +69,7 @@ class MoamalataPay { TrxDateTime: secureHashResponse.DateTimeLocalTrxn, SecureHash: secureHashResponse.secureHash, completeCallback: function(data) { + this.isCompleteCalled = true; window.dispatchEvent( new CustomEvent('moamalatCompleted', { detail: data @@ -91,9 +93,11 @@ class MoamalataPay { }); }, cancelCallback: function() { - window.dispatchEvent( - new CustomEvent('moamalatCancel') - ) + if (!this.isCompleteCalled) { + window.dispatchEvent( + new CustomEvent('moamalatCancel') + ) + } parent_.log({ "status": "canceled" });