tosspayments/api/
issue_virtual_account.rs1use reqwest::Method;
2use serde::{Deserialize, Serialize};
3use typed_builder::TypedBuilder;
4
5use crate::data::{BankCode, CashReceiptTypeForRequest, Payment};
6use crate::endpoint::Endpoint;
7
8#[derive(Debug, Clone, Serialize, Deserialize, TypedBuilder)]
9#[serde(rename_all = "camelCase")]
10pub struct VirtualAccountCashReceipt {
11 pub r#type: CashReceiptTypeForRequest,
12 pub registration_number: String,
13}
14
15#[derive(Debug, Clone, Serialize, Deserialize, TypedBuilder)]
16#[serde(rename_all = "camelCase")]
17pub struct VirtualAccountEscrowProduct {
18 pub id: String,
19 pub name: String,
20 pub code: String,
21 pub unit_price: i32,
22 pub quantity: i32,
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize, TypedBuilder)]
26#[serde(rename_all = "camelCase")]
27pub struct IssueVirtualAccount {
28 pub amount: i32,
29 pub order_id: String,
30 pub order_name: String,
31 pub customer_name: String,
32 pub bank: BankCode,
33 #[builder(default)]
34 pub account_key: Option<String>,
35 #[builder(default)]
36 pub valid_hours: Option<i32>,
37 #[builder(default)]
38 pub due_date: Option<String>,
39 #[builder(default)]
40 pub customer_email: Option<String>,
41 #[builder(default)]
42 pub customer_mobile_phone: Option<String>,
43 #[builder(default)]
44 pub tax_free_amount: Option<usize>,
45 #[builder(default)]
46 pub use_escrow: Option<bool>,
47 #[builder(default)]
48 pub cash_receipt: Option<VirtualAccountCashReceipt>,
49 #[builder(default)]
50 pub escrow_products: Option<Vec<VirtualAccountEscrowProduct>>,
51}
52
53impl Endpoint for IssueVirtualAccount {
54 type Query = ();
55 type Body = Self;
56 type Response = Payment;
57
58 fn relative_path(&self) -> String {
59 "/v1/virtual-accounts".to_string()
60 }
61
62 fn method(&self) -> Method {
63 Method::POST
64 }
65
66 fn body(&self) -> Option<&Self::Body> {
67 Some(&self)
68 }
69}