File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,22 @@ defmodule Algora.Admin do
2525
2626 require Logger
2727
28+ def backfill_charge ( id ) do
29+ with { :ok , tx } <- Repo . fetch_by ( Transaction , id: id ) ,
30+ { :ok ,
31+ % 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
34+ tx
35+ |> change ( % {
36+ gross_amount: gross_amount ,
37+ total_fee: gross_amount - tx . net_amount ,
38+ provider_fee: provider_fee
39+ } )
40+ |> Repo . update ( )
41+ end
42+ end
43+
2844 def seed_job ( opts \\ % { } ) do
2945 with { :ok , user } <- Repo . fetch_by ( User , handle: opts . org . handle ) ,
3046 { :ok , user } <- user |> change ( opts . org ) |> Repo . update ( ) ,
Original file line number Diff line number Diff line change @@ -139,6 +139,7 @@ defmodule Algora.PSP do
139139
140140 @ type t :: Stripe.Charge . t ( )
141141 def retrieve ( id ) , do: Algora.PSP . client ( __MODULE__ ) . retrieve ( id )
142+ def retrieve ( id , params ) , do: Algora.PSP . client ( __MODULE__ ) . retrieve ( id , params )
142143 end
143144
144145 @ type setup_intent :: Algora.PSP.SetupIntent . t ( )
You can’t perform that action at this time.
0 commit comments