title: iOS App Stripe Integration With PHP On Server Side
body: <p>I have the issue with Stripe Integration on iOS App.</p>
  
  <p>According Stripe doc, </p>
  
  <p>1) iOS app need to generate the token first and pass that token to php lib at own server</p>
  
  <pre>
  import UIKit
  import Stripe
  
  class ViewController: UIViewController, STPPaymentCardTextFieldDelegate {
  
      let paymentTextField = STPPaymentCardTextField()
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          Stripe.setDefaultPublishableKey("pk_test_xxxxxxxxxxxxxxxxxxxxx")
  
          // Do any additional setup after loading the view, typically from a nib.
  
          paymentTextField.frame = CGRectMake(15, 15, CGRectGetWidth(self.view.frame) - 30, 44)
          paymentTextField.delegate = self
          view.addSubview(paymentTextField)
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
      }
  
      @IBAction func save(sender: AnyObject) {
          if let card:STPCardParams = paymentTextField.cardParams {
              STPAPIClient.sharedClient().createTokenWithCard(card) { (token, error) -> Void in
                  if let error = error  {
                      print(error)
                  } else if let token = token {
                          self.createBackendChargeWithToken(token) { status in
                      }
                  }
              }
          }
      }
  
      func createBackendChargeWithToken(token: STPToken, completion: PKPaymentAuthorizationStatus -> ()) {
          let url = NSURL(string: "http://localhost:7777/myproject/index.php/rest/stripe/submit")!
          let request = NSMutableURLRequest(URL: url)
          request.HTTPMethod = "POST"
  
          let body = "stripeToken=\(token.tokenId)"
  
          print(body)
  
          request.HTTPBody = body.dataUsingEncoding(NSUTF8StringEncoding)
          let configuration = NSURLSessionConfiguration.ephemeralSessionConfiguration()
          let session = NSURLSession(configuration: configuration)
  
          print(request)
          let task = session.dataTaskWithRequest(request) { (data, response, error) -> Void in
              if error != nil {
                  completion(PKPaymentAuthorizationStatus.Failure)
                  print("Fail to charge")
              }
              else {
                  completion(PKPaymentAuthorizationStatus.Success)
                  print("Successfully Charegd")
                  print(PKPaymentAuthorizationStatus.Success)
              }
          }
          task.resume()
      }
  }
  
  </pre>
  
  <p>2) php lib execute like this to Stripe API </p>
  
  <pre>
  
  \Stripe\Stripe::setApiKey("sk_test_xxxxxxxxxxxxxxxxxxxxxxx");
  
  if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
  
  $token = $_POST['stripeToken'];
  
  $charge = \Stripe\Charge::create(array(
                      "amount" => 5000, // amount in cents, so need to multiply with 100 .. $amount * 100
                      "currency" => "usd",
                      "source" => $token,
                      "description" => "Test Order From iOS"
                  )); 
  }
  </pre>
  
  <p>3) It is working fine and I can receive that Payment Transaction at Stripe Dashboard. </p>
  
  <p>4) But when I switch to another stripe account(like client account), I need to change for <b>Publishable Key(From Mobile App)</b> and <b>Secret Key(From Server Side)</b> Right?</p>
  
  <p>5) After changed new keys, Payment could not receive any more at Stripe Dashboard. Here is logs message from Stripe.</p>
  
  <pre>
  {error: {
  type: "invalid_request_error"
  message: "Stripe no longer supports API requests made with TLS 1.0. Please initiate HTTPS connections with TLS 1.2 or later. You can learn more about this  at https://stripe.com/blog/upgrading-tls."}
  }
  </pre>
  
  <p><b>Error Status is 401</b></p>
  
  <p>My Question is why app is not working when switch API(Publishable &amp; Secret) Keys from another Stripe Account?  </p>