Paypal payout using Firebase Functions

Hey friends.
I have an app where there are two types of users, User A makes payments to Paypal and User B who gets paid by Paypal.
This app uses Firebase Functions.
The problem i am having is the payoutRequest - posting a url request so that i can pay User B. Below is the code i am using but it isn’t working in IOS.
I am also including the code i use for Android that does work (for those who know both IOS and Android). I tried to take the code that works and try to do the same in IOS but not working.

PayoutRequest: IOS:

let email = txtPayoutEmail.text!

    let url = ""

    let params : Parameters = [
        "uid": self.uid! as String,
        "email": email
    let headers : HTTPHeaders = [
        "Content-Type": "application/json",
        "Authorization": "Your Token",
        "cache-control": "no-cache"

    let myData = try? params, options: [])
    //print("data: \(String(describing: myData))")

    Alamofire.request(url, method: .post, parameters: params, encoding: JSONEncoding.default, headers: headers)
        .validate(statusCode: 200..<300)
        .validate(contentType: ["application/json"])
        .responseData(completionHandler: { (response) in

            switch response.result {
            case .success:
                let parsedObject = try! JSONSerialization.jsonObject(with: myData!, options: .allowFragments)
                NSLog("parsed: \(parsedObject)")

            case .failure(let error):

Below is the code I used for the same function, but in Android:

PayoutRequest: Android

public static final MediaType MEDIA_TYPE = MediaType.parse("application/json");
ProgressDialog progress;

private void payoutRequest() {

    progress = new ProgressDialog(this);
    progress.setTitle("Processing your payout ...");
    progress.setMessage("Please Wait .....");

    // HTTP Request ....
    final OkHttpClient client = new OkHttpClient();

    // in json - we need variables for the hardcoded uid and Email
    JSONObject postData = new JSONObject();

    try {
        postData.put("uid", FirebaseAuth.getInstance().getCurrentUser().getUid());
        postData.put("email", mPayoutEmail.getText().toString());

    } catch (JSONException e) {

    // Request body ...
    RequestBody body = RequestBody.create(MEDIA_TYPE, postData.toString());

    // Build Request ...
    final Request request = new Request.Builder()
            .addHeader("Content-Type", "application/json")
            .addHeader("cache-control", "no-cache")
            .addHeader("Authorization", "Your Token")

    client.newCall(request).enqueue(new Callback() {
        public void onFailure(Call call, IOException e) {
            // something went wrong right off the bat

        public void onResponse(Call call, Response response) throws IOException {
            // response successful ....
            // refers to response.status('200') or ('500')
            int responseCode = response.code();
            if (response.isSuccessful()) {
                switch(responseCode) {
                    case 200:
                                "Payout Successful!", Snackbar.LENGTH_LONG)

                    case 500:
                                "Error: no payout available", Snackbar

                                "Error: couldn't complete the transaction",

            } else {
                        "Error: couldn't complete the transaction",


Please help if you can. I have been working on this for over a year and i am stumped. This is my first time working with Firebase Functions and Paypal, not to mention url requests of any kind.

Thank you in advance :slight_smile:

~ Liz ~