example-mobile-backend icon indicating copy to clipboard operation
example-mobile-backend copied to clipboard

unable to change the amount charged from iOS app

Open aidan305 opened this issue 4 years ago • 1 comments

I think the amount charged is hardcoded to 10.99 usd. I want to change the amount for the payment intent created I tried the below in my iOS app but it didn't work. any suggestions?

` func createPaymentIntent(completion: @escaping STPJSONResponseCompletionBlock) { var url = URL(string: backendURL)! url.appendPathComponent("create_payment_intent")

    AF.request(url, method: .post, parameters: ["amount": 4000 , "currency" : "USD"])
               .validate(statusCode: 200..<300)
               .responseJSON { (response) in
                switch (response.result){
                case .failure(let error):
                    completion(nil, error)
                case .success(let jsonResponse):
                    completion(jsonResponse as? [String : Any], nil)
                }
           }
}

`

aidan305 avatar Jul 08 '20 11:07 aidan305

Hey @aidan305

We advise against having the client control the amount for security. I'd recommend passing some kind of ID (product ID, cart ID, etc) to the backend and calculate the price there.

yuki-stripe avatar Jul 08 '20 19:07 yuki-stripe