wirecatllc / blesta-stripe-universal

Blesta Non-merchant payment gateway using Stripe Checkout
MIT License
6 stars 6 forks source link

Adds currency conversion - fixes a few bugs I was having #7

Closed xboxfly15 closed 4 months ago

xboxfly15 commented 4 months ago

I have been using these changes for a week without issue so thought I'd contribute back the changes and share them with everyone.

NeverBehave commented 4 months ago

I am not entirely sure about the ref id overflow, by any chance you have a screenshot of that? Email is not an unique id to ref an transaction so I am kinda hesitate to do that.

xboxfly15 commented 4 months ago

Here's a screenshot of the overflow. (not using real numbers, dont worry) You can also see how the Blesta PayPal gateway does it too, I was using them previously - they use email address. bc65131714566266ocKbFu961b 1 What it looks like with my change a8cae61714566351JjJERi962b 1

I understand email not being as unique but the transaction ID is already provided (That's what the "pi_" number is), which is what Stripe use to identify payments, you can see that by going to your Payments view in the Stripe dashboard.


At least, I don't think the checkout session ID should be used, Stripe doesn't normally provide that(You have to dig around in the events and logs section to find it), they're very long, and Stripe doesn't provide a filter for it which makes them hard to use.

xboxfly15 commented 4 months ago

I had a better idea: Use the customer ID that Stripe provides for someone(they're a number that starts with gcus or cus), they're short enough so they don't overflow and it's unique, plus Stripe provides a filter for customer ID in "More filters" where you can enter the ID to see all payments from that person.

b6c9b41714567276TUZl4a963b 1

EDIT: Looking at this though, it seems the customer ID is rarely populated https://docs.stripe.com/api/checkout/sessions/object#checkout_session_object-customer only if the customer_creation is set to always.. but customer_email is populated so I'm not sure why. If thats due to the webhook being used? This is why I used the customer_email in the first place because its populated else we the customer ID can be used instead.

NeverBehave commented 4 months ago

Actually lets separate this into a different PR for now --- The currency fix and the SDK update seems to be fine.

For SDK update I believe the vendor folder also needs to be updated.