Search code examples
iosparse-platformstripe-paymentsparse-cloud-code

Sending data back from cloud code


I use Stripe in Parse Cloud Code and receive a Stripe ID (String), but I want to send that stripe id back to Xcode. What is the best way of doing this?

I've tried to first of all send the stripe ID to Parse, and in Xcode I do a fetch... But I think that's a bad idea because if there are multiple users processing the payments at same time, it's hard to get the right stripe ID for the user.


Solution

  • To return data from cloud code, take a look at this tutorial post.

    Basically all you have to do is return the stripe id like this

    response.success(stripeId);
    

    Receiving data looks like this :

    [PFCloud callFunctionInBackground:@"averageStars" withParameters:params block:^(NSString *stripeId, NSError *error) {
        if (!error) {
            // code
        }
    }];