1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-19 13:54:25 +01:00

When a payment schedule was canceled by the payment gateway, inform the user in the interface

TODO: send an in-system notification and an email notification
+ refactor payzen/service and stripe/service to extract notification sending
+ send notifications on state=error
+ in the interface: open a modal dialog to allow the admin to choose an action (cancel/continue by check/continue by transfer)
+ refactor the payment-schedule-tables.ts to extact the item-line logic (the component is getting too big)
This commit is contained in:
Sylvain 2022-01-05 17:16:25 +01:00
parent 61d63889b1
commit f647ebd9e0
6 changed files with 17 additions and 1 deletions

View File

@ -4,6 +4,7 @@
- Ability to create slots in the past
- Ability to disable public account creation
- Ability to select "bank transfer" as the payment mean for a payment schedule
- When a payment schedule was canceled by the payment gateway, inform the user in the interface
- Updated caniuse db
- Optimized the load time of the payment schedules list
- Fix a bug: do not load Stripe if no keys were defined

View File

@ -189,7 +189,9 @@ const PaymentSchedulesTableComponent: React.FC<PaymentSchedulesTableProps> = ({
{t('app.shared.schedules_table.update_card')}
</FabButton>
);
case PaymentScheduleItemState.GatewayCanceled:
case PaymentScheduleItemState.Error:
// if the payment schedule was canceled by the gateway, or
// if the payment is in error, the schedule is over, and we can't update the card
cardUpdateButton.set(schedule.id, true);
if (!isPrivileged()) {

View File

@ -4,7 +4,8 @@ export enum PaymentScheduleItemState {
RequirePaymentMethod = 'requires_payment_method',
RequireAction = 'requires_action',
Paid = 'paid',
Error = 'error'
Error = 'error',
GatewayCanceled = 'gateway_canceled'
}
export enum PaymentMethod {

View File

@ -493,6 +493,7 @@ en:
state_requires_action: "Action required"
state_paid: "Paid"
state_error: "Error"
state_gateway_canceled: "Canceled by the payment gateway"
state_canceled: "Canceled"
method_card: "by card"
method_check: "by check"

View File

@ -78,6 +78,12 @@ class PayZen::Service < Payment::Service
end
def process_payment_schedule_item(payment_schedule_item)
pz_subscription = payment_schedule_item.gateway_subscription.retrieve
if DateTime.parse(pz_subscription['answer']['cancelDate']) < DateTime.current
# the subscription was canceled by the gateway => update the status
payment_schedule_item.update_attributes(state: 'gateway_canceled')
return
end
pz_order = payment_schedule_item.payment_schedule.gateway_order.retrieve
transaction = pz_order['answer']['transactions'].last
return unless transaction_matches?(transaction, payment_schedule_item)

View File

@ -94,6 +94,11 @@ class Stripe::Service < Payment::Service
def process_payment_schedule_item(payment_schedule_item)
stripe_key = Setting.get('stripe_secret_key')
stp_subscription = payment_schedule_item.payment_schedule.gateway_subscription.retrieve
if stp_subscription.status == 'canceled'
# the subscription was canceled by the gateway => update the status
payment_schedule_item.update_attributes(state: 'gateway_canceled')
return
end
stp_invoice = Stripe::Invoice.retrieve(stp_subscription.latest_invoice, api_key: stripe_key)
if stp_invoice.status == 'paid'
##### Successfully paid