#vell_2x
1 messages · Page 1 of 1 (latest)
Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- vell-customer-mobile, 6 hours ago, 5 messages
- vell_2x, 20 hours ago, 9 messages
Hello! Stripe Terminal is our approach to collecting payments in person using physical Stripe card readers. Are you using Terminal?
If you're trying to create a Stripe Customer using nothing but an iOS app that's not possible, Customers need to be created on your server.
Your iOS can make a request to your server to trigger creation of a Customer.
Ok. The issue I am having is when I make the POST a customer is created but none of the data is being passed (name, ect.)
Can you share the code you're using to create a Customer?
ok I am using swift5
You can't create a Customer from your iOS app's Swift code.
func createStripeCustomer(customers: [String: Any], completion: @escaping (Result<String, Error>) -> Void) {
// URL for the API endpoint
let urlString = "URLString"
guard let url = URL(string: urlString) else {
completion(.failure(NSError(domain: "Invalid URL", code: 0, userInfo: nil)))
return
}
// Prepare the request
var request = URLRequest(url: url)
request.httpMethod = "POST"
// Convert the array of dictionaries to JSON data
let jsonData: Data
do {
jsonData = try JSONSerialization.data(withJSONObject: customers)
request.httpBody = jsonData
print(jsonData)
} catch {
completion(.failure(error))
return
}
// Set the content type
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
// Create a URLSession task for the request
let task = URLSession.shared.dataTask(with: request) { (data, response, error) in
if let error = error {
completion(.failure(error))
return
}
// Check if data is present
guard let data = data else {
completion(.failure(NSError(domain: "No data received", code: 0, userInfo: nil)))
return
}
// Convert the response data to a string (you may need to adjust this based on the actual response format)
if let customerId = String(data: data, encoding: .utf8) {
completion(.success(customerId))
} else {
completion(.failure(NSError(domain: "Unable to parse response", code: 0, userInfo: nil)))
}
}
// Start the URLSession task
task.resume()
}
You need to creat your Customer on your server, with your secret API key.
For that to work you would need to have your secret API key in your iOS app, which would let anyone get to it, which would mean they could do almost anything on your Stripe account.