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
25
25
26
26
require Logger
27
27
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
+
28
44
def seed_job ( opts \\ % { } ) do
29
45
with { :ok , user } <- Repo . fetch_by ( User , handle: opts . org . handle ) ,
30
46
{ :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
139
139
140
140
@ type t :: Stripe.Charge . t ( )
141
141
def retrieve ( id ) , do: Algora.PSP . client ( __MODULE__ ) . retrieve ( id )
142
+ def retrieve ( id , params ) , do: Algora.PSP . client ( __MODULE__ ) . retrieve ( id , params )
142
143
end
143
144
144
145
@ type setup_intent :: Algora.PSP.SetupIntent . t ( )
You can’t perform that action at this time.
0 commit comments