cordova-plugin-braintree-applepay
v0.0.2
Published
This plugin is a basic implementation of Braintree and Apple Pay with the purpose of returning a Braintree-Token to create a transaction. It works on Cordova / Ionic.
Downloads
6
Readme
Ionic / Cordova Plugin Braintree Apple Pay
This plugin is a basic implementation of Braintree and Apple Pay with the purpose of returning a Braintree-Token to create a transaction. It works on Cordova / Ionic.
Installation
- Setup a Braintree account and follow the steps to create a tokenized key (Account > User > API keys).
- In xCode navigate to the Capabilities and add Apple Pay.
- Install the plugin
cordova plugin add https://github.com/nim901/cordova-plugin-braintree-applepay \
--variable APPLE_PAY_MERCHANT="merchant.com.apple.test"
In xCode < version 8.0 select your app and click on targets. There navigate to Build Phases / Embed Frameworks and select Code Sign on Copy for every file. In xCode >= version 8.0 add braintree frameworks under Targets / Embedded Binaries
For Archiving you have to set Enable Bitcode on Debug in Build Settings in xCode to YES and during the Archiving process uncheck checkbox saying Rebuild from bitcode.
Supported Platforms
- iOS
Methods
- BTApplePay.initialize
- BTApplePay.paymentRequest
BTApplePay.initialize
Must be called before BTApplePay.paymentRequest in order to set the tokenization key provided by Braintree. If this token has not been already generated, it needs to be generated in the Braintree backend. Navigate to Account > My user > API Keys, Tokenizations Keys, Encryption Keys.
BTApplePay.paymentRequest
Is called to open the native Apple Pay payment footer. Options need to be defined. Returns a Braintree token nonce if the generation was successful. This token need to be sent to the server for further processing.
Example
BTApplePay.initialize("tokenization_key",
function () { console.log("init OK!"); },
function (error) { console.error(error); });
var options = {
itemName: "Bicycle for kids",
paymentReceiver: "OX Bar",
amount: "255.50",
countryCode: "SG",
currency: "SGD",
merchantIdentifier: "merchant..."
};
BTApplePay.paymentRequest(options, function (nonce) {
console.log(nonce);
}, function() {
// Catch error
});