Skip to content

Instantly share code, notes, and snippets.

@ArchieR7
Created July 5, 2017 15:38
Show Gist options
  • Select an option

  • Save ArchieR7/5d62145db53f403de29a86943ad2b68d to your computer and use it in GitHub Desktop.

Select an option

Save ArchieR7/5d62145db53f403de29a86943ad2b68d to your computer and use it in GitHub Desktop.
func applePay() {
let request = PKPaymentRequest()
request.merchantIdentifier = "merchant.tw.archie"
request.merchantCapabilities = .capability3DS
request.countryCode = "US"
request.currencyCode = "USD"
request.supportedNetworks = [.visa]
request.paymentSummaryItems = [PKPaymentSummaryItem.init(label: "Archie's shake hand", amount: 2000, type: .final)]
request.shippingType = .storePickup
let contact = PKContact()
contact.emailAddress = "xpopchi@gmail.com"
var name = PersonNameComponents()
name.nickname = "Archie"
contact.name = name
let phone = CNPhoneNumber(stringValue: "0912345678")
contact.phoneNumber = phone
request.billingContact = contact
let applePayController = PKPaymentAuthorizationViewController(paymentRequest: request)
applePayController.delegate = self
present(applePayController, animated: true, completion: nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment