Implement the function handleMessage which will check whether the transaction has been completed or not.
function handleMessage(e) {
if (typeof e.data === 'string') {
try {
let data = JSON.parse(e.data);
} catch (e) {}
if (data && data.payrexx) {
jQuery.each(data.payrexx, function(name, value) {
switch (name) {
case 'transaction':
if (typeof value === 'object') {
if (value.status === 'confirmed') {
//handling success
} else {
//handling failure
}
}
break;
}
});
}
}
}
At this point, the iFrame won't have the rights to push any message to its parent (your mobile app). That's why you need the following code snippet called each time the iFrame content has been loaded.
This will tell our Payrexx Gateway which Origin the parent has (most time it will be NULL for web apps). But it is actually necessary to tell the Payrexx page this information, so it will be able to push messages to your main window.
Example: React Native
Example code how to integrate Payrexx in a React Native application.