5
5
using System . Collections . Generic ;
6
6
using System . Net ;
7
7
using System . Runtime . Serialization ;
8
+ using System . Text ;
8
9
using System . Threading . Tasks ;
9
10
using ServiceStack . Stripe . Types ;
10
11
using ServiceStack . Text ;
11
12
12
13
namespace ServiceStack . Stripe
13
14
{
14
- /* Charges
15
+ /* Charges
15
16
* https://stripe.com/docs/api/curl#charges
16
17
*/
17
18
[ Route ( "/charges" ) ]
@@ -83,7 +84,7 @@ public string ToUrl(string absoluteUrl)
83
84
}
84
85
}
85
86
86
- /* Customers
87
+ /* Customers
87
88
* https://stripe.com/docs/api/curl#customers
88
89
*/
89
90
[ Route ( "/customers" ) ]
@@ -97,6 +98,9 @@ public class CreateStripeCustomer : IPost, IReturn<StripeCustomer>
97
98
public string Plan { get ; set ; }
98
99
public int ? Quantity { get ; set ; }
99
100
public DateTime ? TrialEnd { get ; set ; }
101
+ public Dictionary < string , string > Metadata { get ; set ; }
102
+ public string Currency { get ; set ; }
103
+ public string BusinessVatId { get ; set ; }
100
104
}
101
105
102
106
[ Route ( "/customers" ) ]
@@ -110,6 +114,9 @@ public class CreateStripeCustomerWithToken : IPost, IReturn<StripeCustomer>
110
114
public string Plan { get ; set ; }
111
115
public int ? Quantity { get ; set ; }
112
116
public DateTime ? TrialEnd { get ; set ; }
117
+ public Dictionary < string , string > Metadata { get ; set ; }
118
+ public string Currency { get ; set ; }
119
+ public string BusinessVatId { get ; set ; }
113
120
}
114
121
115
122
[ Route ( "/customers/{Id}" ) ]
@@ -130,6 +137,9 @@ public class UpdateStripeCustomer : IPost, IReturn<StripeCustomer>
130
137
public string Description { get ; set ; }
131
138
public string Email { get ; set ; }
132
139
public string Source { get ; set ; }
140
+ public Dictionary < string , string > Metadata { get ; set ; }
141
+ public string Currency { get ; set ; }
142
+ public string BusinessVatId { get ; set ; }
133
143
}
134
144
135
145
[ Route ( "/customers/{Id}" ) ]
@@ -376,12 +386,22 @@ public class PayStripeInvoice : IPost, IReturn<StripeInvoice>
376
386
}
377
387
378
388
[ Route ( "/invoices" ) ]
379
- public class GetStripeInvoices : IGet , IReturn < StripeCollection < StripeInvoice > >
389
+ public class GetStripeInvoices : IGet , IReturn < StripeCollection < StripeInvoice > > , IUrlFilter
380
390
{
381
391
public string Customer { get ; set ; }
382
392
public DateTime ? Date { get ; set ; }
383
393
public int ? Count { get ; set ; }
384
394
public int ? Offset { get ; set ; }
395
+
396
+ [ IgnoreDataMember ]
397
+ public StripeDateOptions DateOptions { get ; set ; }
398
+
399
+ public string ToUrl ( string absoluteUrl )
400
+ {
401
+ return Date != null || DateOptions == null
402
+ ? absoluteUrl
403
+ : absoluteUrl . AppendOptions ( "date" , DateOptions ) ;
404
+ }
385
405
}
386
406
387
407
[ Route ( "/invoices/upcoming" ) ]
@@ -408,12 +428,11 @@ public class StripeToken : StripeId
408
428
public StripeCard Card { get ; set ; }
409
429
}
410
430
411
- /*
412
- Accounts
431
+ /*
432
+ Accounts
413
433
*/
414
-
415
434
[ Route ( "/accounts" ) ]
416
- public class CreateStripeAccount : IPost , IReturn < StripeAccount >
435
+ public class CreateStripeAccount : IPost , IReturn < CreateStripeAccountResponse >
417
436
{
418
437
public string Country { get ; set ; }
419
438
public bool Managed { get ; set ; }
@@ -422,6 +441,11 @@ public class CreateStripeAccount : IPost, IReturn<StripeAccount>
422
441
public StripeLegalEntity LegalEntity { get ; set ; }
423
442
}
424
443
444
+ public class CreateStripeAccountResponse : StripeAccount
445
+ {
446
+ public Dictionary < string , string > Keys { get ; set ; }
447
+ }
448
+
425
449
public class StripeTosAcceptance
426
450
{
427
451
public DateTime Date { get ; set ; }
@@ -431,18 +455,74 @@ public class StripeTosAcceptance
431
455
432
456
public class StripeLegalEntity
433
457
{
434
- public StripeDob Dob { get ; set ; }
458
+ public StripeOwner [ ] AdditionalOwners { get ; set ; }
459
+ public StripeAddress Address { get ; set ; }
460
+ public string BusinessName { get ; set ; }
461
+ public bool ? BusinessTaxIdProvided { get ; set ; }
462
+ public StripeDate Dob { get ; set ; }
463
+ public string FirstName { get ; set ; }
464
+ public string LastName { get ; set ; }
465
+ public StripeAddress PersonalAddress { get ; set ; }
466
+ public bool ? PersonalIdNumberProvided { get ; set ; }
467
+ public bool ? SsnLast4Provided { get ; set ; }
468
+ public string Type { get ; set ; }
469
+ public StripeVerificationBusiness Verification { get ; set ; }
435
470
}
436
471
437
472
public class StripeAccount : StripeId
438
473
{
439
- public Dictionary < string , string > Keys { get ; set ; }
474
+ public string BusinessName { get ; set ; }
475
+ public string BusinessPrimaryColor { get ; set ; }
476
+ public string BusinessUrl { get ; set ; }
477
+ public bool ChargesEnabled { get ; set ; }
478
+ public string Country { get ; set ; }
479
+ public string [ ] CurrenciesSupported { get ; set ; }
480
+ public bool DebitNegativeBalances { get ; set ; }
481
+ public StripeDeclineCharge DeclineChargeOn { get ; set ; }
482
+ public string DefaultCurrency { get ; set ; }
483
+ public bool DetailsSubmitted { get ; set ; }
484
+ public string DisplayName { get ; set ; }
485
+ public string Email { get ; set ; }
486
+ public StripeLegalEntity LegalEntity { get ; set ; }
487
+ public bool Managed { get ; set ; }
488
+ public string ProductDescription { get ; set ; }
489
+ public string StatementDescriptor { get ; set ; }
490
+ public string SupportEmail { get ; set ; }
491
+ public string SupportPhone { get ; set ; }
492
+ public string SupportUrl { get ; set ; }
493
+ public string Timezone { get ; set ; }
494
+ public StripeTosAcceptance TosAcceptance { get ; set ; }
495
+ public StripeVerificationAccount Verification { get ; set ; }
496
+ }
497
+
498
+ public class StripeDeclineCharge
499
+ {
500
+ public bool AvsFailure { get ; set ; }
501
+ public bool CvcFailure { get ; set ; }
502
+ }
503
+
504
+ public class StripeOwner
505
+ {
506
+ public StripeAddress Address { get ; set ; }
507
+ public StripeDate Dob { get ; set ; }
508
+ public string FirstName { get ; set ; }
509
+ public string LastName { get ; set ; }
440
510
}
441
511
442
- public class StripeDob
512
+ public class StripeAddress
443
513
{
444
- public StripeDob ( ) { }
445
- public StripeDob ( int year , int month , int day )
514
+ public string City { get ; set ; }
515
+ public string Country { get ; set ; }
516
+ public string Line1 { get ; set ; }
517
+ public string Line2 { get ; set ; }
518
+ public string PostalCode { get ; set ; }
519
+ public string State { get ; set ; }
520
+ }
521
+
522
+ public class StripeDate
523
+ {
524
+ public StripeDate ( ) { }
525
+ public StripeDate ( int year , int month , int day )
446
526
{
447
527
Year = year ;
448
528
Month = month ;
@@ -454,6 +534,30 @@ public StripeDob(int year, int month, int day)
454
534
public int Day { get ; set ; }
455
535
}
456
536
537
+ public class StripeVerificationBusiness
538
+ {
539
+ public string Details { get ; set ; }
540
+ public string DetailsCode { get ; set ; }
541
+ public string Document { get ; set ; }
542
+ public string Status { get ; set ; }
543
+ }
544
+
545
+ public class StripeTransferSchedule
546
+ {
547
+ public int DelayDays { get ; set ; }
548
+ public string Interval { get ; set ; }
549
+ public int MonthlyAnchor { get ; set ; }
550
+ public string WeeklyAnchor { get ; set ; }
551
+ public bool TransfersEnabled { get ; set ; }
552
+ }
553
+
554
+ public class StripeVerificationAccount
555
+ {
556
+ public string DisabledReason { get ; set ; }
557
+ public DateTime ? DueBy { get ; set ; }
558
+ public string [ ] FieldsNeeded { get ; set ; }
559
+ }
560
+
457
561
458
562
public class StripeGateway : IRestGateway
459
563
{
@@ -637,12 +741,14 @@ private static string GetMethod<T>(IReturn<T> request)
637
741
638
742
public T Send < T > ( IReturn < T > request )
639
743
{
640
- return Send ( request , GetMethod ( request ) , sendRequestBody : false ) ;
744
+ var method = GetMethod ( request ) ;
745
+ return Send ( request , method , sendRequestBody : method == HttpMethods . Post || method == HttpMethods . Put ) ;
641
746
}
642
747
643
748
public Task < T > SendAsync < T > ( IReturn < T > request )
644
749
{
645
- return SendAsync ( request , GetMethod ( request ) , sendRequestBody : false ) ;
750
+ var method = GetMethod ( request ) ;
751
+ return SendAsync ( request , method , sendRequestBody : method == HttpMethods . Post || method == HttpMethods . Put ) ;
646
752
}
647
753
648
754
public T Get < T > ( IReturn < T > request )
@@ -695,6 +801,42 @@ public Task<T> DeleteAsync<T>(IReturn<T> request)
695
801
return SendAsync ( request , HttpMethods . Delete , sendRequestBody : false ) ;
696
802
}
697
803
}
804
+
805
+ public class StripeDateOptions
806
+ {
807
+ public DateTime ? After { get ; set ; }
808
+ public DateTime ? OnOrAfter { get ; set ; }
809
+ public DateTime ? Before { get ; set ; }
810
+ public DateTime ? OnOrBefore { get ; set ; }
811
+ }
812
+
813
+ internal static class UrlExtensions
814
+ {
815
+ public static string AppendOptions ( this string url , string name , StripeDateOptions options )
816
+ {
817
+ var sb = new StringBuilder ( ) ;
818
+ var map = new Dictionary < string , DateTime ? >
819
+ {
820
+ { "gt" , options . After } ,
821
+ { "gte" , options . OnOrAfter } ,
822
+ { "lt" , options . Before } ,
823
+ { "lte" , options . OnOrBefore } ,
824
+ } ;
825
+
826
+ foreach ( var entry in map )
827
+ {
828
+ if ( entry . Value == null )
829
+ continue ;
830
+
831
+ url = url . AddQueryParam (
832
+ "{0}[{1}]" . Fmt ( name , entry . Key ) ,
833
+ entry . Value . Value . ToUnixTime ( ) ) ;
834
+ }
835
+
836
+ return url ;
837
+ }
838
+ }
839
+
698
840
}
699
841
700
842
namespace ServiceStack . Stripe . Types
@@ -877,6 +1019,8 @@ public class StripeCustomer : StripeId
877
1019
878
1020
public bool Deleted { get ; set ; }
879
1021
public string DefaultSource { get ; set ; }
1022
+ public string Currency { get ; set ; }
1023
+ public string BusinessVatId { get ; set ; }
880
1024
}
881
1025
882
1026
public class GetAllStripeCustomers
@@ -1196,4 +1340,4 @@ public static class Currencies
1196
1340
public const string YemeniRial = "YER" ;
1197
1341
public const string SouthAfricanRand = "ZAR" ;
1198
1342
}
1199
- }
1343
+ }
0 commit comments