1

所以我刚开始使用 Apple Pay,我设置了商家 ID 和 CSR,我相信我设置正确,但是在提示 Apple Pay View Controller 时,我的程序崩溃了,说:

2016-09-05 00:29:47.244 MoneySender[876:325291] Payment request is invalid: check your entitlements

2016-09-05 00:29:47.259 MoneySender[876:325264] Connection to remote alert view service failed

我的代码:

 let request = PKPaymentRequest()

    let SupportedPaymentNetworks = [PKPaymentNetworkVisa, PKPaymentNetworkMasterCard, PKPaymentNetworkAmex]
    let ApplePayMerchantID = "myMerchantID"
    request.merchantIdentifier = ApplePayMerchantID
    request.supportedNetworks = SupportedPaymentNetworks
    request.merchantCapabilities = PKMerchantCapability.Capability3DS
    request.countryCode = "US"
    request.currencyCode = "USD"
    let contact = PKContact()
    let nc = NSPersonNameComponents()
    nc.familyName = "myName"
    nc.givenName = "myNamw"
    nc.middleName = "myName"
    var phoneNumber = CNPhoneNumber()
    phoneNumber = CNPhoneNumber(stringValue: "myNumber")
    contact.emailAddress = "myEmail"
    contact.name = nc
    let postalAddress = CNMutablePostalAddress()
    postalAddress.city = "myCity"
    postalAddress.country = "United States of America"
    postalAddress.postalCode = "myPostal"
    postalAddress.state = "myState"
    postalAddress.street = "myAddress"

    contact.postalAddress = postalAddress
    contact.phoneNumber = phoneNumber
    request.billingContact = contact
    request.paymentSummaryItems = [
        PKPaymentSummaryItem(label: item_description, amount: NSDecimalNumber(double: item_price))
    ]

     let applePayController = PKPaymentAuthorizationViewController(paymentRequest: request)


    self.presentViewController(applePayController, animated: true, completion: nil)
    applePayButton.hidden = !PKPaymentAuthorizationViewController.canMakePaymentsUsingNetworks(SupportedPaymentNetworks)

权利文件:

在此处输入图像描述

4

1 回答 1

3

这是完整的权利文件:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>com.apple.developer.in-app-payments</key>
    <array>
        <string>my-merchant-id</string>
    </array>
</dict>
</plist>
于 2016-09-05T05:02:16.157 回答