qpay 1.0.0

QPay V2 API SDK for Rust
Documentation
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
use serde::{Deserialize, Serialize};

// --- Auth ---

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TokenResponse {
    pub token_type: String,
    pub refresh_expires_in: i64,
    pub refresh_token: String,
    pub access_token: String,
    pub expires_in: i64,
    pub scope: String,
    #[serde(rename = "not-before-policy")]
    pub not_before_policy: String,
    pub session_state: String,
}

// --- Common nested types ---

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct Address {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub city: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub district: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub street: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub building: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub address: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub zipcode: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub longitude: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub latitude: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct SenderBranchData {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub register: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub email: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub phone: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub address: Option<Address>,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct SenderStaffData {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub email: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub phone: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct InvoiceReceiverData {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub register: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub email: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub phone: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub address: Option<Address>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Account {
    pub account_bank_code: String,
    pub account_number: String,
    pub iban_number: String,
    pub account_name: String,
    pub account_currency: String,
    pub is_default: bool,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Transaction {
    pub description: String,
    pub amount: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub accounts: Option<Vec<Account>>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InvoiceLine {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tax_product_code: Option<String>,
    pub line_description: String,
    pub line_quantity: String,
    pub line_unit_price: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub note: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub discounts: Option<Vec<TaxEntry>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub surcharges: Option<Vec<TaxEntry>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub taxes: Option<Vec<TaxEntry>>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct EbarimtInvoiceLine {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tax_product_code: Option<String>,
    pub line_description: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub barcode: Option<String>,
    pub line_quantity: String,
    pub line_unit_price: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub note: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub classification_code: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub taxes: Option<Vec<TaxEntry>>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TaxEntry {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tax_code: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub discount_code: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub surcharge_code: Option<String>,
    pub description: String,
    pub amount: f64,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub note: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Deeplink {
    pub name: String,
    pub description: String,
    pub logo: String,
    pub link: String,
}

// --- Invoice ---

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CreateInvoiceRequest {
    pub invoice_code: String,
    pub sender_invoice_no: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sender_branch_code: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sender_branch_data: Option<SenderBranchData>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sender_staff_data: Option<SenderStaffData>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sender_staff_code: Option<String>,
    pub invoice_receiver_code: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub invoice_receiver_data: Option<InvoiceReceiverData>,
    pub invoice_description: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub enable_expiry: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub allow_partial: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub minimum_amount: Option<f64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub allow_exceed: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub maximum_amount: Option<f64>,
    pub amount: f64,
    pub callback_url: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sender_terminal_code: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sender_terminal_data: Option<serde_json::Value>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub allow_subscribe: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub subscription_interval: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub subscription_webhook: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub note: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub transactions: Option<Vec<Transaction>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub lines: Option<Vec<InvoiceLine>>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CreateSimpleInvoiceRequest {
    pub invoice_code: String,
    pub sender_invoice_no: String,
    pub invoice_receiver_code: String,
    pub invoice_description: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sender_branch_code: Option<String>,
    pub amount: f64,
    pub callback_url: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CreateEbarimtInvoiceRequest {
    pub invoice_code: String,
    pub sender_invoice_no: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sender_branch_code: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sender_staff_data: Option<SenderStaffData>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sender_staff_code: Option<String>,
    pub invoice_receiver_code: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub invoice_receiver_data: Option<InvoiceReceiverData>,
    pub invoice_description: String,
    pub tax_type: String,
    pub district_code: String,
    pub callback_url: String,
    pub lines: Vec<EbarimtInvoiceLine>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InvoiceResponse {
    pub invoice_id: String,
    pub qr_text: String,
    pub qr_image: String,
    #[serde(rename = "qPay_shortUrl")]
    pub qpay_short_url: String,
    pub urls: Vec<Deeplink>,
}

// --- Payment ---

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Offset {
    pub page_number: i32,
    pub page_limit: i32,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PaymentCheckRequest {
    pub object_type: String,
    pub object_id: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub offset: Option<Offset>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PaymentCheckResponse {
    pub count: i32,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub paid_amount: Option<f64>,
    pub rows: Vec<PaymentCheckRow>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PaymentCheckRow {
    pub payment_id: String,
    pub payment_status: String,
    pub payment_amount: String,
    pub trx_fee: String,
    pub payment_currency: String,
    pub payment_wallet: String,
    pub payment_type: String,
    pub next_payment_date: Option<String>,
    pub next_payment_datetime: Option<String>,
    #[serde(default)]
    pub card_transactions: Vec<CardTransaction>,
    #[serde(default)]
    pub p2p_transactions: Vec<P2PTransaction>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PaymentDetail {
    pub payment_id: String,
    pub payment_status: String,
    pub payment_fee: String,
    pub payment_amount: String,
    pub payment_currency: String,
    pub payment_date: String,
    pub payment_wallet: String,
    pub transaction_type: String,
    pub object_type: String,
    pub object_id: String,
    pub next_payment_date: Option<String>,
    pub next_payment_datetime: Option<String>,
    #[serde(default)]
    pub card_transactions: Vec<CardTransaction>,
    #[serde(default)]
    pub p2p_transactions: Vec<P2PTransaction>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CardTransaction {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub card_merchant_code: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub card_terminal_code: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub card_number: Option<String>,
    pub card_type: String,
    pub is_cross_border: bool,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub amount: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub transaction_amount: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub currency: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub transaction_currency: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub date: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub transaction_date: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub status: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub transaction_status: Option<String>,
    pub settlement_status: String,
    pub settlement_status_date: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct P2PTransaction {
    pub transaction_bank_code: String,
    pub account_bank_code: String,
    pub account_bank_name: String,
    pub account_number: String,
    pub status: String,
    pub amount: String,
    pub currency: String,
    pub settlement_status: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PaymentListRequest {
    pub object_type: String,
    pub object_id: String,
    pub start_date: String,
    pub end_date: String,
    pub offset: Offset,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PaymentListResponse {
    pub count: i32,
    pub rows: Vec<PaymentListItem>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PaymentListItem {
    pub payment_id: String,
    pub payment_date: String,
    pub payment_status: String,
    pub payment_fee: String,
    pub payment_amount: String,
    pub payment_currency: String,
    pub payment_wallet: String,
    pub payment_name: String,
    pub payment_description: String,
    pub qr_code: String,
    pub paid_by: String,
    pub object_type: String,
    pub object_id: String,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct PaymentCancelRequest {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub callback_url: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub note: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct PaymentRefundRequest {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub callback_url: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub note: Option<String>,
}

// --- Ebarimt ---

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CreateEbarimtRequest {
    pub payment_id: String,
    pub ebarimt_receiver_type: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ebarimt_receiver: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub district_code: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub classification_code: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct EbarimtResponse {
    pub id: String,
    pub ebarimt_by: String,
    pub g_wallet_id: String,
    pub g_wallet_customer_id: String,
    pub ebarimt_receiver_type: String,
    pub ebarimt_receiver: String,
    pub ebarimt_district_code: String,
    pub ebarimt_bill_type: String,
    pub g_merchant_id: String,
    pub merchant_branch_code: String,
    pub merchant_terminal_code: Option<String>,
    pub merchant_staff_code: Option<String>,
    pub merchant_register_no: String,
    pub g_payment_id: String,
    pub paid_by: String,
    pub object_type: String,
    pub object_id: String,
    pub amount: String,
    pub vat_amount: String,
    pub city_tax_amount: String,
    pub ebarimt_qr_data: String,
    pub ebarimt_lottery: String,
    pub note: Option<String>,
    pub barimt_status: String,
    pub barimt_status_date: String,
    pub ebarimt_sent_email: Option<String>,
    pub ebarimt_receiver_phone: String,
    pub tax_type: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub merchant_tin: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ebarimt_receipt_id: Option<String>,
    pub created_by: String,
    pub created_date: String,
    pub updated_by: String,
    pub updated_date: String,
    pub status: bool,
    #[serde(default)]
    pub barimt_items: Vec<EbarimtItem>,
    #[serde(default)]
    pub barimt_transactions: Vec<serde_json::Value>,
    #[serde(default)]
    pub barimt_histories: Vec<EbarimtHistory>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct EbarimtItem {
    pub id: String,
    pub barimt_id: String,
    pub merchant_product_code: Option<String>,
    pub tax_product_code: String,
    pub bar_code: Option<String>,
    pub name: String,
    pub unit_price: String,
    pub quantity: String,
    pub amount: String,
    pub city_tax_amount: String,
    pub vat_amount: String,
    pub note: Option<String>,
    pub created_by: String,
    pub created_date: String,
    pub updated_by: String,
    pub updated_date: String,
    pub status: bool,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct EbarimtHistory {
    pub id: String,
    pub barimt_id: String,
    pub ebarimt_receiver_type: String,
    pub ebarimt_receiver: String,
    pub ebarimt_register_no: Option<String>,
    pub ebarimt_bill_id: String,
    pub ebarimt_date: String,
    pub ebarimt_mac_address: String,
    pub ebarimt_internal_code: String,
    pub ebarimt_bill_type: String,
    pub ebarimt_qr_data: String,
    pub ebarimt_lottery: String,
    pub ebarimt_lottery_msg: Option<String>,
    pub ebarimt_error_code: Option<String>,
    pub ebarimt_error_msg: Option<String>,
    pub ebarimt_response_code: Option<String>,
    pub ebarimt_response_msg: Option<String>,
    pub note: Option<String>,
    pub barimt_status: String,
    pub barimt_status_date: String,
    pub ebarimt_sent_email: Option<String>,
    pub ebarimt_receiver_phone: String,
    pub tax_type: String,
    pub created_by: String,
    pub created_date: String,
    pub updated_by: String,
    pub updated_date: String,
    pub status: bool,
}