0
Apple Pay를 내 앱에 설정하면 기기에서 실행할 때 제대로 작동하는 것으로 보입니다. 스트라이프를 결제 처리기로 사용했지만 스트라이프로 토큰을 보내지는 않지만 내 iPhone의 디지털 지갑에 표시된 신용 카드로 청구하는 것 같습니다.Apple Pay and Stripe : 토큰이 스트라이프로 전송되지 않습니다.
오전 데 문제는 내가 "터치 ID 결제 수단 '한 번 눌러, 내 애플 지불 시트에 체크 표시를 얻을 수 있지만, 다음 페이지는 엑스 코드에 표시한다는 것입니다 :
코드 애플 지불에 대한 & 스트라이프
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
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