Constructor
new ApplePay(options)
You cannot use this constructor directly. Use braintree.apple-pay.create instead.
Parameters:
Name | Type | Description |
---|---|---|
options |
object | Options |
- Source:
Methods
createPaymentRequest(paymentRequest) → {external:ApplePayPaymentRequest}
Merges a payment request with Braintree defaults
The following properties are assigned to paymentRequest
if not already defined
- countryCode
- currencyCode
- merchantCapabilities
- supportedNetworks
Parameters:
Name | Type | Description |
---|---|---|
paymentRequest |
external:ApplePayPaymentRequest | The payment request details to apply on top of those from Braintree. |
- Source:
Example
var applePay = require('braintree-web/apple-pay');
applePay.create({client: clientInstance}, function (createErr, applePayInstance) {
// ...
var paymentRequest = applePay.createPaymentRequest({
total: {
label: 'My Company',
amount: '19.99'
});
console.log(paymentRequest);
// { total: { }, countryCode: 'US', currencyCode: 'USD', merchantCapabilities: [ ], supportedNetworks: [ ] }
performValidation(options, callback) → {void}
Validates the merchant website, as required by ApplePaySession before payment can be authorized.
Parameters:
Name | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | Options Properties
|
||||||||||||||||
callback |
callback | The second argument, |
- Source:
Example
var applePay = require('braintree-web/apple-pay');
applePay.create({client: clientInstance}, function (createErr, applePayInstance) {
var session = new ApplePaySession(1, {
// This should be the payment request object that
// contains the information needed to display the payment sheet.
});
session.onvalidatemerchant = function (event) {
applePay.performValidation({
validationURL: event.validationURL
}, function(err, validationData) {
if (err) {
console.error(err);
session.abort();
return;
}
session.completeMerchantValidation(validationData);
});
};
});
tokenize(options, callback) → {void}
Tokenizes an Apple Pay payment.
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
options |
object | Options Properties
|
||||||
callback |
callback | The second argument, |
- Source:
Example
var applePay = require('braintree-web/apple-pay');
applePay.create({client: clientInstance}, function (createErr, applePayInstance) {
var session = new ApplePaySession(1, { });
session.onpaymentauthorized = function (event) {
applePay.tokenize({
token: event.payment.token
}, function (err, tokenizedPayload) {
if (err) {
session.completePayment(ApplePaySession.STATUS_FAILURE);
return;
}
session.completePayment(ApplePaySession.STATUS_SUCCESS);
// Send the tokenizedPayload to your server.
});
};
});