@@ -641,6 +641,55 @@ public void Deserialize()
641
641
Assert . Equal ( typeof ( Foo ) , deserialized . GetType ( ) ) ;
642
642
}
643
643
644
+ [ Fact ]
645
+ public async Task StripeContextHeaderSet ( )
646
+ {
647
+ var apiRequestorWithContext = new LiveApiRequestor ( new StripeClientOptions
648
+ {
649
+ ApiKey = "sk_test_123" ,
650
+ HttpClient = this . httpClient ,
651
+ StripeContext = "ctx_1234" ,
652
+ } ) ;
653
+ var response = new StripeResponse ( HttpStatusCode . OK , null , "{}" ) ;
654
+ this . httpClient . Response = response ;
655
+
656
+ var service = new CustomerService ( apiRequestorWithContext ) ;
657
+
658
+ await service . CreateAsync ( new CustomerCreateOptions ( ) { } ) ;
659
+ var lastRequest = this . httpClient . LastRequest ;
660
+ Assert . Equal ( "ctx_1234" , lastRequest . StripeHeaders [ "Stripe-Context" ] ) ;
661
+
662
+ // If its set in the request options, that takes precendence
663
+ await service . CreateAsync ( new CustomerCreateOptions ( ) { } , new RequestOptions { StripeContext = "ctx_2345" } ) ;
664
+ lastRequest = this . httpClient . LastRequest ;
665
+ Assert . Equal ( "ctx_2345" , lastRequest . StripeHeaders [ "Stripe-Context" ] ) ;
666
+ }
667
+
668
+ [ Fact ]
669
+ public async Task StripeAccountHeaderSet ( )
670
+ {
671
+ var apiRequestorWithContext = new LiveApiRequestor ( new StripeClientOptions
672
+ {
673
+ ApiKey = "sk_test_123" ,
674
+ HttpClient = this . httpClient ,
675
+ StripeAccount = "acct_1234" ,
676
+ } ) ;
677
+
678
+ var response = new StripeResponse ( HttpStatusCode . OK , null , "{}" ) ;
679
+ this . httpClient . Response = response ;
680
+
681
+ var service = new CustomerService ( apiRequestorWithContext ) ;
682
+
683
+ await service . CreateAsync ( new CustomerCreateOptions ( ) { } ) ;
684
+ var lastRequest = this . httpClient . LastRequest ;
685
+ Assert . Equal ( "acct_1234" , lastRequest . StripeHeaders [ "Stripe-Account" ] ) ;
686
+
687
+ // If its set in the request options, that takes precendence
688
+ await service . CreateAsync ( new CustomerCreateOptions ( ) { } , new RequestOptions { StripeAccount = "acct_2345" } ) ;
689
+ lastRequest = this . httpClient . LastRequest ;
690
+ Assert . Equal ( "acct_2345" , lastRequest . StripeHeaders [ "Stripe-Account" ] ) ;
691
+ }
692
+
644
693
private class Foo : StripeEntity < Foo >
645
694
{
646
695
[ JsonProperty ( "bar" ) ]
0 commit comments