zai_payment 1.3.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/examples/users.md CHANGED
@@ -32,6 +32,7 @@ Create a buyer with minimal required information.
32
32
  ```ruby
33
33
  # Create a basic payin user
34
34
  response = ZaiPayment.users.create(
35
+ user_type: 'payin',
35
36
  email: 'buyer@example.com',
36
37
  first_name: 'John',
37
38
  last_name: 'Doe',
@@ -43,6 +44,9 @@ if response.success?
43
44
  puts "Payin user created successfully!"
44
45
  puts "User ID: #{user['id']}"
45
46
  puts "Email: #{user['email']}"
47
+
48
+ # Note: device_id and ip_address will be required later
49
+ # when creating an item and charging a card
46
50
  else
47
51
  puts "Failed to create user"
48
52
  end
@@ -55,6 +59,7 @@ Create a buyer with all recommended information for better fraud prevention.
55
59
  ```ruby
56
60
  response = ZaiPayment.users.create(
57
61
  # Required fields
62
+ user_type: 'payin',
58
63
  email: 'john.buyer@example.com',
59
64
  first_name: 'John',
60
65
  last_name: 'Doe',
@@ -67,15 +72,14 @@ response = ZaiPayment.users.create(
67
72
  state: 'NY',
68
73
  zip: '10001',
69
74
  mobile: '+1234567890',
70
- dob: '15/01/1990',
71
-
72
- # For fraud prevention (required when charging)
73
- device_id: 'device_abc123xyz',
74
- ip_address: '192.168.1.1'
75
+ dob: '15/01/1990'
75
76
  )
76
77
 
77
78
  user = response.data
78
79
  puts "Complete payin user profile created: #{user['id']}"
80
+
81
+ # Note: device_id and ip_address can be stored separately
82
+ # and will be required when creating an item and charging a card
79
83
  ```
80
84
 
81
85
  ### Example 3: Progressive Profile Building
@@ -85,6 +89,7 @@ Create a user quickly, then update with additional information later.
85
89
  ```ruby
86
90
  # Step 1: Quick user creation during signup
87
91
  response = ZaiPayment.users.create(
92
+ user_type: 'payin',
88
93
  email: 'quicksignup@example.com',
89
94
  first_name: 'Jane',
90
95
  last_name: 'Smith',
@@ -106,14 +111,9 @@ ZaiPayment.users.update(
106
111
 
107
112
  puts "User profile updated with shipping address"
108
113
 
109
- # Step 3: Add device info before payment
110
- ZaiPayment.users.update(
111
- user_id,
112
- device_id: 'device_xyz789',
113
- ip_address: '203.0.113.42'
114
- )
115
-
116
- puts "Device information added for payment"
114
+ # Note: device_id and ip_address should be captured during
115
+ # payment flow and will be required when creating an item
116
+ # They are not stored in the user profile, but used at transaction time
117
117
  ```
118
118
 
119
119
  ## Payout User Examples
@@ -124,6 +124,9 @@ Create a seller who will receive payments. All required fields must be provided.
124
124
 
125
125
  ```ruby
126
126
  response = ZaiPayment.users.create(
127
+ # User type
128
+ user_type: 'payout',
129
+
127
130
  # Required for payout users
128
131
  email: 'seller@example.com',
129
132
  first_name: 'Alice',
@@ -137,8 +140,7 @@ response = ZaiPayment.users.create(
137
140
 
138
141
  # Recommended
139
142
  mobile: '+14155551234',
140
- government_number: '123456789', # SSN or Tax ID
141
- user_type: 'payout'
143
+ government_number: '123456789' # SSN or Tax ID
142
144
  )
143
145
 
144
146
  seller = response.data
@@ -152,6 +154,7 @@ Create an Australian seller with appropriate details.
152
154
 
153
155
  ```ruby
154
156
  response = ZaiPayment.users.create(
157
+ user_type: 'payout',
155
158
  email: 'aussie.seller@example.com',
156
159
  first_name: 'Bruce',
157
160
  last_name: 'Williams',
@@ -165,8 +168,7 @@ response = ZaiPayment.users.create(
165
168
  zip: '2000',
166
169
 
167
170
  mobile: '+61298765432',
168
- government_number: '123456789', # TFN (Tax File Number)
169
- user_type: 'payout'
171
+ government_number: '123456789' # TFN (Tax File Number)
170
172
  )
171
173
 
172
174
  if response.success?
@@ -182,6 +184,7 @@ Create a UK-based seller.
182
184
 
183
185
  ```ruby
184
186
  response = ZaiPayment.users.create(
187
+ user_type: 'payout',
185
188
  email: 'uk.merchant@example.com',
186
189
  first_name: 'Oliver',
187
190
  last_name: 'Brown',
@@ -195,8 +198,7 @@ response = ZaiPayment.users.create(
195
198
  zip: 'SW1A 2AA',
196
199
 
197
200
  mobile: '+447700900123',
198
- government_number: 'AB123456C', # National Insurance Number
199
- user_type: 'payout'
201
+ government_number: 'AB123456C' # National Insurance Number
200
202
  )
201
203
 
202
204
  merchant = response.data
@@ -316,18 +318,21 @@ Create multiple users efficiently.
316
318
  ```ruby
317
319
  users_to_create = [
318
320
  {
321
+ user_type: 'payin',
319
322
  email: 'buyer1@example.com',
320
323
  first_name: 'Alice',
321
324
  last_name: 'Anderson',
322
325
  country: 'USA'
323
326
  },
324
327
  {
328
+ user_type: 'payin',
325
329
  email: 'buyer2@example.com',
326
330
  first_name: 'Bob',
327
331
  last_name: 'Brown',
328
332
  country: 'USA'
329
333
  },
330
334
  {
335
+ user_type: 'payout',
331
336
  email: 'seller1@example.com',
332
337
  first_name: 'Charlie',
333
338
  last_name: 'Chen',
@@ -336,8 +341,7 @@ users_to_create = [
336
341
  address_line1: '123 Test St',
337
342
  city: 'Sydney',
338
343
  state: 'NSW',
339
- zip: '2000',
340
- user_type: 'payout'
344
+ zip: '2000'
341
345
  }
342
346
  ]
343
347
 
@@ -549,6 +553,7 @@ end
549
553
  # Step 1: Create user during signup (minimal info)
550
554
  def create_initial_user(email:, name_parts:)
551
555
  ZaiPayment.users.create(
556
+ user_type: 'payin', # or 'payout' based on your use case
552
557
  email: email,
553
558
  first_name: name_parts[:first],
554
559
  last_name: name_parts[:last],
@@ -592,32 +597,40 @@ Create a user representing a business entity with full company details.
592
597
  ```ruby
593
598
  # Example: Create a merchant user with company information
594
599
  response = ZaiPayment.users.create(
595
- # Personal details
600
+ # User type
601
+ user_type: 'payout',
602
+
603
+ # Personal details (required for payout users)
596
604
  email: 'john.director@example.com',
597
605
  first_name: 'John',
598
606
  last_name: 'Smith',
599
607
  country: 'AUS',
608
+ dob: '15/06/1985',
609
+ address_line1: '789 Business Ave',
610
+ city: 'Melbourne',
611
+ state: 'VIC',
612
+ zip: '3000',
600
613
  mobile: '+61412345678',
601
614
 
602
615
  # Business role
603
616
  authorized_signer_title: 'Director',
604
617
 
605
- # Company details
618
+ # Company details (required fields for payout companies)
606
619
  company: {
607
620
  name: 'Smith Trading Co',
608
621
  legal_name: 'Smith Trading Company Pty Ltd',
609
622
  tax_number: '53004085616', # ABN for Australian companies
610
623
  business_email: 'accounts@smithtrading.com',
611
624
  country: 'AUS',
612
- charge_tax: true, # GST registered
613
-
614
- # Business address
615
625
  address_line1: '123 Business Street',
616
- address_line2: 'Suite 5',
617
626
  city: 'Melbourne',
618
627
  state: 'VIC',
619
628
  zip: '3000',
620
- phone: '+61398765432'
629
+ phone: '+61398765432',
630
+
631
+ # Optional fields
632
+ address_line2: 'Suite 5',
633
+ charge_tax: true # GST registered
621
634
  }
622
635
  )
623
636
 
@@ -630,27 +643,24 @@ end
630
643
 
631
644
  ### Pattern 4: Enhanced Fraud Prevention
632
645
 
633
- Create users with additional verification data for enhanced security.
646
+ Capture device information for payin users during payment flow.
634
647
 
635
648
  ```ruby
636
- # Example: Payin user with driver's license and IP tracking
649
+ # Example: Payin user creation with recommended fields
637
650
  response = ZaiPayment.users.create(
638
651
  # Required fields
652
+ user_type: 'payin',
639
653
  email: 'secure.buyer@example.com',
640
654
  first_name: 'Sarah',
641
655
  last_name: 'Johnson',
642
656
  country: 'USA',
643
657
 
644
- # Enhanced verification
658
+ # Recommended verification fields
645
659
  dob: '15/01/1990',
646
660
  government_number: '123-45-6789', # SSN for US
647
661
  drivers_license_number: 'D1234567',
648
662
  drivers_license_state: 'CA',
649
663
 
650
- # Fraud prevention
651
- ip_address: '192.168.1.100',
652
- device_id: 'device_abc123xyz',
653
-
654
664
  # Contact and address
655
665
  mobile: '+14155551234',
656
666
  address_line1: '456 Market Street',
@@ -660,16 +670,22 @@ response = ZaiPayment.users.create(
660
670
  zip: '94103'
661
671
  )
662
672
 
663
- puts "Secure user created with enhanced verification"
673
+ user_id = response.data['id']
674
+ puts "User created with enhanced profile"
675
+
676
+ # Note: device_id and ip_address should be captured during payment
677
+ # and will be required when creating an item and charging a card.
678
+ # They are typically obtained from your payment form or checkout page.
664
679
  ```
665
680
 
666
681
  ### Pattern 5: Custom Branding for Merchants
667
682
 
668
- Create a merchant user with custom branding for statements and payment pages.
683
+ Create a payout merchant user with custom branding for statements and payment pages.
669
684
 
670
685
  ```ruby
671
686
  # Example: Merchant with custom branding
672
687
  response = ZaiPayment.users.create(
688
+ user_type: 'payout',
673
689
  email: 'merchant@brandedstore.com',
674
690
  first_name: 'Alex',
675
691
  last_name: 'Merchant',
@@ -677,17 +693,17 @@ response = ZaiPayment.users.create(
677
693
  mobile: '+61411222333',
678
694
  dob: '10/05/1985',
679
695
 
696
+ # Required address for payout users
697
+ address_line1: '789 Retail Plaza',
698
+ city: 'Brisbane',
699
+ state: 'QLD',
700
+ zip: '4000',
701
+
680
702
  # Branding
681
703
  logo_url: 'https://example.com/logo.png',
682
704
  color_1: '#FF5733', # Primary brand color
683
705
  color_2: '#C70039', # Secondary brand color
684
- custom_descriptor: 'BRANDED STORE', # Shows on bank statements
685
-
686
- # Address
687
- address_line1: '789 Retail Plaza',
688
- city: 'Brisbane',
689
- state: 'QLD',
690
- zip: '4000'
706
+ custom_descriptor: 'BRANDED STORE' # Shows on bank statements
691
707
  )
692
708
 
693
709
  merchant = response.data
@@ -697,11 +713,12 @@ puts "Custom descriptor: #{merchant['custom_descriptor']}"
697
713
 
698
714
  ### Pattern 6: AMEX Merchant Setup
699
715
 
700
- Create a merchant specifically configured for American Express transactions.
716
+ Create a payout merchant specifically configured for American Express transactions.
701
717
 
702
718
  ```ruby
703
719
  # Example: AMEX merchant with required fields
704
720
  response = ZaiPayment.users.create(
721
+ user_type: 'payout',
705
722
  email: 'director@amexshop.com',
706
723
  first_name: 'Michael',
707
724
  last_name: 'Director',
@@ -712,25 +729,27 @@ response = ZaiPayment.users.create(
712
729
  # AMEX requirement: Must specify authorized signer title
713
730
  authorized_signer_title: 'Managing Director',
714
731
 
715
- # Business details
732
+ # Required address for payout users
716
733
  address_line1: '100 Corporate Drive',
717
734
  city: 'Sydney',
718
735
  state: 'NSW',
719
736
  zip: '2000',
720
737
 
721
- # Company for AMEX merchants
738
+ # Company for AMEX merchants (required fields for payout companies)
722
739
  company: {
723
740
  name: 'AMEX Shop',
724
741
  legal_name: 'AMEX Shop Pty Limited',
725
742
  tax_number: '51824753556',
726
743
  business_email: 'finance@amexshop.com',
727
744
  country: 'AUS',
728
- charge_tax: true,
729
745
  address_line1: '100 Corporate Drive',
730
746
  city: 'Sydney',
731
747
  state: 'NSW',
732
748
  zip: '2000',
733
- phone: '+61299887766'
749
+ phone: '+61299887766',
750
+
751
+ # Optional
752
+ charge_tax: true
734
753
  }
735
754
  )
736
755
 
@@ -739,7 +758,7 @@ puts "AMEX-ready merchant created: #{response.data['id']}"
739
758
 
740
759
  ## See Also
741
760
 
742
- - [User Management Documentation](../docs/USERS.md)
761
+ - [User Management Documentation](../docs/users.md)
743
762
  - [Webhook Examples](webhooks.md)
744
763
  - [Zai API Reference](https://developer.hellozai.com/reference)
745
764
 
@@ -28,7 +28,7 @@ A comprehensive User resource that provides CRUD operations for managing both pa
28
28
  - Country (ISO 3166-1 alpha-3 code, required)
29
29
  - Address details (line1, line2, city, state, zip)
30
30
  - Contact information (mobile, phone)
31
- - Date of birth (YYYYMMDD format)
31
+ - Date of birth (DD/MM/YYYY format)
32
32
  - Government ID number
33
33
  - Device ID and IP address (for fraud prevention)
34
34
  - User type designation (payin/payout)
@@ -37,7 +37,7 @@ A comprehensive User resource that provides CRUD operations for managing both pa
37
37
  - Required field validation
38
38
  - Email format validation
39
39
  - Country code validation (3-letter ISO codes)
40
- - Date of birth format validation (YYYYMMDD)
40
+ - Date of birth format validation (DD/MM/YYYY)
41
41
  - User type validation (payin/payout)
42
42
 
43
43
  ### 2. Client Updates (`lib/zai_payment/client.rb`)
@@ -83,7 +83,7 @@ A comprehensive User resource that provides CRUD operations for managing both pa
83
83
 
84
84
  ### 6. Documentation
85
85
 
86
- #### User Guide (`docs/USERS.md`)
86
+ #### User Guide (`docs/users.md`)
87
87
  Comprehensive guide covering:
88
88
  - Overview of payin vs payout users
89
89
  - Required fields for each user type
@@ -110,7 +110,7 @@ Practical examples including:
110
110
  - RSpec integration tests
111
111
  - Common patterns with retry logic
112
112
 
113
- #### README Updates (`README.md`)
113
+ #### README Updates (`readme.md`)
114
114
  - Added Users section with quick examples
115
115
  - Updated roadmap to mark Users as "Done"
116
116
  - Added documentation links
@@ -199,7 +199,7 @@ response = ZaiPayment.users.update(
199
199
  **Required:**
200
200
  - Email, first name, last name, country
201
201
  - Address, city, state, zip
202
- - Date of birth (YYYYMMDD format)
202
+ - Date of birth (DD/MM/YYYY format)
203
203
 
204
204
  **Recommended:**
205
205
  - Mobile, government number
@@ -208,7 +208,7 @@ response = ZaiPayment.users.update(
208
208
 
209
209
  1. **Email**: Must be valid email format
210
210
  2. **Country**: Must be 3-letter ISO 3166-1 alpha-3 code (e.g., USA, AUS, GBR)
211
- 3. **Date of Birth**: Must be YYYYMMDD format (e.g., 19900101)
211
+ 3. **Date of Birth**: Must be DD/MM/YYYY format (e.g., 19900101)
212
212
  4. **User Type**: Must be 'payin' or 'payout' (optional field)
213
213
 
214
214
  ## Error Handling
@@ -235,14 +235,14 @@ The implementation provides proper error handling for:
235
235
  ### Created Files:
236
236
  1. `/lib/zai_payment/resources/user.rb` - User resource class
237
237
  2. `/spec/zai_payment/resources/user_spec.rb` - Test suite
238
- 3. `/docs/USERS.md` - User management guide
238
+ 3. `/docs/users.md` - User management guide
239
239
  4. `/examples/users.md` - Usage examples
240
240
 
241
241
  ### Modified Files:
242
242
  1. `/lib/zai_payment/client.rb` - Added endpoint support
243
243
  2. `/lib/zai_payment/response.rb` - Added users data handling
244
244
  3. `/lib/zai_payment.rb` - Integrated User resource
245
- 4. `/README.md` - Added Users section and updated roadmap
245
+ 4. `/readme.md` - Added Users section and updated roadmap
246
246
 
247
247
  ## Code Quality
248
248
 
@@ -292,7 +292,7 @@ The implementation is complete and ready for use. Recommended next steps:
292
292
  ## Support
293
293
 
294
294
  For questions or issues:
295
- 1. Check the documentation in `/docs/USERS.md`
295
+ 1. Check the documentation in `/docs/users.md`
296
296
  2. Review examples in `/examples/users.md`
297
297
  3. Run tests: `bundle exec rspec spec/zai_payment/resources/user_spec.rb`
298
298
  4. Refer to Zai Developer Portal: https://developer.hellozai.com/