example-mobile-backend
example-mobile-backend copied to clipboard
unable to change the amount charged from iOS app
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)
}
}
}
`
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.