我能够从 Apple Pay 成功检索所有数据,包括加密的支付数据、名字、姓氏和账单地址。但是,我似乎无法弄清楚如何从 Apple Pay 结帐期间显示的“联系人”部分中检索电话号码和电子邮件地址。我需要检索这些值,以便将它们提交给我的下游支付提供商。请帮忙:
extension ViewController: PKPaymentAuthorizationViewControllerDelegate {
/* USER HAS AUTHORIZED PAYMENT */
func paymentAuthorizationViewController(controller: PKPaymentAuthorizationViewController!, didAuthorizePayment payment: PKPayment!, completion: ((PKPaymentAuthorizationStatus) -> Void)!) {
//Declare a dictionary of request parameters
var parameters = Dictionary<String, String>()
//Get Encrypted Payment Data from AP
parameters["encryptedPayment_data"] = payment.token.paymentData.base64EncodedStringWithOptions(nil)
let billingAddress: ABRecord = payment.billingAddress
parameters["billTo_firstName"] = ABRecordCopyValue(billingAddress, kABPersonFirstNameProperty).takeRetainedValue() as? String
parameters["billTo_lastName"] = ABRecordCopyValue(billingAddress, kABPersonLastNameProperty).takeRetainedValue() as? String
//Extract billing address from ABRecord format and assign accordingly
let addressProperty: ABMultiValueRef = ABRecordCopyValue(billingAddress, kABPersonAddressProperty).takeUnretainedValue() as ABMultiValueRef
if let dict: NSDictionary = ABMultiValueCopyValueAtIndex(addressProperty, 0).takeUnretainedValue() as? NSDictionary {
parameters["billTo_street1"] = dict[String(kABPersonAddressStreetKey)] as? String
parameters["billTo_city"] = dict[String(kABPersonAddressCityKey)] as? String
parameters["billTo_state"] = dict[String(kABPersonAddressStateKey)] as? String
parameters["billTo_postalCode"] = dict[String(kABPersonAddressZIPKey)] as? String
parameters["billTo_country"] = dict[String(kABPersonAddressCountryKey)] as? String //"United States"
}
//Can't figure out how to obtain these from Apple Pay!
parameters["billTo_email"] = "null@sample.com"
parameters["billTo_phoneNumber"] = "5555555555"