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

Allow refunds using py_ payment token #216

Open
francoisburdy opened this issue Jul 5, 2022 · 2 comments
Open

Allow refunds using py_ payment token #216

francoisburdy opened this issue Jul 5, 2022 · 2 comments

Comments

@francoisburdy
Copy link
Contributor

francoisburdy commented Jul 5, 2022

Hey!

Since 2.4.6, it is possible to make refunds from Payment Intents (pi_) tokens, while the previous version only allowed to use charges tokens, which is great.

However it seems there is a downside in the new implementation that makes impossible to create a refund using a py_ token even though the Stripe API allows it and treat it as a charge token.

In my case, I use Sepa Debits and the API gives me a py_ token only. I found no way to get a ch_ or pi_ token associated to the payment.

If I try to pass a py_ token to the Refund->create() method (which I got working for long) , now I get an a No such payment_intent: 'py_[...]' error.

For now I manage to make refund bypassing the Refund->create() method, this way :

$stripe->refunds()->_post('refunds', [
    'amount' => $amount,
    'charge' => $my_py_token,
]);

A solution can be to invert the ternary mentioned below, to use the charge mode by default, and the PaymentIntent only if $paymentId is a pi_ token ?

return substr($paymentId, 0, 2) === 'ch' ? 'charge' : 'payment_intent';

Many thanks! and long live this package!

@francoisburdy francoisburdy changed the title Allow refund payment using py_ token Allow refunds payment using py_ token Jul 5, 2022
@francoisburdy francoisburdy changed the title Allow refunds payment using py_ token Allow refunds using py_ payment token Jul 5, 2022
@brunogaspar
Copy link
Member

So ch_ and py_ are for charges? Do you know if there's any other prefixes?

I don't mind having it switched around, as long as everything passes :)

You up for doing a pull request?

Thank you!

@francoisburdy
Copy link
Contributor Author

No idea if there are other prefixes that can be used, as the stripe documentation is not extensive on this topic.

All I can say is that according to my tests, the post refund endpoint behaves the same with py_ and ch_ tokens :)

See my pull request #217

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