#smartkiparis
1 messages ยท Page 1 of 1 (latest)
๐ happy to help
you need to retrieve the charge and expand on refunds
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
which is a list of all refunds that have been applied to a charge
And it will have a sub array of refunds? So I can access through a loop like
foreach ($charge->refunds as $refund) {}
yes
it's actually $charge->refunds.data
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
ok, thanks!
let me know if you need any more help
What is a proper way to make a mock charge object with constructFrom method, that will include a set of fake refunds?
you can create a charge and pay it with these card numbers https://stripe.com/docs/testing#refunds to simulate refunds
Oh, no. That's not what I need
you need to create the refund yourself
In tests I create mock objects with static method for each object
are you talking about unit testing?
$chargeMock = Charge::constructFrom([
'id' => $chargeId,
'refunds' => [...Refund]
]);
I want something like this
yep, unit testing. I mock stripe API and create objects that should be returned
where is this function coming from?
Charge::constructFrom
are you using the stripe-mock https://github.com/stripe/stripe-mock ?
yes but you would need to pass in refunds in the $expandedFields