This plugin is a basic implementation of Stripe and Apple Pay with the purpose of returning a useable stripe token.
- Follow the steps on https://stripe.com/docs/mobile/apple-pay to get your certs generated
- In your Xcode project, go to Capabilities and enable Apple Pay
- Install the plugin
cordova plugin add https://github.com/mtshare/cordova-plugin-applepay
- iOS
- ApplePay.getAllowsApplePay
- ApplePay.setMerchantId
- ApplePay.setStripePublishableKey
- ApplePay.getStripeToken
Returns successfully if the device is setup for Apple Pay (correct software version, correct hardware & has card added).
ApplePay.getAllowsApplePay(successCallback, errorCallback);
Set your Apple-given merchant ID. This overrides the value obtained from ApplePayMerchant in Info.plist.
ApplePay.setMerchantId('merchant.apple.test', successCallback, errorCallback);
Set your Stripe Publishable Key. This overrides the value obtained from StripePublishableKey in Info.plist.
ApplePay.setStripePublishableKey('pk_test_stripekey', successCallback, errorCallback);
Request a stripe token for an Apple Pay card.
- amount (string)
- description (string)
- currency (uppercase string) [EUR, USD, etc...]
ApplePay.getStripeToken(amount, description, currency, successCallback, errorCallback);
{
"id": "tok_STRIPE_TOKEN",
"card": {
"id": "card_CARD_ID",
"brand": "MasterCard",
"last4": "1234",
"exp_year": "2050",
"exp_month": "6"
}
}
ApplePay.setMerchantId('merchant.apple.test');
ApplePay.getAllowsApplePay(function() {
ApplePay.getStripeToken({
amount: '10.00',
description: 'Delicious Cake',
currency: 'USD'
}, function(results) {
alert('Your token is: ' + results.id);
}, function() {
alert('Error getting payment info');
});
}, function() {
alert('User does not have apple pay available');
});