0
私のアプリでApple Payを設定すると、デバイスで実行しているときに正常に動作するようです。ストライプを支払い処理担当者として使用していますが、ストライプにトークンを送信していませんが、iPhoneのデジタルウォレットに記載されているクレジットカードに請求しているようです。Apple Pay and Stripe:トークンがストライプに送信されない
私が午前問題は、私は「タッチIDで支払う」を押した後、私はAppleの有料シートにチェックマークを取得しますが、以下のページをXcodeで表示されていることである:
アップルペイ&ストライプ
var paymentSucceeded: Bool = false
func paymentAuthorizationViewController(_ controller: PKPaymentAuthorizationViewController,
didAuthorizePayment payment: PKPayment, completion: @escaping (PKPaymentAuthorizationStatus) -> Void) {
STPAPIClient.shared().createToken(with: payment) { (token, error) in
print("I am here")
if error != nil {
completion(.failure)
print("failed")
} else {
self.paymentSucceeded = true
completion(.success)
print("woohoo")
}
self.createBackendCharge(with: token!, completion: completion)
print("created Backend Charge")
self.postStripeToken(token: token!)
print("posted stripe token")
}
} // paymentAuthorizationViewController(didAuthorizePayment)
func createBackendCharge(with token: STPToken, completion: @escaping (_: PKPaymentAuthorizationStatus) -> Void) {
//We are printing Stripe token here, you can charge the Credit Card using this token from your backend.
print("Stripe Token is \(token)")
completion(.success)
} // createBackendCharge func
func paymentAuthorizationViewControllerDidFinish(_ controller: PKPaymentAuthorizationViewController) {
controller.dismiss(animated: true, completion: {
if (self.paymentSucceeded) {
// show a receipt page
}
})
} // paymentAuthorizationViewControllerDidFinish()
@IBAction func applePayPressed(_ sender: UIButton) {
// we have already accepted the request from viewDriverBids
// all that remains is to complete payment
print("enable apple pay")
// send user to Apple Pay to make payment
let paymentNetworks = [PKPaymentNetwork.visa, .masterCard, .interac, .discover, .amex]
if PKPaymentAuthorizationViewController.canMakePayments(usingNetworks: paymentNetworks) {
paymentRequest = PKPaymentRequest()
paymentRequest.currencyCode = "CAD"
paymentRequest.countryCode = "CA"
paymentRequest.merchantIdentifier = "merchant.com.xxx"
paymentRequest.supportedNetworks = paymentNetworks
paymentRequest.merchantCapabilities = .capability3DS
paymentRequest.requiredShippingAddressFields = [.all]
paymentRequest.paymentSummaryItems = self.rydes()
let applePayVC = PKPaymentAuthorizationViewController(paymentRequest: paymentRequest)
applePayVC.delegate = self
self.present(applePayVC, animated: true, completion: {
rRydeHandler.Instance.completeApplePay()
self.paymentComplete = true
self.updateDriverInfoView()
})
} else {
print("Tell the user they need to set up Apple Pay!")
}
} // applePayPressed func ACTION
バックエンド・サーバ・FUNC
0のコードfunc postStripeToken(token: STPToken) {
let URL = "http://localhost/donate/payment.php"
let params = ["stripeToken": token.tokenId,
"amount": Int(self.driverInfoView.rydeFare.text!)!,
"currency": "cad",
"description": self.riderName] as [String : Any]
let manager = AFHTTPSessionManager()
manager.post(URL, parameters: params, success: { (operation, responseObject) -> Void in
if let response = responseObject as? [String: String] {
let alertController = UIAlertController(title: response["status"], message: response["message"], preferredStyle: .alert)
let defaultAction = UIAlertAction(title: "OK", style: .default, handler: nil)
alertController.addAction(defaultAction)
self.present(alertController, animated: true, completion: nil)
}
}) { (operation, error) -> Void in
self.handleError(error as NSError)
print(error)
}
}
どのように私はこの問題を解決することができますように助けていただければ幸いです。
お返事ありがとうございます。私はいくつかのブレークポイントを入れました、私はそれがバックエンドのサーバー機能と関係があると思っていますが、私は何がわかりません。 – LizG
クラッシュの原因となっている行が正確にわかる場合に役立ちます。 –
Fabricをインストールしてトークンの送信を妨害していたようです。すべてが元気です。 – LizG