Once you’ve successfully set up the Bolt iOS SDK and payment methods, you can customize your Apple Pay checkout button with a few quick lines of code.
In the view controller where you want to show Apple Pay, modify the viewDidLoad()
function to create BoltCheckoutPanelViewController
to include the following fields:
let boltVC = Bolt()
.withPublishableKey(publishableKey)
.withOrderToken(orderToken)
.withMerchantName(merchantName)
.withMerchantAppleId(merchantAppleId)
.withApplePayButton()
Variable |
Definition |
publishableKey |
REQUIRED FIELD FOR EITHER BUTTON. Your publishable key assigned to you by Bolt. The publishable key is a long string of lower and upper case letters and numbers that consists of three sections. |
orderToken |
REQUIRED FIELD FOR EITHER BUTTON. The token created [by calling /v1/merchant/orders ][1] on your backend. |
merchantName |
REQUIRED FIELD FOR APPLE PAY. The name of your merchant as it will be shown on the Apple Pay view controller. |
merchantAppleId |
REQUIRED FIELD FOR APPLE PAY. The id assigned to your merchant by Apple. |
If you want to, you can follow the instructions below to apply the ApplePayButtonDelegate
that can be supplied to withApplePayButton()
to enable Apple Pay Callbacks.
Similarly to BoltCheckoutButtonDelegate
, you can pass BoltApplePayButtonDelegate
to Bolt’s withApplePayButton
method to receive Apple Pay Callbacks. onApplePayClose
is called when the Apple Pay view controller is closed. This is called even when the transaction is successful. onApplePaySuccess
is called when Apple Pay payment is successful.
INFO
As noted earlier, to include the Apple Pay button, you must state .withApplePayButton()
when configuring the Bolt View Controller. This function has an optional parameter called delegate
. To pass the onApplePaySuccess
and onApplePayClose
callback, you must pass in an object which conforms to the BoltApplePayButtonDelegate
protocol for the delegate parameter.
let boltVC = Bolt()
// ...
// ...
.withApplePayButton(delegate: self)
.checkoutPanel()
//
func onApplePayComplete(status: String, reason: String) {
print("bolt apple pay status: \(status), reason: \(reason)")
}
//
func onApplePayClose() {
print("bolt ApplePay on close")
}
}
Apple Pay Responses
Depending on the response to the request, there are a few different statuses - coupled with reasons - that may be returned to onApplePayComplete
.
“Succeeded”
The succeeded
response will return the reason
value of none
.
“Declined”
The declined
response may have several different provided reason
values:
Reason |
What it means |
invalid_amount |
The amount of the purchase is invalid. |
invalid_cvv |
The provided credit card’s CVV number is invalid. |
invalid_cc_number |
The provided credit card number is invalid. |
expired |
The provided credit card has expired. |
risk |
The transaction appears suspicious and has triggered a risk flag. |
lost_stolen |
The provided credit card was reported lost or stolen. |
invalid_merchant_for_card |
The merchant does not accept the card type provided. |
call_issuer |
There is some undetermined cause for an error - contact the issuer. |
WARNING
Should you receive an error
response, rather than one of the declined
responses listed above, please reach out to your CSM.
Next Steps
Now that you’re set up with Apple Pay, you can move on to customizing the shopper’s checkout experience or the setting up the Bolt Button.