1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-30 19:52:20 +01:00

wait for the first payzen transaction + fix initial amount

This commit is contained in:
Sylvain 2021-06-03 14:28:52 +02:00
parent dc0a75e52d
commit ea774e2080
2 changed files with 32 additions and 26 deletions

View File

@ -1,5 +1,5 @@
import axios, { AxiosInstance } from 'axios'
// compile
const token: HTMLMetaElement = document.querySelector('[name="csrf-token"]');
const client: AxiosInstance = axios.create({
headers: {

View File

@ -24,7 +24,7 @@ class PayZen::Service < Payment::Service
rrule: rrule(payment_schedule),
order_id: order_id
}
unless first_item.details['adjustment']&.zero?
unless first_item.details['adjustment']&.zero? && first_item.details['other_items']&.zero?
params[:initial_amount] = first_item.amount
params[:initial_amount_number] = 1
end
@ -51,6 +51,11 @@ class PayZen::Service < Payment::Service
def process_payment_schedule_item(payment_schedule_item)
pz_order = payment_schedule_item.payment_schedule.payment_gateway_objects.find { |pgo| pgo.gateway_object_type == 'PayZen::Order' }.gateway_object.retrieve
transaction = pz_order['answer']['transactions'].last
transaction_date = DateTime.parse(transaction['creationDate']).to_date
# check that the transaction matches the current PaymentScheduleItem
if transaction['amount'] == payment_schedule_item.amount &&
transaction_date >= payment_schedule_item.due_date.to_date &&
transaction_date <= payment_schedule_item.due_date.to_date + 7.days
if transaction['status'] == 'PAID'
PaymentScheduleService.new.generate_invoice(payment_schedule_item,
payment_method: 'card',
@ -78,6 +83,7 @@ class PayZen::Service < Payment::Service
payment_schedule_item.update_attributes(state: 'error')
end
end
end
private