Object that implements IKushki.
Visual and behavioral options for the Apple Pay button:
"black"
| "white"
→ button style."en-US"
| "es-ES"
| "es-MX"
| "pt-BR"
→ language/region for the button."add-money" | "book" | "buy" | "check-out" | "continue" | "contribute" | "donate" | "order" | "pay" | "plain" | "reload" | "rent" | "set-up" | "subscribe" | "support" | "tip" | "top-up"
→ defines the text/action displayed on the button.Instance of ICardApplePay.
HTML container:
<div id="kushki-apple-pay-button"></div>
Initialize Kushki instance:
const kushkiOptions: KushkiOptions = {
publicCredentialId: 'public-merchant-id',
inTest: true
};
Initialize CardApplePay instance:
const options: ApplePayOptions = {
style: "black",
locale: "es-MX",
type: "pay"
};
try {
const kushkiInstance: IKushki = await init(kushkiOptions);
const cardApplePay: ICardApplePay = await initApplePayButton(kushkiInstance, options);
} catch (e: any) {
console.error(e.message);
}
Using events and requesting the Apple Pay token:
try {
const cardApplePay: ICardApplePay = await initApplePayButton(kushkiInstance, options);
cardApplePay.onCancel(() => {
console.log("Payment canceled");
});
cardApplePay.onClick(async () => {
try {
const token = await cardApplePay.requestApplePayToken({
displayName: "DEMO",
countryCode: "EC",
currencyCode: "USD",
amount: 20
});
console.log(token);
} catch (error) {
console.log("Error requesting token: ", error);
}
});
} catch (e: any) {
console.error(e.message);
}
Generated using TypeDoc
Introduction
Function to render the Apple Pay button and initialize an instance of ICardApplePay.
For this method to work correctly, you must include the following container in your project’s HTML: