Constructor
new ApplePay(options)
You cannot use this constructor directly. Use braintree.applePay.create instead.
Parameters:
Name | Type | Description |
---|---|---|
options |
object |
Options |
- Source:
Members
merchantIdentifier
A special merchant ID which represents the merchant association with Braintree. Required when using ApplePaySession.canMakePaymentsWithActiveCard
.
- Source:
Example
var promise = ApplePaySession.canMakePaymentsWithActiveCard(applePayInstance.merchantIdentifier);
promise.then(function (canMakePaymentsWithActiveCard) {
if (canMakePaymentsWithActiveCard) {
// Set up Apple Pay buttons
}
});
Methods
createPaymentRequest(paymentRequest) → {external:ApplePayPaymentRequest}
Merges a payment request with Braintree defaults to return an {external:ApplePayPaymentRequest}.
The following properties are assigned to paymentRequest
if not already defined. Their default values come from the Braintree gateway.
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 (applePayErr, applePayInstance) {
if (applePayErr) {
// Handle error here
return;
}
var paymentRequest = applePayInstance.createPaymentRequest({
total: {
label: 'My Company',
amount: '19.99'
}
});
var session = new ApplePaySession(3, paymentRequest);
// ...
performValidation(options, callbackopt) → {Promise|void}
Validates your merchant website, as required by ApplePaySession
before payment can be authorized.
Parameters:
Name | Type | Attributes | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
Options Properties
|
||||||||||
callback |
callback |
<optional> |
The second argument, |
- Source:
Example
var applePay = require('braintree-web/apple-pay');
applePay.create({client: clientInstance}, function (applePayErr, applePayInstance) {
if (applePayErr) {
// Handle error here
return;
}
var paymentRequest = applePayInstance.createPaymentRequest({
total: {
label: 'My Company',
amount: '19.99'
}
});
var session = new ApplePaySession(3, paymentRequest);
session.onvalidatemerchant = function (event) {
applePayInstance.performValidation({
validationURL: event.validationURL,
displayName: 'My Great Store'
}, function (validationErr, validationData) {
if (validationErr) {
console.error(validationErr);
session.abort();
return;
}
session.completeMerchantValidation(validationData);
});
};
});
teardown(callbackopt) → {Promise|void}
Cleanly tear down anything set up by create.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
callback |
<optional> |
Called once teardown is complete. No data is returned if teardown completes successfully. |
- Source:
Examples
applePayInstance.teardown();
applePayInstance.teardown(function () {
// teardown is complete
});
tokenize(options, callbackopt) → {Promise|void}
Tokenizes an Apple Pay payment. This will likely be called in your ApplePaySession
's onpaymentauthorized
callback.
Parameters:
Name | Type | Attributes | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
options |
object |
Options Properties
|
|||||||
callback |
callback |
<optional> |
The second argument, |
- Source:
Example
var applePay = require('braintree-web/apple-pay');
applePay.create({client: clientInstance}, function (applePayErr, applePayInstance) {
if (applePayErr) {
// Handle error here
return;
}
var paymentRequest = applePayInstance.createPaymentRequest({
total: {
label: 'My Company',
amount: '19.99'
}
});
var session = new ApplePaySession(3, paymentRequest);
session.onpaymentauthorized = function (event) {
applePayInstance.tokenize({
token: event.payment.token
}, function (tokenizeErr, tokenizedPayload) {
if (tokenizeErr) {
session.completePayment(ApplePaySession.STATUS_FAILURE);
return;
}
// Send the tokenizedPayload to your server here!
// Once the transaction is complete, call completePayment
// to close the Apple Pay sheet
session.completePayment(ApplePaySession.STATUS_SUCCESS);
});
};
// ...
});
Type Definitions
tokenizePayload :object
Properties:
Name | Type | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
nonce |
string |
The payment method nonce. |
||||||||||||||||||||||||||||||
details |
object |
Additional details. Properties
|
||||||||||||||||||||||||||||||
description |
string |
A human-readable description. |
||||||||||||||||||||||||||||||
type |
string |
The payment method type, always |
||||||||||||||||||||||||||||||
binData |
object |
Information about the card based on the bin. Properties
|
- Source: