Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How does one check for the response #5

Closed
lstables opened this issue Nov 21, 2018 · 14 comments
Closed

How does one check for the response #5

lstables opened this issue Nov 21, 2018 · 14 comments

Comments

@lstables
Copy link

lstables commented Nov 21, 2018

Hi, I using this package with Laravel and all is good, but I need to get the response back from Revolut, so I can save the UUID's they send to out database.

So this is the code I have:

// At the top I have     use RevolutPHP\Client as Revolut;
$pay = new Revolut($this->api_key); 
            $counterparty = $pay->counterparties->create(
                array (
                'company_name' => user()->companies()->first()->name,
                'bank_country' => 'GB',
                'currency' => 'GBP',
                'account_no' => $request->account_no,
                'sort_code' => $request->sort_code,
                "email" => user()->email,
                "phone" => user()->tel,
                'profile_type' => 'business',
                'address' => 
                    array (
                    'street_line1' => user()->companies()->first()->address_line_1,
                    'street_line2' => user()->companies()->first()->address_line_2,
                    'region' => '',
                    'postcode' => user()->companies()->first()->postcode,
                    'city' => user()->companies()->first()->city,
                    'country' => 'GB',
                    ),
                )
            );

Soon as the response is sent back from Revoult I want to be able to grab that data and do what I want with it, how can one achieve this?

@sverraest
Copy link
Owner

sverraest commented Nov 21, 2018

Hi, great that you're using this package.
The response itself is parsed automatically as an array.
So your variable $counterparty will be an array that has the following information:

https://revolutdev.github.io/business-api/#add-revolut-counterparty

I would wrap this code in a try / catch block though.

@lstables
Copy link
Author

Apologies this is within a try /catch

try {
            $pay = new Revolut($this->api_key); 
            $counterparty = $pay->counterparties->create(
                array (
                'company_name' => user()->companies()->first()->name,
                'bank_country' => 'GB',
                'currency' => 'GBP',
                'account_no' => $request->account_no,
                'sort_code' => $request->sort_code,
                "email" => user()->email,
                "phone" => user()->tel,
                'profile_type' => 'business',
                'address' => 
                    array (
                    'street_line1' => user()->companies()->first()->address_line_1,
                    'street_line2' => user()->companies()->first()->address_line_2,
                    'region' => '',
                    'postcode' => user()->companies()->first()->postcode,
                    'city' => user()->companies()->first()->city,
                    'country' => 'GB',
                    ),
                )
            );
        } catch (Exception $e) {
            \Log::info($e);
            return response()->json(['message' => 'There was something wrong, please try again.', 404]);
        }

So $pay as the array in, but once this is sent to Revolut I want to get their response to I can save the successful creation details.

@sverraest
Copy link
Owner

sverraest commented Nov 21, 2018

What do you get when you do print_r($counterparty); after this call?

@lstables
Copy link
Author

Nothing it seems.... :(

@lstables
Copy link
Author

Seems there's an error either my end or theirs:

POST https://b2b.revolut.com/api/1.0/counterparty` resulted in a `400 Bad Request` response: {"message":"Sort code is in invalid format","code":4002}

Even though sending within the array like so "sort_code" => "$request->sort_code",

@sverraest
Copy link
Owner

The sort_code parameter should be a string like "223344".
Are you including any hyphens maybe? "22-33-44" should be posted as "223344"

@lstables
Copy link
Author

Yeah just posting as "000000"

@sverraest
Copy link
Owner

Can you get a full request body / headers which is giving you this error?
Please check that you omit any sensitive data such as API Keys.
Otherwise I suggest to contact Revolut for Business directly.

@lstables
Copy link
Author

Yeah API keys everything looks good as I did when I tested it before, so I will contact them directly.

@sverraest
Copy link
Owner

Ok, do update the issue here if you hear back, thanks!

@lstables
Copy link
Author

Will do, although they aren't the fastest cats :)

Awesome package btw 👍

@sverraest
Copy link
Owner

Was Revolut able to solve your issue? Anything specific to the package?

@lstables
Copy link
Author

Nope, to be honest they were lacking in these areas shall we say. Also it appears they don't do what we wanted it to do, so for now at least we are staying with Stripe.

@lstables
Copy link
Author

PS, the package is fine, just Revolut not so...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants