Skip to content

Commit c53f6df

Browse files
committed
fix: Admin.backfill_charge/1 impl
1 parent ea75d9e commit c53f6df

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/algora/admin/admin.ex

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,15 @@ defmodule Algora.Admin do
2929
with {:ok, tx} <- Repo.fetch_by(Transaction, id: id),
3030
{:ok,
3131
%Stripe.Charge{
32-
balance_transaction: %Stripe.BalanceTransaction{currency: "usd", amount: gross_amount, fee: provider_fee}
33-
}} <- PSP.Charge.retrieve(tx.provider_id, expand: ["balance_transaction"]) do
32+
balance_transaction: %Stripe.BalanceTransaction{currency: currency, amount: gross_amount, fee: provider_fee}
33+
}} <- Algora.PSP.Charge.retrieve(tx.provider_id, expand: ["balance_transaction"]) do
34+
gross_amount = Money.from_integer(gross_amount, currency)
35+
provider_fee = Money.from_integer(provider_fee, currency)
36+
3437
tx
3538
|> change(%{
3639
gross_amount: gross_amount,
37-
total_fee: gross_amount - tx.net_amount,
40+
total_fee: Money.sub!(gross_amount, tx.net_amount),
3841
provider_fee: provider_fee
3942
})
4043
|> Repo.update()

0 commit comments

Comments
 (0)