Skip to content

Commit b590bfe

Browse files
committed
Add application fee refund
1 parent 1e9a3df commit b590bfe

File tree

2 files changed

+56
-4
lines changed

2 files changed

+56
-4
lines changed

src/clj/stripe/charge.clj

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,49 @@
101101
(s/optional-key :transfer) s/Str}
102102
(ss/stripe-object "charge")))
103103

104+
;; ## Application Fees:
105+
106+
(s/defschema ApplicationFeeID
107+
(s/named s/Str "Application fee identifier."))
108+
109+
(s/defschema ApplicationFeeRefundID
110+
(s/named s/Str "Application fee refund identifier."))
111+
112+
(declare ApplicationFee)
113+
114+
(s/defschema ApplicationFeeRefund
115+
(-> {:id ApplicationFeeRefundID
116+
:amount ss/Currency
117+
:balance_transaction (s/either b/BalanceTxID b/BalanceTx)
118+
:created ss/UnixTimestamp
119+
:currency ss/CurrencyID
120+
:fee (s/either ApplicationFeeID ApplicationFee)
121+
:metadata ss/Metadata}
122+
(ss/stripe-object "fee_refund")))
123+
124+
(s/defschema ApplicationFee
125+
(-> {:id ApplicationFeeID
126+
:account s/Str
127+
:amount ss/Currency
128+
:amount_refunded ss/Currency
129+
:application s/Str
130+
:balance_transaction (s/either b/BalanceTxID b/BalanceTx)
131+
:charge (s/named s/Str "Payment ID")
132+
:created ss/UnixTimestamp
133+
:currency ss/CurrencyID
134+
:livemode s/Bool
135+
:originating_transaction ChargeID
136+
:refunded s/Bool
137+
:refunds (ss/sublist [ApplicationFeeRefund])}
138+
(ss/stripe-object "application_fee")))
139+
140+
(s/defschema ApplicationFeeRefundReq
141+
"Supported options for a Stripe application fee refund request."
142+
(-> {:id ChargeID
143+
(s/optional-key :amount) ss/PositiveInt
144+
(s/optional-key :expand) h/Expansion
145+
:metadata ss/Metadata}))
146+
104147
;; ## Charge API Requests
105148

106149
(s/defn create-charge :- (ss/Async)
@@ -130,7 +173,18 @@
130173
([req :- RefundReq opts :- h/RequestOptions]
131174
(h/post-req (format "charges/%s/refund" (:id req))
132175
(assoc opts
133-
:stripe-params (dissoc req :id)))))
176+
:stripe-params (dissoc req :id)))))
177+
178+
;; ## ApplicationFee API Requests
179+
180+
(s/defn refund-app-fee :- (ss/Async ApplicationFeeRefund)
181+
([req :- ApplicationFeeRefundReq]
182+
(refund-app-fee req {}))
183+
([req :- ApplicationFeeRefundReq
184+
opts :- h/RequestOptions]
185+
(h/post-req (format "application_fees/%s/refunds" (:id req))
186+
(assoc opts
187+
:stripe-params (dissoc req :id)))))
134188

135189
;; ## Helpers
136190

src/clj/stripe/schema.cljc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@
4242
([inner]
4343
(s/either inner (Channel inner))))
4444

45-
(def CurrencyID
46-
"Right now just these two are supported."
47-
(s/enum "usd" "cad"))
45+
(def CurrencyID s/Str)
4846

4947
(s/defschema Metadata
5048
"Metadata feature supported by the Stripe API. Keyword keys are converted to strings on the way over.

0 commit comments

Comments
 (0)