title: Apple Pay and Stripe: Token not being sent to Stripe
body: <p>Set up Apple Pay in my app and it seems to work fine when running on device.  Using Stripe as the payment processor but it is not sending the token to Stripe, but seems to be charging the credit card listed in my iPhone's digital wallet.  </p>
  
  <p>The problem I am having is that once I press the "Pay with Touch ID", I get a check mark in my Apple Pay sheet but the following page appears in Xcode:</p>
  
  <p><a href="https://i.stack.imgur.com/cWl2P.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cWl2P.png" alt="error"></a></p>
  
  <p><strong>Code for Apple Pay &amp; Stripe</strong></p>
  
  <pre><code>    var paymentSucceeded: Bool = false
  
  
  func paymentAuthorizationViewController(_ controller: PKPaymentAuthorizationViewController,
                                          didAuthorizePayment payment: PKPayment, completion: @escaping (PKPaymentAuthorizationStatus) -&gt; 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) -&gt; 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
  </code></pre>
  
  <p><strong>backend server func</strong></p>
  
  <pre><code>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) -&gt; 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) -&gt; Void in
          self.handleError(error as NSError)
          print(error)
      }
  }
  </code></pre>
  
  <p>How can I resolve this issue?</p>