Comments (5)
Hey @StApostol
Sorry you're running into issue here, but I'm not quite sure I understand your problem. Why are you trying to access a key called currency
? The list-payouts API responds with currency_code
and that is the value you should be reading from.
But when converting
Can you elaborate more on this
Cheers!
from square-php-sdk.
@zenmasterjobo I'll try to explain my problem in code.
$apiClient = new \Square\SquareClient([
'customUrl' => 'https://connect.squareup.com',
'environment' => 'production',
'accessToken' => $accessToken,
]);
$response = $apiClient->getPayoutsApi()->getPayout($payoutId);
assert($response instanceof \Square\Http\ApiResponse);
$result = $response->getResult();
assert($result instanceof \Square\Models\ListPayoutsResponse);
$payouts = $result->getPayoutEntries();
As a result, the $payouts variable contains an array of objects of the Square\Models\Payout class. In further logic I can't get the currency because it is not filled in the object.
When I add a method to the Square\Models\Money class, the property is filled in
public function setCurrencyCode(?string $currency): void
{
$this->currency = $currency;
}
I think the main problem is that in the rest of the API the amount_money
object is represented by the amount
and currency
properties (https://developer.squareup.com/reference/square/payments-api/get-payment). But in this API (https://developer.squareup.com/reference/square/payouts-api/list-payouts) uses amount
and currency_code
, so jsonMapper does not fill the object correctly
from square-php-sdk.
Ahhh, yes - I understand your issue now, thanks for writing this up!
So this is actually bug with the payouts
api endpoint, that we are still working on fixing.
In the meantime the workarounds that you can use here.
-
You can
$result = $response->getBody()
which will give you the raw JSON response. You can then parse that and grabcurrency_code
from there. -
For a given Square account, the currency will always be the same. So if you are just working with this one Square Account that is in
AUD
you can just use that assumption
Sorry for the unfavorable workarounds right now. The Payouts API team is actively working on how to best mitigate this bug.
Let me know if you need clarification or have further questions!
from square-php-sdk.
@zenmasterjobo Thanks, hopefully the API will be fixed. Can you suggest how to get a list of payments and orders for payout more efficiently?
My current method
- get payout entries
- extract payment and refund ids
- for each id get information from payment or refund API
- extract order ids
- get orders information via batch order API
from square-php-sdk.
Yeah, I'll try to remember to update this thread when that fix goes through!
And I think what you have there makes sense. I tried to think of some other spots you could shortcut on, but I don't think you can.
from square-php-sdk.
Related Issues (20)
- when uploading image it is adding image/jpeg for Content-Type ? HOT 4
- this sdk is the worst api i've ever worked with HOT 1
- PHP8.2 HOT 4
- difference in api explorer and sdk for creating a device code with product type set HOT 2
- 415 Unsupported Media Type while trying to use getInvoice HOT 2
- Order type and sources should be cleaned up HOT 4
- "failed to open stream: No such file or directory" in error in JsonMapper.php file. HOT 4
- Singular name, should be plural? HOT 2
- Fatal error when `php_uname()` is disabled for security reasons. HOT 6
- Now getCheckoutPageUrl() returning a Reletive url HOT 3
- Description set using `setDescriptionHtml` does not show up in the sandbox dashboard HOT 10
- `InvalidArgumentException: Invalid Url format.` when using any custom server URL HOT 2
- Error: Class 'Square\SquareClient' not found HOT 1
- Fatal Error for DELIVERY Orders HOT 7
- open_basedir restriction error in JsonMapper HOT 1
- unirest-php has removed static entities in the latest release HOT 2
- PHP version required HOT 2
- Support mocking of `HttpClient` in `SquareClient
- Has error related to booking api HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from square-php-sdk.