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
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
//! Customer types for the Payrix API.
//!
//! Customers represent payment contacts associated with a merchant.
//! Each customer can have multiple tokens (saved payment methods).
//!
//! **OpenAPI schema:** `customersResponse`
use payrix_macros::PayrixEntity;
use serde::{Deserialize, Serialize};
use super::{bool_from_int_default_false, PayrixId, Token};
// =============================================================================
// Customer (Response)
// =============================================================================
/// A Payrix customer.
///
/// Customers are associated with a merchant and can have multiple payment
/// tokens. The `custom` field can store your application's identifier.
///
/// **OpenAPI schema:** `customersResponse`
///
/// See `API_INCONSISTENCIES.md` for known deviations from this spec.
#[derive(Debug, Clone, Serialize, Deserialize, PayrixEntity)]
#[payrix(create = CreateCustomer, update = UpdateCustomer)]
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))]
#[serde(rename_all = "camelCase")]
pub struct Customer {
// -------------------------------------------------------------------------
// Core Identifiers (readonly)
// -------------------------------------------------------------------------
/// The ID of this resource.
///
/// **OpenAPI type:** string
#[payrix(readonly)]
pub id: PayrixId,
/// The date and time at which this resource was created.
///
/// Format: `YYYY-MM-DD HH:MM:SS.SSSS`
///
/// **OpenAPI type:** string (pattern: `^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.\d{4}$`)
#[payrix(readonly)]
#[serde(default)]
pub created: Option<String>,
/// The date and time at which this resource was modified.
///
/// Format: `YYYY-MM-DD HH:MM:SS.SSSS`
///
/// **OpenAPI type:** string (pattern: `^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.\d{4}$`)
#[payrix(readonly)]
#[serde(default)]
pub modified: Option<String>,
/// The identifier of the Login that created this resource.
///
/// **OpenAPI type:** string (ref: `creator`)
#[payrix(readonly)]
#[serde(default)]
pub creator: Option<PayrixId>,
/// The identifier of the Login that last modified this resource.
///
/// **OpenAPI type:** string
#[payrix(readonly)]
#[serde(default)]
pub modifier: Option<PayrixId>,
/// The ID of the Login that owns this resource.
///
/// **OpenAPI type:** string (ref: `customersModelLogin`)
#[payrix(create_only)]
#[serde(default)]
pub login: Option<PayrixId>,
/// The ID of the Merchant associated with this Customer.
///
/// **OpenAPI type:** string (ref: `customersModelMerchant`)
///
/// Note: API may return null for some customers.
#[payrix(create_only)]
#[serde(default)]
pub merchant: Option<PayrixId>,
/// The ID of the Entity that owns this resource.
///
/// **OpenAPI type:** string (ref: `customersModelEntity`)
#[payrix(readonly)]
#[serde(default)]
pub entity: Option<PayrixId>,
// -------------------------------------------------------------------------
// Customer Name & Company (mutable)
// -------------------------------------------------------------------------
/// The first name associated with this Customer.
///
/// **OpenAPI type:** string
#[payrix(mutable)]
#[serde(default)]
pub first: Option<String>,
/// The middle name associated with this Customer.
///
/// **OpenAPI type:** string
#[payrix(mutable)]
#[serde(default)]
pub middle: Option<String>,
/// The last name associated with this Customer.
///
/// **OpenAPI type:** string
#[payrix(mutable)]
#[serde(default)]
pub last: Option<String>,
/// The name of the company associated with this Customer.
///
/// **OpenAPI type:** string
#[payrix(mutable)]
#[serde(default)]
pub company: Option<String>,
// -------------------------------------------------------------------------
// Contact Information (mutable)
// -------------------------------------------------------------------------
/// The email address of this Customer.
///
/// **OpenAPI type:** string
#[payrix(mutable)]
#[serde(default)]
pub email: Option<String>,
/// The phone number associated with this Transaction.
///
/// This field is stored as a text string and must be between 10 and 15 characters long.
///
/// **OpenAPI type:** string
#[payrix(mutable)]
#[serde(default)]
pub phone: Option<String>,
/// The fax number associated with this Customer.
///
/// This field is stored as a text string and must be between 10 and 15 characters long.
///
/// **OpenAPI type:** string
#[payrix(mutable)]
#[serde(default)]
pub fax: Option<String>,
// -------------------------------------------------------------------------
// Billing Address (mutable)
// -------------------------------------------------------------------------
/// The first line of the address associated with this Customer.
///
/// This field is stored as a text string and must be between 1 and 500 characters long.
///
/// **OpenAPI type:** string
#[payrix(mutable)]
#[serde(default)]
pub address1: Option<String>,
/// The second line of the address associated with this Customer.
///
/// This field is stored as a text string and must be between 1 and 500 characters long.
///
/// **OpenAPI type:** string
#[payrix(mutable)]
#[serde(default)]
pub address2: Option<String>,
/// The name of the city in the address associated with this Customer.
///
/// This field is stored as a text string and must be between 1 and 500 characters long.
///
/// **OpenAPI type:** string
#[payrix(mutable)]
#[serde(default)]
pub city: Option<String>,
/// The U.S. state or Canadian province relevant to the address provided here.
///
/// If the location is within the U.S. and Canada, specify the 2-character postal
/// abbreviation for the state. If the location is outside of the U.S. and Canada,
/// provide the full state name.
///
/// This field is stored as a text string and must be between 2 and 100 characters long.
///
/// **OpenAPI type:** string
#[payrix(mutable)]
#[serde(default)]
pub state: Option<String>,
/// The ZIP code in the address associated with this Customer.
///
/// This field is stored as a text string and must be between 1 and 20 characters long.
///
/// **OpenAPI type:** string
#[payrix(mutable)]
#[serde(default)]
pub zip: Option<String>,
/// The country associated with this Customer.
///
/// Valid values for this field is the 3-letter ISO code for the country
/// (e.g., `USA`, `CAN`).
///
/// **OpenAPI type:** string (ref: `Country`)
#[payrix(mutable)]
#[serde(default)]
pub country: Option<String>,
// -------------------------------------------------------------------------
// Shipping Address (mutable)
// -------------------------------------------------------------------------
/// The first name associated with this Customer's shipping information.
///
/// **OpenAPI type:** string
#[payrix(mutable)]
#[serde(default)]
pub shipping_first: Option<String>,
/// The middle name associated with this Customer's shipping information.
///
/// **OpenAPI type:** string
#[payrix(mutable)]
#[serde(default)]
pub shipping_middle: Option<String>,
/// The last name associated with this Customer's shipping information.
///
/// **OpenAPI type:** string
#[payrix(mutable)]
#[serde(default)]
pub shipping_last: Option<String>,
/// The name of the company associated with this Customer's shipping information.
///
/// **OpenAPI type:** string
#[payrix(mutable)]
#[serde(default)]
pub shipping_company: Option<String>,
/// The first line of the address associated with this Customer's shipping information.
///
/// This field is stored as a text string and must be between 1 and 500 characters long.
///
/// **OpenAPI type:** string
#[payrix(mutable)]
#[serde(default)]
pub shipping_address1: Option<String>,
/// The second line of the address associated with this Customer's shipping information.
///
/// This field is stored as a text string and must be between 1 and 500 characters long.
///
/// **OpenAPI type:** string
#[payrix(mutable)]
#[serde(default)]
pub shipping_address2: Option<String>,
/// The name of the city associated with this Customer's shipping information.
///
/// This field is stored as a text string and must be between 1 and 500 characters long.
///
/// **OpenAPI type:** string
#[payrix(mutable)]
#[serde(default)]
pub shipping_city: Option<String>,
/// The U.S. state or Canadian province relevant to the shipping address.
///
/// If the location is within the U.S. and Canada, specify the 2-character postal
/// abbreviation for the state. If the location is outside of the U.S. and Canada,
/// provide the full state name.
///
/// This field is stored as a text string and must be between 2 and 100 characters long.
///
/// **OpenAPI type:** string
#[payrix(mutable)]
#[serde(default)]
pub shipping_state: Option<String>,
/// The ZIP code associated with this Customer's shipping information.
///
/// This field is stored as a text string and must be between 1 and 20 characters long.
///
/// **OpenAPI type:** string
#[payrix(mutable)]
#[serde(default)]
pub shipping_zip: Option<String>,
/// The country associated with this Customer's shipping information.
///
/// Valid values for this field is the 3-letter ISO code for the country
/// (e.g., `USA`, `CAN`).
///
/// **OpenAPI type:** string (ref: `ShippingCountry`)
#[payrix(mutable)]
#[serde(default)]
pub shipping_country: Option<String>,
/// The phone number associated with this Customer's shipping information.
///
/// This field is stored as a text string and must be between 10 and 15 characters long.
///
/// **OpenAPI type:** string
#[payrix(mutable)]
#[serde(default)]
pub shipping_phone: Option<String>,
/// The fax number associated with this Customer's shipping information.
///
/// This field is stored as a text string and must be between 10 and 15 characters long.
///
/// **OpenAPI type:** string
#[payrix(mutable)]
#[serde(default)]
pub shipping_fax: Option<String>,
// -------------------------------------------------------------------------
// Custom & Authentication Fields
// -------------------------------------------------------------------------
/// Custom, free-form field for client-supplied text.
///
/// Must be between 0 and 1,000 characters long.
/// Use this to store your application's ID for this contact.
///
/// **OpenAPI type:** string
#[payrix(mutable)]
#[serde(default)]
pub custom: Option<String>,
/// The customer reference from the authToken used for user authentication, if available.
///
/// **OpenAPI type:** string
#[payrix(readonly)]
#[serde(default)]
pub auth_token_customer: Option<String>,
// -------------------------------------------------------------------------
// Status Flags (mutable)
// -------------------------------------------------------------------------
/// Whether this resource is marked as frozen.
///
/// **OpenAPI type:** integer (ref: `Frozen`)
///
/// Valid values:
/// - `0` - Not Frozen
/// - `1` - Frozen
#[payrix(mutable)]
#[serde(default, with = "bool_from_int_default_false")]
pub frozen: bool,
/// Whether this resource is marked as inactive.
///
/// **OpenAPI type:** integer (ref: `Inactive`)
///
/// Valid values:
/// - `0` - Active
/// - `1` - Inactive
#[payrix(mutable)]
#[serde(default, with = "bool_from_int_default_false")]
pub inactive: bool,
// -------------------------------------------------------------------------
// Nested Relations (expanded via `expand` query parameter)
// -------------------------------------------------------------------------
/// Array of invoices associated with this Customer.
///
/// Only populated when using the `expand` query parameter.
///
/// **OpenAPI type:** array of `invoicesResponse`
#[cfg_attr(feature = "sqlx", sqlx(skip))]
#[serde(default)]
pub invoices: Option<Vec<serde_json::Value>>,
/// Array of tokens (saved payment methods) associated with this Customer.
///
/// Only populated when using the `expand` query parameter.
///
/// **OpenAPI type:** array of `tokensResponse`
#[cfg_attr(feature = "sqlx", sqlx(skip))]
#[serde(default)]
pub tokens: Option<Vec<Token>>,
}
// Helper methods for CreateCustomer
impl CreateCustomer {
/// Create a new customer for a merchant with minimal info.
pub fn new(merchant: impl Into<PayrixId>) -> Self {
Self {
merchant: Some(merchant.into()),
..Default::default()
}
}
/// Set the customer's name.
pub fn with_name(mut self, first: impl Into<String>, last: impl Into<String>) -> Self {
self.first = Some(first.into());
self.last = Some(last.into());
self
}
/// Set the customer's email.
pub fn with_email(mut self, email: impl Into<String>) -> Self {
self.email = Some(email.into());
self
}
/// Set the customer's phone number.
pub fn with_phone(mut self, phone: impl Into<String>) -> Self {
self.phone = Some(phone.into());
self
}
/// Set the billing address.
pub fn with_address(
mut self,
address1: impl Into<String>,
city: impl Into<String>,
state: impl Into<String>,
zip: impl Into<String>,
) -> Self {
self.address1 = Some(address1.into());
self.city = Some(city.into());
self.state = Some(state.into());
self.zip = Some(zip.into());
self
}
/// Set a custom identifier for your application.
pub fn with_custom(mut self, custom: impl Into<String>) -> Self {
self.custom = Some(custom.into());
self
}
}
// =============================================================================
// Tests
// =============================================================================
#[cfg(test)]
mod tests {
use super::*;
// =========================================================================
// Customer Struct Tests
// =========================================================================
#[test]
fn customer_deserialize_full() {
let json = r#"{
"id": "t1_cus_12345678901234567890123",
"created": "2024-01-01 00:00:00.0000",
"modified": "2024-04-01 12:00:00.0000",
"creator": "t1_lgn_creator1234567890123456",
"modifier": "t1_lgn_modifier123456789012345",
"login": "t1_lgn_12345678901234567890123",
"merchant": "t1_mer_12345678901234567890123",
"entity": "t1_ent_12345678901234567890123",
"first": "John",
"middle": "Q",
"last": "Doe",
"company": "Acme Corp",
"email": "john.doe@example.com",
"phone": "555-1234567",
"fax": "555-9876543",
"address1": "123 Main St",
"address2": "Suite 100",
"city": "Springfield",
"state": "IL",
"zip": "62701",
"country": "USA",
"shippingFirst": "Jane",
"shippingMiddle": "R",
"shippingLast": "Smith",
"shippingCompany": "Shipping Co",
"shippingAddress1": "456 Oak Ave",
"shippingAddress2": "Apt 5",
"shippingCity": "Chicago",
"shippingState": "IL",
"shippingZip": "60601",
"shippingCountry": "USA",
"shippingPhone": "555-1111111",
"shippingFax": "555-2222222",
"custom": "my-app-customer-12345",
"authTokenCustomer": "auth-customer-ref",
"frozen": 0,
"inactive": 1
}"#;
let customer: Customer = serde_json::from_str(json).unwrap();
// Core identifiers
assert_eq!(customer.id.as_str(), "t1_cus_12345678901234567890123");
assert_eq!(customer.created.as_deref(), Some("2024-01-01 00:00:00.0000"));
assert_eq!(customer.modified.as_deref(), Some("2024-04-01 12:00:00.0000"));
assert_eq!(customer.creator.as_ref().unwrap().as_str(), "t1_lgn_creator1234567890123456");
assert_eq!(customer.modifier.as_ref().unwrap().as_str(), "t1_lgn_modifier123456789012345");
assert_eq!(customer.login.as_ref().unwrap().as_str(), "t1_lgn_12345678901234567890123");
assert_eq!(customer.merchant.as_ref().unwrap().as_str(), "t1_mer_12345678901234567890123");
assert_eq!(customer.entity.as_ref().unwrap().as_str(), "t1_ent_12345678901234567890123");
// Customer name & company
assert_eq!(customer.first.as_deref(), Some("John"));
assert_eq!(customer.middle.as_deref(), Some("Q"));
assert_eq!(customer.last.as_deref(), Some("Doe"));
assert_eq!(customer.company.as_deref(), Some("Acme Corp"));
// Contact information
assert_eq!(customer.email.as_deref(), Some("john.doe@example.com"));
assert_eq!(customer.phone.as_deref(), Some("555-1234567"));
assert_eq!(customer.fax.as_deref(), Some("555-9876543"));
// Billing address
assert_eq!(customer.address1.as_deref(), Some("123 Main St"));
assert_eq!(customer.address2.as_deref(), Some("Suite 100"));
assert_eq!(customer.city.as_deref(), Some("Springfield"));
assert_eq!(customer.state.as_deref(), Some("IL"));
assert_eq!(customer.zip.as_deref(), Some("62701"));
assert_eq!(customer.country.as_deref(), Some("USA"));
// Shipping address
assert_eq!(customer.shipping_first.as_deref(), Some("Jane"));
assert_eq!(customer.shipping_middle.as_deref(), Some("R"));
assert_eq!(customer.shipping_last.as_deref(), Some("Smith"));
assert_eq!(customer.shipping_company.as_deref(), Some("Shipping Co"));
assert_eq!(customer.shipping_address1.as_deref(), Some("456 Oak Ave"));
assert_eq!(customer.shipping_address2.as_deref(), Some("Apt 5"));
assert_eq!(customer.shipping_city.as_deref(), Some("Chicago"));
assert_eq!(customer.shipping_state.as_deref(), Some("IL"));
assert_eq!(customer.shipping_zip.as_deref(), Some("60601"));
assert_eq!(customer.shipping_country.as_deref(), Some("USA"));
assert_eq!(customer.shipping_phone.as_deref(), Some("555-1111111"));
assert_eq!(customer.shipping_fax.as_deref(), Some("555-2222222"));
// Custom & auth fields
assert_eq!(customer.custom.as_deref(), Some("my-app-customer-12345"));
assert_eq!(customer.auth_token_customer.as_deref(), Some("auth-customer-ref"));
// Status flags
assert!(!customer.frozen);
assert!(customer.inactive);
// Nested relations (not expanded)
assert!(customer.invoices.is_none());
assert!(customer.tokens.is_none());
}
#[test]
fn customer_deserialize_minimal() {
let json = r#"{
"id": "t1_cus_12345678901234567890123"
}"#;
let customer: Customer = serde_json::from_str(json).unwrap();
assert_eq!(customer.id.as_str(), "t1_cus_12345678901234567890123");
assert!(customer.created.is_none());
assert!(customer.modified.is_none());
assert!(customer.creator.is_none());
assert!(customer.modifier.is_none());
assert!(customer.login.is_none());
assert!(customer.merchant.is_none());
assert!(customer.entity.is_none());
assert!(customer.first.is_none());
assert!(customer.last.is_none());
assert!(customer.email.is_none());
assert!(!customer.frozen);
assert!(!customer.inactive);
}
#[test]
fn customer_deserialize_with_nested_tokens() {
let json = r#"{
"id": "t1_cus_12345678901234567890123",
"merchant": "t1_mer_12345678901234567890123",
"tokens": [
{
"id": "t1_tok_12345678901234567890123",
"customer": "t1_cus_12345678901234567890123",
"inactive": 0,
"frozen": 0
}
]
}"#;
let customer: Customer = serde_json::from_str(json).unwrap();
assert!(customer.tokens.is_some());
let tokens = customer.tokens.unwrap();
assert_eq!(tokens.len(), 1);
assert_eq!(tokens[0].id.as_str(), "t1_tok_12345678901234567890123");
}
#[test]
fn customer_deserialize_with_nested_invoices() {
let json = r#"{
"id": "t1_cus_12345678901234567890123",
"merchant": "t1_mer_12345678901234567890123",
"invoices": [
{"id": "t1_inv_12345678901234567890123", "status": "pending"}
]
}"#;
let customer: Customer = serde_json::from_str(json).unwrap();
assert!(customer.invoices.is_some());
let invoices = customer.invoices.unwrap();
assert_eq!(invoices.len(), 1);
}
#[test]
fn customer_bool_from_int_zero_is_false() {
let json = r#"{
"id": "t1_cus_12345678901234567890123",
"inactive": 0,
"frozen": 0
}"#;
let customer: Customer = serde_json::from_str(json).unwrap();
assert!(!customer.inactive);
assert!(!customer.frozen);
}
#[test]
fn customer_bool_from_int_one_is_true() {
let json = r#"{
"id": "t1_cus_12345678901234567890123",
"inactive": 1,
"frozen": 1
}"#;
let customer: Customer = serde_json::from_str(json).unwrap();
assert!(customer.inactive);
assert!(customer.frozen);
}
#[test]
fn customer_bool_from_int_missing_defaults_false() {
let json = r#"{
"id": "t1_cus_12345678901234567890123"
}"#;
let customer: Customer = serde_json::from_str(json).unwrap();
assert!(!customer.inactive);
assert!(!customer.frozen);
}
#[test]
fn customer_creator_modifier_fields() {
let json = r#"{
"id": "t1_cus_12345678901234567890123",
"creator": "t1_lgn_creator1234567890123456",
"modifier": "t1_lgn_modifier123456789012345"
}"#;
let customer: Customer = serde_json::from_str(json).unwrap();
assert_eq!(customer.creator.as_ref().unwrap().as_str(), "t1_lgn_creator1234567890123456");
assert_eq!(customer.modifier.as_ref().unwrap().as_str(), "t1_lgn_modifier123456789012345");
}
#[test]
fn customer_auth_token_customer_field() {
let json = r#"{
"id": "t1_cus_12345678901234567890123",
"authTokenCustomer": "customer-auth-ref-12345"
}"#;
let customer: Customer = serde_json::from_str(json).unwrap();
assert_eq!(customer.auth_token_customer.as_deref(), Some("customer-auth-ref-12345"));
}
// =========================================================================
// CreateCustomer Tests
// =========================================================================
#[test]
fn create_customer_serialize_with_builder() {
let merchant_id: PayrixId = "t1_mer_12345678901234567890123".parse().unwrap();
let create = CreateCustomer::new(merchant_id)
.with_name("John", "Doe")
.with_email("john.doe@example.com")
.with_address("123 Main St", "Springfield", "IL", "62701");
let json = serde_json::to_string(&create).unwrap();
assert!(json.contains("\"merchant\""));
assert!(json.contains("\"first\""));
assert!(json.contains("\"last\""));
assert!(json.contains("\"email\""));
assert!(json.contains("\"address1\""));
assert!(json.contains("\"city\""));
assert!(json.contains("\"state\""));
assert!(json.contains("\"zip\""));
}
#[test]
fn create_customer_serialize_minimal() {
let merchant_id: PayrixId = "t1_mer_12345678901234567890123".parse().unwrap();
let create = CreateCustomer::new(merchant_id);
let json = serde_json::to_string(&create).unwrap();
assert!(json.contains("\"merchant\""));
// Optional fields should be omitted when None
assert!(!json.contains("\"first\""));
assert!(!json.contains("\"email\""));
}
}