Skip to content

Commit

Permalink
Merge pull request #44 from xsolla/PAYMENTS-15786
Browse files Browse the repository at this point in the history
PAYMENTS-15786: Error event added
  • Loading branch information
A-Neganova authored Aug 21, 2023
2 parents 627a3b1 + 2e512b9 commit a491f07
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 12 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 1.2.10
- [feature] Add new event - error (PS 4)

## 1.2.9
- [feature] Add new event FCP
- [fix] Fixed documentation
Expand Down Expand Up @@ -27,7 +30,7 @@
## 1.2.2 - 2020-10-21

- [fix] Fixed adding custom event
- [feature] Added decorator for handler method `XPayStationWidget.on`
- [feature] Added decorator for handler method `XPayStationWidget.on`

## 1.2.1 - 2020-09-08

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ You can refer to the widget object, using the following methods:
* **status-troubled** — Event when the user was moved on the status page, but the payment failed
* **user-country** — Event when Pay Station have determine user country
* **fcp** — Event when in Pay Station occures fcp
* **error** — Event when in Pay Station 4 occures payment flow errors

You can access list of event using XPayStationWidget.eventTypes object.

Expand Down Expand Up @@ -170,4 +171,4 @@ If a payment method opens in a new browser tab, you must ensure there is a conne
If the conditions for opening a new tab depend on asynchronous code, the event won’t be trusted and result in an error.
Refactoring the callback code that opens a new tab in synchronous style can resolve this problem.

Additional code that runs on a widget button click may also cause similar problems.
Additional code that runs on a widget button click may also cause similar problems.
21 changes: 18 additions & 3 deletions dist/widget.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/widget.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/widget.min.js.map

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ <h3>1914 translation by H. Rackham</h3>
XPayStationWidget.on(XPayStationWidget.eventTypes.FCP, function (event) {
console.log('fcp', arguments, event.detail);
});
XPayStationWidget.on(XPayStationWidget.eventTypes.ERROR, function (event) {
console.log('error event', arguments, event.detail);
});
XPayStationWidget.init(options);
}, false);
var head = document.getElementsByTagName('head')[0];
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xsolla-paystation-widget",
"version": "1.2.9",
"version": "1.2.10",
"description": "PayStation 3 Integration Widget",
"scripts": {
"build": "gulp build",
Expand Down Expand Up @@ -28,4 +28,4 @@
"engines": {
"node": ">=0.10.0"
}
}
}
11 changes: 10 additions & 1 deletion src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ module.exports = (function () {
STATUS_TROUBLED: 'status-troubled',
STATUS_DONE: 'status-done',
USER_COUNTRY: 'user-country',
FCP: 'fcp'
FCP: 'fcp',
ERROR: 'error'
};

var DEFAULT_CONFIG = {
Expand Down Expand Up @@ -200,6 +201,10 @@ module.exports = (function () {
that.triggerCustomEvent(App.eventTypes.FCP, event.detail);
}

function handleError(event) {
that.triggerCustomEvent(App.eventTypes.ERROR, event.detail);
}

this.postMessage = null;
if ((new Device).isMobile() && !this.config.iframeOnly) {
var childWindow = new ChildWindow;
Expand All @@ -219,11 +224,13 @@ module.exports = (function () {
childWindow.off('status', handleStatus);
childWindow.off(App.eventTypes.USER_COUNTRY, handleUserLocale);
childWindow.off(App.eventTypes.FCP, handleFcp);
childWindow.off(App.eventTypes.ERROR, handleError);
childWindow.off('close', handleClose);
});
childWindow.on('status', handleStatus);
childWindow.on(App.eventTypes.USER_COUNTRY, handleUserLocale);
childWindow.on(App.eventTypes.FCP, handleFcp);
childWindow.on(App.eventTypes.ERROR, handleError);
childWindow.open(url, this.config.childWindow);
that.childWindow = childWindow;
} else {
Expand All @@ -244,11 +251,13 @@ module.exports = (function () {
lightBox.off('status', handleStatus);
lightBox.off(App.eventTypes.USER_COUNTRY, handleUserLocale);
lightBox.off(App.eventTypes.FCP, handleFcp);
lightBox.off(App.eventTypes.ERROR, handleError);
lightBox.off('close', handleClose);
});
lightBox.on('status', handleStatus);
lightBox.on(App.eventTypes.USER_COUNTRY, handleUserLocale);
lightBox.on(App.eventTypes.FCP, handleFcp);
lightBox.on(App.eventTypes.ERROR, handleError);
lightBox.openFrame(url, this.config.lightbox);
that.childWindow = lightBox;
}
Expand Down
3 changes: 3 additions & 0 deletions src/childwindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ module.exports = (function () {
that.message.on('fcp', function (event) {
that.triggerEvent('fcp', event.detail);
});
that.message.on('error', function (event) {
that.triggerEvent('error', event.detail);
});
};

switch (options.target) {
Expand Down
3 changes: 3 additions & 0 deletions src/lightbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,9 @@ module.exports = (function () {
this.message.on('fcp', (function (event) {
this.triggerEvent('fcp', event.detail);
}).bind(this));
this.message.on('error', (function (event) {
this.triggerEvent('error', event.detail);
}).bind(this));

// Resize
window.addEventListener(handleResizeEventName, lightBoxResize);
Expand Down
2 changes: 1 addition & 1 deletion src/version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = '1.2.9';
module.exports = '1.2.10';

0 comments on commit a491f07

Please sign in to comment.