From 0ece2d9392b719bce277ccc3802c49afd5367dbb Mon Sep 17 00:00:00 2001 From: Douglas Lise Date: Tue, 26 Sep 2023 15:52:13 -0300 Subject: [PATCH] Emit/forward 'error' and 'close' events on AmazonPay frame --- lib/recurly/amazon/amazon-pay.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/recurly/amazon/amazon-pay.js b/lib/recurly/amazon/amazon-pay.js index bd938895f..3b1a624b2 100644 --- a/lib/recurly/amazon/amazon-pay.js +++ b/lib/recurly/amazon/amazon-pay.js @@ -17,10 +17,10 @@ class AmazonPay extends Emitter { path: `/amazon_pay/start?region=${this.region}`, type: Frame.TYPES.WINDOW, defaultEventName - }).on('error', cause => console.log(cause)) - .on('done', results => { - this.emit('token', results); - }); + }) + .on('error', cause => this.emit('error', cause)) // Emitted by js/v1/amazon_pay/cancel + .on('close', () => this.emit('error', 'closed')) // Emitted by RJS Frame when the window is manually closed + .on('done', results => this.emit('token', results)); // Emitted by js/v1/amazon_pay/finish } }