Skip to content
Advertisement

Trying to access data returned from Stripe API with Alamofire, but result is not valid JSON

I’m trying to interface a Swift app with the Stripe API, using Alamofire, but I’m having trouble with the returned results. I was expecting valid JSON, but I am getting the following:

JavaScript

I’m using the following PHP code:

JavaScript

How can I get at the JSON inside this object? I tried converting it to json, but then I get nothing. Alamofire doesn’t like it the way it is now. Do I need to somehow strip off the “StripeSetupIntent JSON:”?

Advertisement

Answer

You can access the json object body that came back from the API with getLastResponse():

JavaScript

edit. You can also use json_encode() to produce the json from the object yourself:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement