Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
API
To get the refunds for a payment, you can do:
Or*:
Or (booo! don't do this! ❌):
Now, you can also do it in a way more native to JavaScript:
This makes
_links
and_embedded
redundant entirely ‒ and candidates for removal in 4.0.0.[*] the version with
_embedded
is not great, as it can produceundefined
; whereas the first and last versions will always produce a (potentially empty) array.Internal
getRefunds
internally uses the embedded refunds if present, or fetches them if not.Caveats
getRefunds
"sometimes" uses refunds which were embedded when the payment was fetched, refunds which were created in the timeframe between thepayments.get
andgetRefunds
calls might or might not appear in the array. This might be confusing. However, this library doesn't guarantee to keep any data "fresh". I feel consumers of this library should be aware that data they keep in memory for longer periods of time becomes stale, in general.getRefunds
ends up calling the endpoint (because no refunds were embedded), that endpoint will return a limited number of refunds as it applies pagination. This might be unexpected. I am currently unsure how this compares to embedding refunds. Does the API return all refunds when embedded? I'll look into this before releasing.order.getPayments()
has an odd implementation.