openfoodfoundation / openfoodnetwork

Connect suppliers, distributors and consumers to trade local produce.
https://www.openfoodnetwork.org
GNU Affero General Public License v3.0
1.12k stars 724 forks source link

[City OFN Voucher] A shopper can use a VINE voucher #12949

Open rioug opened 3 weeks ago

rioug commented 3 weeks ago

⚠️ When working on this use the Clockify code: Citi Food Vouchers: #1A. https://github.com/openfoodfoundation/openfoodnetwork/issues/11922 Citi OFN Voucher - VINE Integration ⚠️

What? Why?

What should we test?

Set up: _!! Make sure "connectedapps" feature is turned on Logged as an enterprise to VINE, in the backoffice as an enterprise manager :

Log into VINE https://vine-staging.openfoodnetwork.org.au/ :

Normal checkout

Make sure you have an order cycle set up with the enterprise you connected to VINE set as a distributor, set your team in VINE to "OFN test - merchant"

Same voucher used by multiple enterprise

Same as above, but this time use a $50 voucher from the first voucher set and place order under $50 so we can use the voucher with another enterprise.

Failed redemption :
Admin - capture a payment
Failed redemption:
Admin - create a payment
Failed redemption:
Report

Check the voucher are showing up correctly on the following reports:

Release notes

Changelog Category (reviewers may add a label for the release notes):

The title of the pull request will be included in the release notes.

rioug commented 1 week ago

I am yet to address all the review comments, but I had to do a bit more work to handle this requirement:

I ended up creating Vouchers::Vine because in the end it is different enough from Vouchers::FlatRate to have its' own class, mainly because we now have different requirement on the uniqueness of a voucher code.

@dacook I started looking into handling API error with exception, and you are right it should be a bit cleaner than the current solution.

Moving back into code review because I think it's worth Maikel having a look even if it's not totally finished