I need to make this request in Alamofire.
curl https://api.omise.co/charges \
-u $OMISE_SECRET_KEY: \
-d "amount=100000" \
-d "currency=thb" \
-d "card=tokn_test_5g5mep9yrko3vx2f0hx"
I guess it should be something like
let url = "https://api.omise.co/charges"
let parameters: [String: Any] = ["amount": 100000,
"currency": "thb",
"card": token]
AF.request(url, method: .post, parameters: parameters, encoding: JSONEncoding.default).response { response in
switch response.result {
case .success( _):
let data = responseJSON.result.value!
print(data)
case .failure(let error):
print(error.localizedDescription)
}
}
How do I make a request?
I don't know how to handle -u $ OMISE_SECRET_KEY:
.