Posts

Post not yet marked as solved
2 Replies
4.1k Views
I implemented the apple pay with a stripe. When I tap the apple pay button it doesn't show any payment sheet and it always returns the nil value. The code is :applepayButton.isEnabled = Stripe.deviceSupportsApplePay() let merchantIdentifier = "merchant.deyaPayApplepay" let paymentRequest = Stripe.paymentRequest(withMerchantIdentifier: merchantIdentifier, country: "US", currency: "usd") // Configure the line items on the payment request paymentRequest.paymentSummaryItems = [ //PKPaymentSummaryItem(label: "Fancy Hat", amount:NSDecimalNumber(value :amount)), // The final line should represent your company; // it'll be prepended with the word "Pay" (i.e. "Pay iHats, Inc $50") PKPaymentSummaryItem(label: "amount to be added", amount:NSDecimalNumber(value :amount)), ] if Stripe.canSubmitPaymentRequest(paymentRequest) { // Setup payment authorization view controller let paymentAuthorizationViewController = PKPaymentAuthorizationViewController(paymentRequest: paymentRequest) paymentAuthorizationViewController?.delegate = self // Present payment authorization view controller self.present((paymentAuthorizationViewController)!, animated: true,completion: nil) } else { // There is a problem with your Apple Pay configuration print("apple pay is not configred properly"); } } func paymentAuthorizationViewController(_ controller: PKPaymentAuthorizationViewController, didAuthorizePayment payment: PKPayment, completion: @escaping (PKPaymentAuthorizationStatus) -> Void) { STPAPIClient.shared().createToken(with: payment) { (token: STPToken?, error)-> Void in print("Stripe token is \(String(describing: token!))") completion(.success) let b = String(describing: token!) } } func paymentAuthorizationViewControllerDidFinish(_ controller: PKPaymentAuthorizationViewController) { //Dismiss payment authorization view controller dismiss(animated: true, completion: { if (true) { // print("Payment Success") // Show a receipt page... } }) }It always the "apple pay is not configured properly". It is worked fine in simulator but when it runs in real device it shows the else condition rather than if condition. Why it is not working properly in real device
Posted Last updated
.