com.razorpay.cordova
Advanced tools
Comparing version 1.1.0 to 1.1.1
{ | ||
"name": "com.razorpay.cordova", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Cordova/Phonegap bindings for Razorpay's Mobile SDKs", | ||
@@ -5,0 +5,0 @@ "main": "Readme.md", |
@@ -22,7 +22,7 @@ # Cordova/Phonegap bindings for Razorpay's Mobile SDKs | ||
cordova platform add browser # optional | ||
cordova plugin add https://github.com/razorpay/razorpay-cordova.git --save | ||
cordova plugin add com.razorpay.cordova --save | ||
``` | ||
(or, `phonegap plugin add https://github.com/razorpay/razorpay-cordova.git --save`) | ||
(or, `phonegap plugin add com.razorpay.cordova --save`) | ||
@@ -99,3 +99,21 @@ ## Integration code | ||
``` | ||
### Android Lifecycle Guide | ||
***It is recomended that you read [this](https://cordova.apache.org/docs/en/latest/guide/platforms/android/#lifecycle-guide) first before proceeding with this section*** | ||
Since our plugin launches a new activity on Android, the cordova activity goes in the background | ||
and might get destroyed by the Android System. For this scenario, you need to add the following code to make sure the | ||
payment result is delivered after the cordova activity is recreated: | ||
``` | ||
// You need to register an event listener for the `resume` event | ||
document.addEventListener('resume', onResume, false); | ||
var onResume = function(event) { | ||
// Re-register the payment success and cancel callbacks | ||
RazorpayCheckout.on('payment.success', successCallback) | ||
RazorpayCheckout.on('payment.cancel', cancelCallback) | ||
// Pass on the event to RazorpayCheckout | ||
RazorpayCheckout.onResume(event); | ||
}; | ||
``` | ||
### Things to be taken care: | ||
@@ -102,0 +120,0 @@ |
@@ -32,3 +32,14 @@ /*global cordova, module*/ | ||
} | ||
}, | ||
onResume: function(event) { | ||
if(event.pendingResult && event.pendingResult.pluginServiceName === 'Checkout'){ | ||
if(event.pendingResult.pluginStatus === "OK") { | ||
this.callbacks['payment.success'](event.pendingResult.result); | ||
} | ||
else { | ||
this.callbacks['payment.cancel'](event.pendingResult.result); | ||
} | ||
} | ||
} | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
1705755
160
127
0