GEWIS / sudosos-backend

SudoSOS is a Node.js-based Bar and POS system made for study association GEWIS.
https://sudosos.gewis.nl
GNU Affero General Public License v3.0
6 stars 3 forks source link

[Feature] Automagic Invoices #197

Open JustSamuel opened 4 months ago

JustSamuel commented 4 months ago

What would you like?

Create automatic invoices for enabled users. These invoices will be more like receipts and should make it easier for the BACPM.

Why is this needed?

How could it be implemented?

Automatic invoices will be separate from normal invoices. The BACPM can still make manual invoices (for things such as CEB account).

The implementation will be that automatic invoices should be counted in the "transactionOverview" where as manual invoices are not. This could be tricky, so this should be done carefully.

We can use an internal reference on the invoice (SUDOSOSXXXX) which will make it clear that it is an automatic invoice. It was also suggested that an automatic invoice also create a "paymentRequest" from stripe such that an account can instantly pay using stripe. This will allow us to send payment links (hopefully that doesn't kill our spam score)

But the main gist is to turn automatic invoices into automatic "receipts" which will be paid for through SudoSOS. This also means that they do not have to be incorporated into the BAC bookkeeping as they will be reported within the transactionOverview.

Other information

No response

tomudding commented 4 months ago

It was also suggested that an automatic invoice also create a "paymentRequest" from stripe such that an account can instantly pay using stripe. This will allow us to send payment links (hopefully that doesn't kill our spam score)

What would the payment links look like? I assume you will get some URL that looks like {sudosos_domain}/invoice/{long_random_string} that prompts you with the interface from the paymentRequest?

How will you handle expiration of URL/invoice? How will you deal with accidental double payments because Stripe's webhooks are delayed?

JustSamuel commented 4 months ago

It was also suggested that an automatic invoice also create a "paymentRequest" from stripe such that an account can instantly pay using stripe. This will allow us to send payment links (hopefully that doesn't kill our spam score)

What would the payment links look like? I assume you will get some URL that looks like {sudosos_domain}/invoice/{long_random_string} that prompts you with the interface from the paymentRequest?

How will you handle expiration of URL/invoice? How will you deal with accidental double payments because Stripe's webhooks are delayed?

I was more thinking that you get a link like sudosos.gewis.nl/pay/HASH and it follows the almost exact same flow as the topup. Difference would be that in this case the amount is not variable and invoice users can "top up".

tomudding commented 4 months ago

The reason I am asking this is because Stripe also have an invoice service, which could prevent us from abusing PaymentRequests and not have to deal with iDEAL payments not working for some people. It can also handle expiry automatically and I would assume that you would not have to implement any logic to prevent double payments.

However, that requires a bit more setup and has some other issues that are difficult or impossible to solve (e.g. generic treasurer e-mail address instead of BAC treasurer). So I think your suggestion is preferable but requires proper testing to ensure it cannot break.

Stripe invoice: image

Stripe e-mail: image

Payment page ('invoice: no' because this is a draft): image

Yoronex commented 3 months ago

We have decided to implement this all within SudoSOS, but it will require some extra work and things to keep in mind: