1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
use crate::api::*;
use crate::{ApiError, ClientConfig, HttpClient, QueryBuilder, RequestOptions};
use reqwest::Method;
pub struct MoneyInClient {
pub http_client: HttpClient,
}
impl MoneyInClient {
pub fn new(config: ClientConfig) -> Result<Self, ApiError> {
Ok(Self {
http_client: HttpClient::new(config.clone())?,
})
}
/// Authorize a card transaction. This returns an authorization code and reserves funds for the merchant. Authorized transactions aren't flagged for settlement until [captured](/developers/api-reference/moneyin/capture-an-authorized-transaction).
/// Only card transactions can be authorized. This endpoint can't be used for ACH transactions.
/// <Tip>
/// Consider migrating to the [v2 Authorize endpoint](/developers/api-reference/moneyinV2/authorize-a-transaction) to take advantage of unified response codes and improved response consistency.
/// </Tip>
///
/// # Arguments
///
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
pub async fn authorize(
&self,
request: &AuthorizeRequest,
options: Option<RequestOptions>,
) -> Result<AuthResponse, ApiError> {
self.http_client
.execute_request(
Method::POST,
"MoneyIn/authorize",
Some(serde_json::to_value(&request.body).map_err(ApiError::Serialization)?),
QueryBuilder::new()
.serialize(
"forceCustomerCreation",
request.force_customer_creation.clone(),
)
.build(),
options,
)
.await
}
/// <Warning>
/// This endpoint is deprecated and will be sunset on November 24, 2025. Migrate to [POST `/capture/{transId}`](/developers/api-reference/moneyin/capture-an-authorized-transaction)`.
/// </Warning>
///
/// Capture an [authorized
/// transaction](/developers/api-reference/moneyin/authorize-a-transaction) to complete the transaction and move funds from the customer to merchant account.
///
/// # Arguments
///
/// * `trans_id` - ReferenceId for the transaction (PaymentId).
/// * `amount` - Amount to be captured. The amount can't be greater the original total amount of the transaction. `0` captures the total amount authorized in the transaction. Partial captures aren't supported.
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
pub async fn capture(
&self,
trans_id: &str,
amount: f64,
options: Option<RequestOptions>,
) -> Result<CaptureResponse, ApiError> {
self.http_client
.execute_request(
Method::GET,
&format!("MoneyIn/capture/{}/{}", trans_id, amount),
None,
None,
options,
)
.await
}
/// Capture an [authorized transaction](/developers/api-reference/moneyin/authorize-a-transaction) to complete the transaction and move funds from the customer to merchant account.
///
/// You can use this endpoint to capture both full and partial amounts of the original authorized transaction. See [Capture an authorized transaction](/developers/developer-guides/pay-in-auth-and-capture) for more information about this endpoint.
///
/// <Tip>
/// Consider migrating to the [v2 Capture endpoint](/developers/api-reference/moneyinV2/capture-an-authorized-transaction) to take advantage of unified response codes and improved response consistency.
/// </Tip>
///
/// # Arguments
///
/// * `trans_id` - ReferenceId for the transaction (PaymentId).
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
pub async fn capture_auth(
&self,
trans_id: &str,
request: &CaptureRequest,
options: Option<RequestOptions>,
) -> Result<CaptureResponse, ApiError> {
self.http_client
.execute_request(
Method::POST,
&format!("MoneyIn/capture/{}", trans_id),
Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
None,
options,
)
.await
}
/// Make a temporary microdeposit in a customer account to verify the customer's ownership and access to the target account. Reverse the microdeposit with `reverseCredit`. Payabli doesn't automatically make microdeposits when you add a bank account, you must manually make the requests.
///
/// This feature must be enabled by Payabli on a per-merchant basis. Contact support for help.
///
/// # Arguments
///
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
pub async fn credit(
&self,
request: &RequestCredit,
options: Option<RequestOptions>,
) -> Result<PayabliApiResponse0, ApiError> {
self.http_client
.execute_request(
Method::POST,
"MoneyIn/makecredit",
Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
QueryBuilder::new()
.serialize(
"forceCustomerCreation",
request.force_customer_creation.clone(),
)
.build(),
options,
)
.await
}
/// Retrieve a processed transaction's details.
///
/// # Arguments
///
/// * `trans_id` - ReferenceId for the transaction (PaymentId).
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
pub async fn details(
&self,
trans_id: &str,
options: Option<RequestOptions>,
) -> Result<TransactionQueryRecordsCustomer, ApiError> {
self.http_client
.execute_request(
Method::GET,
&format!("MoneyIn/details/{}", trans_id),
None,
None,
options,
)
.await
}
/// Make a single transaction. This method authorizes and captures a payment in one step.
///
/// <Tip>
/// Consider migrating to the [v2 Make a transaction endpoint](/developers/api-reference/moneyinV2/make-a-transaction) to take advantage of unified response codes and improved response consistency.
/// </Tip>
///
/// # Arguments
///
/// * `include_details` - When `true`, transactionDetails object is returned in the response. See a full example of the `transactionDetails` object in the [Transaction integration guide](/developers/developer-guides/money-in-transaction-add#includedetailstrue-response).
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
pub async fn getpaid(
&self,
request: &GetpaidRequest,
options: Option<RequestOptions>,
) -> Result<PayabliApiResponseGetPaid, ApiError> {
self.http_client
.execute_request(
Method::POST,
"MoneyIn/getpaid",
Some(serde_json::to_value(&request.body).map_err(ApiError::Serialization)?),
QueryBuilder::new()
.serialize("achValidation", request.ach_validation.clone())
.serialize(
"forceCustomerCreation",
request.force_customer_creation.clone(),
)
.bool("includeDetails", request.include_details.clone())
.build(),
options,
)
.await
}
/// A reversal either refunds or voids a transaction independent of the transaction's settlement status. Send a reversal request for a transaction, and Payabli automatically determines whether it's a refund or void. You don't need to know whether the transaction is settled or not. This endpoint only works on transactions made with the v1 API. For v2 transactions, check the transaction's settlement status and call v2 void or v2 refund based on the result.
///
/// # Arguments
///
/// * `trans_id` - ReferenceId for the transaction (PaymentId).
/// * `amount` - Amount to reverse from original transaction, minus any service fees charged on the original transaction.
///
/// The amount provided can't be greater than the original total amount of the transaction, minus service fees. For example, if a transaction was $90 plus a $10 service fee, you can reverse up to $90.
///
/// An amount equal to zero will refunds the total amount authorized minus any service fee.
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
pub async fn reverse(
&self,
trans_id: &str,
amount: f64,
options: Option<RequestOptions>,
) -> Result<ReverseResponse, ApiError> {
self.http_client
.execute_request(
Method::GET,
&format!("MoneyIn/reverse/{}/{}", trans_id, amount),
None,
None,
options,
)
.await
}
/// Refund a transaction that has settled and send money back to the account holder. If a transaction hasn't been settled, void it instead.
///
/// <Tip>
/// Consider migrating to the [v2 Refund endpoint](/developers/api-reference/moneyinV2/refund-a-settled-transaction) to take advantage of unified response codes and improved response consistency.
/// </Tip>
///
/// # Arguments
///
/// * `trans_id` - ReferenceId for the transaction (PaymentId).
/// * `amount` - Amount to refund from original transaction, minus any service fees charged on the original transaction.
///
/// The amount provided can't be greater than the original total amount of the transaction, minus service fees. For example, if a transaction was \$90 plus a \$10 service fee, you can refund up to \$90.
///
/// An amount equal to zero will refund the total amount authorized minus any service fee.
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
pub async fn refund(
&self,
trans_id: &str,
amount: f64,
options: Option<RequestOptions>,
) -> Result<RefundResponse, ApiError> {
self.http_client
.execute_request(
Method::GET,
&format!("MoneyIn/refund/{}/{}", trans_id, amount),
None,
None,
options,
)
.await
}
/// Refunds a settled transaction with split instructions.
///
/// # Arguments
///
/// * `trans_id` - ReferenceId for the transaction (PaymentId).
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
pub async fn refund_with_instructions(
&self,
trans_id: &str,
request: &RequestRefund,
options: Option<RequestOptions>,
) -> Result<RefundWithInstructionsResponse, ApiError> {
self.http_client
.execute_request(
Method::POST,
&format!("MoneyIn/refund/{}", trans_id),
Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
None,
options,
)
.await
}
/// Reverse microdeposits that are used to verify customer account ownership and access. The `transId` value is returned in the success response for the original credit transaction made with `api/MoneyIn/makecredit`.
///
/// # Arguments
///
/// * `trans_id` - ReferenceId for the transaction (PaymentId).
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
pub async fn reverse_credit(
&self,
trans_id: &str,
options: Option<RequestOptions>,
) -> Result<PayabliApiResponse, ApiError> {
self.http_client
.execute_request(
Method::GET,
&format!("MoneyIn/reverseCredit/{}", trans_id),
None,
None,
options,
)
.await
}
/// Send a payment receipt for a transaction.
///
/// # Arguments
///
/// * `trans_id` - ReferenceId for the transaction (PaymentId).
/// * `email` - Email address where the payment receipt should be sent.
///
/// If not provided, the email address on file for the user owner of the transaction is used.
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
pub async fn send_receipt_2_trans(
&self,
trans_id: &str,
request: &SendReceipt2TransQueryRequest,
options: Option<RequestOptions>,
) -> Result<ReceiptResponse, ApiError> {
self.http_client
.execute_request(
Method::GET,
&format!("MoneyIn/sendreceipt/{}", trans_id),
None,
QueryBuilder::new()
.string("email", request.email.clone())
.build(),
options,
)
.await
}
/// Validates a card number without running a transaction or authorizing a charge.
///
/// # Arguments
///
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
pub async fn validate(
&self,
request: &RequestPaymentValidate,
options: Option<RequestOptions>,
) -> Result<ValidateResponse, ApiError> {
self.http_client
.execute_request(
Method::POST,
"MoneyIn/validate",
Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
None,
options,
)
.await
}
/// Cancel a transaction that hasn't been settled yet. Voiding non-captured authorizations prevents future captures. If a transaction has been settled, refund it instead.
///
/// <Tip>
/// Consider migrating to the [v2 Void endpoint](/developers/api-reference/moneyinV2/void-a-transaction) to take advantage of unified response codes and improved response consistency.
/// </Tip>
///
/// # Arguments
///
/// * `trans_id` - ReferenceId for the transaction (PaymentId).
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
pub async fn void(
&self,
trans_id: &str,
options: Option<RequestOptions>,
) -> Result<VoidResponse, ApiError> {
self.http_client
.execute_request(
Method::GET,
&format!("MoneyIn/void/{}", trans_id),
None,
None,
options,
)
.await
}
/// Make a single transaction. This method authorizes and captures a payment in one step. This is the v2 version of the `api/MoneyIn/getpaid` endpoint, and returns the unified response format. See [Pay In unified response codes reference](/guides/pay-in-unified-response-codes-reference) for more information.
///
/// # Arguments
///
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
pub async fn getpaidv_2(
&self,
request: &Getpaidv2Request,
options: Option<RequestOptions>,
) -> Result<V2TransactionResponseWrapper, ApiError> {
self.http_client
.execute_request(
Method::POST,
"v2/MoneyIn/getpaid",
Some(serde_json::to_value(&request.body).map_err(ApiError::Serialization)?),
QueryBuilder::new()
.serialize("achValidation", request.ach_validation.clone())
.serialize(
"forceCustomerCreation",
request.force_customer_creation.clone(),
)
.build(),
options,
)
.await
}
/// Authorize a card transaction. This returns an authorization code and reserves funds for the merchant. Authorized transactions aren't flagged for settlement until captured. This is the v2 version of the `api/MoneyIn/authorize` endpoint, and returns the unified response format. See [Pay In unified response codes reference](/guides/pay-in-unified-response-codes-reference) for more information.
///
/// **Note**: Only card transactions can be authorized. This endpoint can't be used for ACH transactions.
///
/// # Arguments
///
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
pub async fn authorizev_2(
&self,
request: &Authorizev2Request,
options: Option<RequestOptions>,
) -> Result<V2TransactionResponseWrapper, ApiError> {
self.http_client
.execute_request(
Method::POST,
"v2/MoneyIn/authorize",
Some(serde_json::to_value(&request.body).map_err(ApiError::Serialization)?),
QueryBuilder::new()
.serialize(
"forceCustomerCreation",
request.force_customer_creation.clone(),
)
.build(),
options,
)
.await
}
/// Capture an authorized transaction to complete the transaction and move funds from the customer to merchant account. This is the v2 version of the `api/MoneyIn/capture/{transId}` endpoint, and returns the unified response format. See [Pay In unified response codes reference](/guides/pay-in-unified-response-codes-reference) for more information.
///
/// # Arguments
///
/// * `trans_id` - ReferenceId for the transaction (PaymentId).
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
pub async fn capturev_2(
&self,
trans_id: &str,
request: &CaptureRequest,
options: Option<RequestOptions>,
) -> Result<V2TransactionResponseWrapper, ApiError> {
self.http_client
.execute_request(
Method::POST,
&format!("v2/MoneyIn/capture/{}", trans_id),
Some(serde_json::to_value(request).map_err(ApiError::Serialization)?),
None,
options,
)
.await
}
/// Give a full refund for a transaction that has settled and send money back to the account holder. To perform a partial refund, see [Partially refund a transaction](developers/api-reference/moneyinV2/partial-refund-a-settled-transaction).
///
/// This is the v2 version of the refund endpoint, and returns the unified response format. See [Pay In unified response codes reference](/guides/pay-in-unified-response-codes-reference) for more information.
///
/// # Arguments
///
/// * `trans_id` - ReferenceId for the transaction (PaymentId).
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
pub async fn refundv_2(
&self,
trans_id: &str,
options: Option<RequestOptions>,
) -> Result<V2TransactionResponseWrapper, ApiError> {
self.http_client
.execute_request(
Method::POST,
&format!("v2/MoneyIn/refund/{}", trans_id),
None,
None,
options,
)
.await
}
/// Refund a transaction that has settled and send money back to the account holder. If `amount` is omitted or set to 0, performs a full refund. When a non-zero `amount` is provided, this endpoint performs a partial refund.
///
/// This is the v2 version of the refund endpoint, and returns the unified response format. See [Pay In unified response codes reference](/guides/pay-in-unified-response-codes-reference) for more information.
///
/// # Arguments
///
/// * `trans_id` - ReferenceId for the transaction (PaymentId).
/// * `amount` - Amount to refund from original transaction, minus any service fees charged on the original transaction. If omitted or set to 0, performs a full refund.
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
pub async fn refundv_2_amount(
&self,
trans_id: &str,
amount: f64,
options: Option<RequestOptions>,
) -> Result<V2TransactionResponseWrapper, ApiError> {
self.http_client
.execute_request(
Method::POST,
&format!("v2/MoneyIn/refund/{}/{}", trans_id, amount),
None,
None,
options,
)
.await
}
/// Cancel a transaction that hasn't been settled yet. Voiding non-captured authorizations prevents future captures. This is the v2 version of the `api/MoneyIn/void/{transId}` endpoint, and returns the unified response format. See [Pay In unified response codes reference](/guides/pay-in-unified-response-codes-reference) for more information.
///
/// # Arguments
///
/// * `trans_id` - ReferenceId for the transaction (PaymentId).
/// * `options` - Additional request options such as headers, timeout, etc.
///
/// # Returns
///
/// JSON response from the API
pub async fn voidv_2(
&self,
trans_id: &str,
options: Option<RequestOptions>,
) -> Result<V2TransactionResponseWrapper, ApiError> {
self.http_client
.execute_request(
Method::POST,
&format!("v2/MoneyIn/void/{}", trans_id),
None,
None,
options,
)
.await
}
}