|
101 | 101 | (s/optional-key :transfer) s/Str} |
102 | 102 | (ss/stripe-object "charge"))) |
103 | 103 |
|
| 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 | + |
104 | 147 | ;; ## Charge API Requests |
105 | 148 |
|
106 | 149 | (s/defn create-charge :- (ss/Async) |
|
130 | 173 | ([req :- RefundReq opts :- h/RequestOptions] |
131 | 174 | (h/post-req (format "charges/%s/refund" (:id req)) |
132 | 175 | (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))))) |
134 | 188 |
|
135 | 189 | ;; ## Helpers |
136 | 190 |
|
|
0 commit comments