Move STPAPIClient to StripeCore (#386)

* Move STPAPIClient to StripeCore.
* Keep payments-related functionality in Stripe.
* Create Objective-C wrappers in Stripe.framework for STPAPIClient, StripeError, and StripeAPI to prevent users from changing their integration. (Tests for this were added in Prepare tests and UI Examples app for modularized API Client #382)
This commit is contained in:
davidme-stripe 2021-10-15 17:34:11 -07:00 committed by GitHub
parent 537d4e56db
commit 28dc61bcf9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
45 changed files with 1579 additions and 572 deletions

View File

@ -24,6 +24,7 @@
0FC7C95025B0EAF900E99D3E /* STPPaymentMethodAfterpayClearpayParamsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 0FC7C94F25B0EAF900E99D3E /* STPPaymentMethodAfterpayClearpayParamsTest.m */; };
0FC7C95325B1075D00E99D3E /* STPPaymentMethodAfterpayClearpayTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 0FC7C95225B1075D00E99D3E /* STPPaymentMethodAfterpayClearpayTest.m */; };
3100770B253A735F00A5D35D /* NSURLComponents+Stripe.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABD4225117C9400CC59EF /* NSURLComponents+Stripe.swift */; };
310AF468271A5151007339F4 /* StripeAPI+Deprecated.swift in Sources */ = {isa = PBXBuildFile; fileRef = 310AF467271A5151007339F4 /* StripeAPI+Deprecated.swift */; };
3111BE742512FD0800288D28 /* STPTelemetryClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABD6A25117C9600CC59EF /* STPTelemetryClient.swift */; };
3111BE792513039700288D28 /* STPShippingMethodTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABD6C25117C9700CC59EF /* STPShippingMethodTableViewCell.swift */; };
3111BE802513057C00288D28 /* STPMultiFormTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABD9A25117C9900CC59EF /* STPMultiFormTextField.swift */; };
@ -32,8 +33,7 @@
3111BE9F251316E600288D28 /* STPAddCardViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABDAD25117C9A00CC59EF /* STPAddCardViewController.swift */; };
3111C2F7252683CE00207E32 /* STPCardBrand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABDB225117C9B00CC59EF /* STPCardBrand.swift */; };
3111C2FE252688B800207E32 /* STPFakeAddPaymentPassViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABE1B25117CA100CC59EF /* STPFakeAddPaymentPassViewController.swift */; };
3111C30225268ED800207E32 /* STPError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABDFD25117C9F00CC59EF /* STPError.swift */; };
3111C3082526956500207E32 /* NSError+Stripe.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABDA525117C9A00CC59EF /* NSError+Stripe.swift */; };
3111C30225268ED800207E32 /* _stpobjc_STPError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABDFD25117C9F00CC59EF /* _stpobjc_STPError.swift */; };
3111C30C252697A800207E32 /* STPPaymentMethodEnums.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABDA225117C9A00CC59EF /* STPPaymentMethodEnums.swift */; };
3111C31125269B0700207E32 /* STPPaymentOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABDA725117C9A00CC59EF /* STPPaymentOption.swift */; };
3111C3152526A53400207E32 /* STPSourceEnums.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABE1425117CA000CC59EF /* STPSourceEnums.swift */; };
@ -45,7 +45,6 @@
3111C32F2526BE8600207E32 /* NSDecimalNumber+Stripe_Currency.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABD7225117C9700CC59EF /* NSDecimalNumber+Stripe_Currency.swift */; };
3111C3392526C24F00207E32 /* STPDispatchFunctions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABD7925117C9700CC59EF /* STPDispatchFunctions.swift */; };
3111C33D2526C2A300207E32 /* STPPromise.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABD8525117C9800CC59EF /* STPPromise.swift */; };
3111C3422526C71A00207E32 /* STPEphemeralKeyManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABD5E25117C9600CC59EF /* STPEphemeralKeyManager.swift */; };
3111C3522527871300207E32 /* STPCustomerContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABE1325117CA000CC59EF /* STPCustomerContext.swift */; };
3111C35725279C3B00207E32 /* STPSwiftFixtures.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3111C35625279C3B00207E32 /* STPSwiftFixtures.swift */; };
3111C3612527B62C00207E32 /* STPBackendAPIAdapter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABE1825117CA100CC59EF /* STPBackendAPIAdapter.swift */; };
@ -168,12 +167,13 @@
3137A74726FD76EC008BEF7B /* STPAPISettingsBridgeTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 316E9F7526FA9AD400986485 /* STPAPISettingsBridgeTest.m */; };
3137A74826FD76F2008BEF7B /* STPAPIClientNetworkBridgeTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 3137A74326FD7687008BEF7B /* STPAPIClientNetworkBridgeTest.m */; };
3137A74C26FD7710008BEF7B /* STPErrorBridgeTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 3137A74A26FD7710008BEF7B /* STPErrorBridgeTest.m */; };
3137A74D26FD7AF5008BEF7B /* STPURLCallbackHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABD5925117C9500CC59EF /* STPURLCallbackHandler.swift */; };
3137A74D26FD7AF5008BEF7B /* (null) in Sources */ = {isa = PBXBuildFile; };
3137A74F26FE8754008BEF7B /* URLRequest+StripeTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3137A74E26FE8754008BEF7B /* URLRequest+StripeTest.swift */; };
3137A75126FE878E008BEF7B /* APIStubbedTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3137A75026FE878E008BEF7B /* APIStubbedTestCase.swift */; };
315E4B302639C86B00C1D955 /* STPIntentActionWeChatPayRedirectToApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 315E4B2F2639C86B00C1D955 /* STPIntentActionWeChatPayRedirectToApp.swift */; };
315E4B362639D80F00C1D955 /* STPIntentActionWeChatPayRedirectToAppTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 315E4B352639D80F00C1D955 /* STPIntentActionWeChatPayRedirectToAppTest.swift */; };
31686174260ED62A00BF1C69 /* URLSession+Retry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31686173260ED62A00BF1C69 /* URLSession+Retry.swift */; };
316E9F7926FA9FDF00986485 /* _stpobjc_STPAppInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 316E9F7826FA9FDF00986485 /* _stpobjc_STPAppInfo.swift */; };
316F8110254109FC000A80B5 /* STPIntentActionOXXODisplayDetails.swift in Sources */ = {isa = PBXBuildFile; fileRef = 316F810F254109FC000A80B5 /* STPIntentActionOXXODisplayDetails.swift */; };
316F811625410B0E000A80B5 /* STPPaymentMethodOXXO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 316F811525410B0E000A80B5 /* STPPaymentMethodOXXO.swift */; };
316F811A25410B12000A80B5 /* STPPaymentMethodOXXOParams.swift in Sources */ = {isa = PBXBuildFile; fileRef = 316F811925410B12000A80B5 /* STPPaymentMethodOXXOParams.swift */; };
@ -212,7 +212,7 @@
317ABF3B251193B600CC59EF /* STPCardScannerTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABE0D25117CA000CC59EF /* STPCardScannerTableViewCell.swift */; };
317ABF40251196A600CC59EF /* STPCameraView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABD9325117C9900CC59EF /* STPCameraView.swift */; };
317ABF462511983100CC59EF /* STPColorUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABD5425117C9500CC59EF /* STPColorUtils.swift */; };
317ABF53251292B400CC59EF /* STPAppInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABE0325117C9F00CC59EF /* STPAppInfo.swift */; };
317ABF53251292B400CC59EF /* (null) in Sources */ = {isa = PBXBuildFile; };
317ABF5A2512957800CC59EF /* STPBECSDebitAccountNumberValidator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABD7625117C9700CC59EF /* STPBECSDebitAccountNumberValidator.swift */; };
317ABF5D2512979A00CC59EF /* STPBINRange.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABD2625117C9200CC59EF /* STPBINRange.swift */; };
317E054125D494F3006D4C29 /* STPPaymentMethodCardParamsTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317E054025D494F3006D4C29 /* STPPaymentMethodCardParamsTest.swift */; };
@ -296,7 +296,10 @@
3194909B25144D7800AD8F0B /* STPPaymentContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABD5025117C9500CC59EF /* STPPaymentContext.swift */; };
3194CF5C2314869500E1940F /* STPPaymentMethodFPXTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 3194CF5B2314869400E1940F /* STPPaymentMethodFPXTest.m */; };
3194CF5E231487A200E1940F /* STPFPXBankBrandTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 3194CF5D231487A100E1940F /* STPFPXBankBrandTest.m */; };
319E3659271A03B300460867 /* STPAPIClient+Payments.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABD8625117C9800CC59EF /* STPAPIClient+Payments.swift */; };
31A4381E251052C00067F936 /* FBSnapshotTestCase.xcframework in CopyFiles */ = {isa = PBXBuildFile; fileRef = F15AC18D1DBA9CA90009EADE /* FBSnapshotTestCase.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
31B49E9B26E8269C00A0464A /* _stpobjc_STPAPIClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31B49E9A26E8269C00A0464A /* _stpobjc_STPAPIClient.swift */; };
31B49EA826E9743D00A0464A /* StripeCore+Import.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31B49EA726E9743C00A0464A /* StripeCore+Import.swift */; };
31C2621A255F887A000C5B50 /* Stripe-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 31C26219255F887A000C5B50 /* Stripe-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; };
31C5B86E252E518E00A481A7 /* STPAddCardViewControllerTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3111C3F5252BC79D00207E32 /* STPAddCardViewControllerTest.swift */; };
31C5B871252E746200A481A7 /* STPBECSDebitAccountNumberValidatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3111C3A7252BC79000207E32 /* STPBECSDebitAccountNumberValidatorTests.swift */; };
@ -330,11 +333,13 @@
31D4D6962512EE0100809066 /* UIViewController+Stripe_ParentViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABDF325117C9E00CC59EF /* UIViewController+Stripe_ParentViewController.swift */; };
31D4D69E2512F68D00809066 /* STPStringUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABE1925117CA100CC59EF /* STPStringUtils.swift */; };
31E242FB26F9028400064908 /* STPCustomerContextTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31E242FA26F9028400064908 /* STPCustomerContextTest.swift */; };
31E242FD26FA3EBC00064908 /* _stpobjc_StripeAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31E242FC26FA3EBC00064908 /* _stpobjc_StripeAPI.swift */; };
31E2430026FA428E00064908 /* STPApplePayTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31E242FE26FA424900064908 /* STPApplePayTest.swift */; };
31EFEE0E258AE3F40069BC5F /* Stripe3DS2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 31EFEE0D258AE3F40069BC5F /* Stripe3DS2.framework */; };
31F2E875252403AD004D4B5E /* STPRedirectContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABDBD25117C9B00CC59EF /* STPRedirectContext.swift */; };
31F2E8782524143F004D4B5E /* STPPaymentResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABD6225117C9600CC59EF /* STPPaymentResult.swift */; };
31F2E87C25241C30004D4B5E /* STPApplePayPaymentOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABE2425117CA100CC59EF /* STPApplePayPaymentOption.swift */; };
31F9015E26FEA07000F9E11D /* STPEphemeralKeyManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABD5E25117C9600CC59EF /* STPEphemeralKeyManager.swift */; };
36002B782584251700E46F8B /* CheckboxButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 36002B772584251700E46F8B /* CheckboxButton.swift */; };
360C28A12567199100A6BF67 /* STPGenericInputTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 360C28A02567199100A6BF67 /* STPGenericInputTextField.swift */; };
3617A51420FE5BBB001A9E6A /* NSLocale+STPSwizzling.h in Headers */ = {isa = PBXBuildFile; fileRef = 3617A51220FE5BBB001A9E6A /* NSLocale+STPSwizzling.h */; };
@ -441,10 +446,7 @@
36FB69D725267E6200F129CE /* STPPaymentHandlerActionParams.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABD4525117C9400CC59EF /* STPPaymentHandlerActionParams.swift */; };
448895AF245255D800F7D0C2 /* STPPaymentMethodPrzelewy24ParamsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 448895AE245255D800F7D0C2 /* STPPaymentMethodPrzelewy24ParamsTests.m */; };
44BDCFDF245A46CC007EE6D5 /* STPPaymentMethodBancontactParamsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 44BDCFDE245A46CC007EE6D5 /* STPPaymentMethodBancontactParamsTests.m */; };
618E787926EFDA2A0034A01F /* ServerErrorMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 618E787826EFDA2A0034A01F /* ServerErrorMapper.swift */; };
618E787B26EFDD310034A01F /* ServerErrorMapperTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 618E787A26EFDD310034A01F /* ServerErrorMapperTest.swift */; };
61B4BC3126D53E5F0099D768 /* PaymentRequirementProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61B4BC3026D53E5F0099D768 /* PaymentRequirementProvider.swift */; };
61B4BC3426D53EB10099D768 /* PaymentSheet+HelperTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61B4BC3226D53E790099D768 /* PaymentSheet+HelperTest.swift */; };
61B4BC3426D53EB10099D768 /* PaymentSheet+PaymentMethodAvailabilityTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61B4BC3226D53E790099D768 /* PaymentSheet+PaymentMethodAvailabilityTest.swift */; };
61D30DB926D5B5F2002872DE /* TestModeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61D30DB826D5B5F2002872DE /* TestModeView.swift */; };
61EA8CEE26DD84DF00B2879D /* Error+PaymentSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61EA8CED26DD84DF00B2879D /* Error+PaymentSheet.swift */; };
@ -608,7 +610,6 @@
B6D13947230C68FF007AFF8A /* STPConnectAccountAddressTest.m in Sources */ = {isa = PBXBuildFile; fileRef = B6D13946230C68FF007AFF8A /* STPConnectAccountAddressTest.m */; };
B6D6C933223076600092AFC8 /* STPPaymentMethodAddressTest.m in Sources */ = {isa = PBXBuildFile; fileRef = B6D6C932223076600092AFC8 /* STPPaymentMethodAddressTest.m */; };
B6D6C935223078840092AFC8 /* STPPaymentMethodBillingDetailsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = B6D6C934223078840092AFC8 /* STPPaymentMethodBillingDetailsTest.m */; };
B6D98967251AFA9B00C3D894 /* STPAPIClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABD8625117C9800CC59EF /* STPAPIClient.swift */; };
B6D98973251C07FA00C3D894 /* APIRequestTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6D98972251C07FA00C3D894 /* APIRequestTest.swift */; };
B6D9CEAB2514809B00AAD424 /* STPPaymentMethodCardNetworks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABDB125117C9B00CC59EF /* STPPaymentMethodCardNetworks.swift */; };
B6D9CEB0251483AD00AAD424 /* STPPaymentMethodCardWallet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABDB625117C9B00CC59EF /* STPPaymentMethodCardWallet.swift */; };
@ -618,7 +619,6 @@
B6D9CED2251570D200AAD424 /* APIRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABD3B25117C9300CC59EF /* APIRequest.swift */; };
B6D9CEDB251AA99100AAD424 /* STPPinManagementService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABD8825117C9800CC59EF /* STPPinManagementService.swift */; };
B6D9CEE5251AAFBA00AAD424 /* STPAPIClient+PushProvisioning.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317ABDDE25117C9D00CC59EF /* STPAPIClient+PushProvisioning.swift */; };
B6D9CF03251AD14E00AAD424 /* StripeAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6D9CF02251AD14E00AAD424 /* StripeAPI.swift */; };
B6DF4C972411BE4D005C1AE0 /* STPApplePayContextFunctionalTest.m in Sources */ = {isa = PBXBuildFile; fileRef = B6DF4C962411BE4D005C1AE0 /* STPApplePayContextFunctionalTest.m */; };
B6E40EA0254253E400A5BABD /* PanModalPresentable+Defaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6E40E8E254253E400A5BABD /* PanModalPresentable+Defaults.swift */; };
B6E40EA1254253E400A5BABD /* PanModalPresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6E40E8F254253E400A5BABD /* PanModalPresentable.swift */; };
@ -776,6 +776,7 @@
0FC7C94F25B0EAF900E99D3E /* STPPaymentMethodAfterpayClearpayParamsTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STPPaymentMethodAfterpayClearpayParamsTest.m; sourceTree = "<group>"; };
0FC7C95225B1075D00E99D3E /* STPPaymentMethodAfterpayClearpayTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STPPaymentMethodAfterpayClearpayTest.m; sourceTree = "<group>"; };
11C74B9B164043050071C2CA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
310AF467271A5151007339F4 /* StripeAPI+Deprecated.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "StripeAPI+Deprecated.swift"; sourceTree = "<group>"; };
310FCA922582F1C6005FB2AE /* Stripe3DS2.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Stripe3DS2.framework; sourceTree = BUILT_PRODUCTS_DIR; };
3111C35625279C3B00207E32 /* STPSwiftFixtures.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = STPSwiftFixtures.swift; sourceTree = "<group>"; };
3111C38A252BC78B00207E32 /* STPThreeDSUICustomizationTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPThreeDSUICustomizationTest.swift; sourceTree = "<group>"; };
@ -889,6 +890,7 @@
315E4B352639D80F00C1D955 /* STPIntentActionWeChatPayRedirectToAppTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = STPIntentActionWeChatPayRedirectToAppTest.swift; sourceTree = "<group>"; };
31686173260ED62A00BF1C69 /* URLSession+Retry.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "URLSession+Retry.swift"; sourceTree = "<group>"; };
316E9F7526FA9AD400986485 /* STPAPISettingsBridgeTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STPAPISettingsBridgeTest.m; sourceTree = "<group>"; };
316E9F7826FA9FDF00986485 /* _stpobjc_STPAppInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = _stpobjc_STPAppInfo.swift; sourceTree = "<group>"; };
316F810F254109FC000A80B5 /* STPIntentActionOXXODisplayDetails.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = STPIntentActionOXXODisplayDetails.swift; sourceTree = "<group>"; };
316F811525410B0E000A80B5 /* STPPaymentMethodOXXO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = STPPaymentMethodOXXO.swift; sourceTree = "<group>"; };
316F811925410B12000A80B5 /* STPPaymentMethodOXXOParams.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = STPPaymentMethodOXXOParams.swift; sourceTree = "<group>"; };
@ -918,7 +920,7 @@
317ABD3B25117C9300CC59EF /* APIRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = APIRequest.swift; sourceTree = "<group>"; };
317ABD3E25117C9400CC59EF /* STPShippingMethodsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPShippingMethodsViewController.swift; sourceTree = "<group>"; };
317ABD4125117C9400CC59EF /* STPPaymentMethodAddress.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPPaymentMethodAddress.swift; sourceTree = "<group>"; };
317ABD4225117C9400CC59EF /* NSURLComponents+Stripe.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSURLComponents+Stripe.swift"; sourceTree = "<group>"; };
317ABD4225117C9400CC59EF /* NSURLComponents+Stripe.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "NSURLComponents+Stripe.swift"; path = "../StripeCore/StripeCore/Source/Categories/NSURLComponents+Stripe.swift"; sourceTree = "<group>"; };
317ABD4325117C9400CC59EF /* STPPaymentMethodGiropay.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPPaymentMethodGiropay.swift; sourceTree = "<group>"; };
317ABD4425117C9400CC59EF /* STPCustomer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPCustomer.swift; sourceTree = "<group>"; };
317ABD4525117C9400CC59EF /* STPPaymentHandlerActionParams.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPPaymentHandlerActionParams.swift; sourceTree = "<group>"; };
@ -936,7 +938,6 @@
317ABD5525117C9500CC59EF /* PKPaymentAuthorizationViewController+Stripe_Blocks.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "PKPaymentAuthorizationViewController+Stripe_Blocks.swift"; sourceTree = "<group>"; };
317ABD5625117C9500CC59EF /* STPSetupIntentEnums.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPSetupIntentEnums.swift; sourceTree = "<group>"; };
317ABD5825117C9500CC59EF /* STPThreeDSButtonCustomization.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPThreeDSButtonCustomization.swift; sourceTree = "<group>"; };
317ABD5925117C9500CC59EF /* STPURLCallbackHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPURLCallbackHandler.swift; sourceTree = "<group>"; };
317ABD5A25117C9500CC59EF /* STPPaymentMethodFPX.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPPaymentMethodFPX.swift; sourceTree = "<group>"; };
317ABD5B25117C9500CC59EF /* STPSourceParams.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPSourceParams.swift; sourceTree = "<group>"; };
317ABD5C25117C9600CC59EF /* STPSourcePoller.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPSourcePoller.swift; sourceTree = "<group>"; };
@ -975,7 +976,7 @@
317ABD8325117C9800CC59EF /* STPPushProvisioningDetails.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPPushProvisioningDetails.swift; sourceTree = "<group>"; };
317ABD8425117C9800CC59EF /* STPPhoneNumberValidator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPPhoneNumberValidator.swift; sourceTree = "<group>"; };
317ABD8525117C9800CC59EF /* STPPromise.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPPromise.swift; sourceTree = "<group>"; };
317ABD8625117C9800CC59EF /* STPAPIClient.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPAPIClient.swift; sourceTree = "<group>"; };
317ABD8625117C9800CC59EF /* STPAPIClient+Payments.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "STPAPIClient+Payments.swift"; sourceTree = "<group>"; };
317ABD8725117C9800CC59EF /* STPAddress.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPAddress.swift; sourceTree = "<group>"; };
317ABD8825117C9800CC59EF /* STPPinManagementService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPPinManagementService.swift; sourceTree = "<group>"; };
317ABD8A25117C9800CC59EF /* STPPaymentConfiguration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPPaymentConfiguration.swift; sourceTree = "<group>"; };
@ -998,7 +999,6 @@
317ABDA025117C9900CC59EF /* STPPaymentMethodGrabPay.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPPaymentMethodGrabPay.swift; sourceTree = "<group>"; };
317ABDA225117C9A00CC59EF /* STPPaymentMethodEnums.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPPaymentMethodEnums.swift; sourceTree = "<group>"; };
317ABDA325117C9A00CC59EF /* STPPaymentMethodEPSParams.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPPaymentMethodEPSParams.swift; sourceTree = "<group>"; };
317ABDA525117C9A00CC59EF /* NSError+Stripe.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSError+Stripe.swift"; sourceTree = "<group>"; };
317ABDA625117C9A00CC59EF /* STPPaymentMethodBacsDebitParams.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPPaymentMethodBacsDebitParams.swift; sourceTree = "<group>"; };
317ABDA725117C9A00CC59EF /* STPPaymentOption.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPPaymentOption.swift; sourceTree = "<group>"; };
317ABDA825117C9A00CC59EF /* STPPostalCodeValidator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPPostalCodeValidator.swift; sourceTree = "<group>"; };
@ -1073,13 +1073,12 @@
317ABDF925117C9F00CC59EF /* STPEphemeralKey.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPEphemeralKey.swift; sourceTree = "<group>"; };
317ABDFA25117C9F00CC59EF /* STPAuthenticationContext.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPAuthenticationContext.swift; sourceTree = "<group>"; };
317ABDFB25117C9F00CC59EF /* STPFPXBankStatusResponse.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPFPXBankStatusResponse.swift; sourceTree = "<group>"; };
317ABDFD25117C9F00CC59EF /* STPError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPError.swift; sourceTree = "<group>"; };
317ABDFD25117C9F00CC59EF /* _stpobjc_STPError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = _stpobjc_STPError.swift; sourceTree = "<group>"; };
317ABDFE25117C9F00CC59EF /* STPAddressFieldTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPAddressFieldTableViewCell.swift; sourceTree = "<group>"; };
317ABDFF25117C9F00CC59EF /* STPFormTextField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPFormTextField.swift; sourceTree = "<group>"; };
317ABE0025117C9F00CC59EF /* STPPaymentIntentEnums.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPPaymentIntentEnums.swift; sourceTree = "<group>"; };
317ABE0125117C9F00CC59EF /* STPPaymentIntentParams.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPPaymentIntentParams.swift; sourceTree = "<group>"; };
317ABE0225117C9F00CC59EF /* UIBarButtonItem+Stripe.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIBarButtonItem+Stripe.swift"; sourceTree = "<group>"; };
317ABE0325117C9F00CC59EF /* STPAppInfo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPAppInfo.swift; sourceTree = "<group>"; };
317ABE0425117C9F00CC59EF /* STPPaymentIntentSourceActionAuthorizeWithURL.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPPaymentIntentSourceActionAuthorizeWithURL.swift; sourceTree = "<group>"; };
317ABE0625117C9F00CC59EF /* STPPushProvisioningContext.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPPushProvisioningContext.swift; sourceTree = "<group>"; };
317ABE0725117CA000CC59EF /* STPPaymentIntentSourceAction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPPaymentIntentSourceAction.swift; sourceTree = "<group>"; };
@ -1176,9 +1175,12 @@
31875B5B25DC63C800884BE0 /* STPE2ETest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = STPE2ETest.swift; sourceTree = "<group>"; };
3194CF5B2314869400E1940F /* STPPaymentMethodFPXTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = STPPaymentMethodFPXTest.m; sourceTree = "<group>"; };
3194CF5D231487A100E1940F /* STPFPXBankBrandTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = STPFPXBankBrandTest.m; sourceTree = "<group>"; };
31B49E9A26E8269C00A0464A /* _stpobjc_STPAPIClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = _stpobjc_STPAPIClient.swift; sourceTree = "<group>"; };
31B49EA726E9743C00A0464A /* StripeCore+Import.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "StripeCore+Import.swift"; sourceTree = "<group>"; };
31C26219255F887A000C5B50 /* Stripe-umbrella.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Stripe-umbrella.h"; sourceTree = SOURCE_ROOT; };
31C8644824DDF2550015F7DF /* STPPaymentMethodSofortParamsTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STPPaymentMethodSofortParamsTests.m; sourceTree = "<group>"; };
31E242FA26F9028400064908 /* STPCustomerContextTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = STPCustomerContextTest.swift; sourceTree = "<group>"; };
31E242FC26FA3EBC00064908 /* _stpobjc_StripeAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = _stpobjc_StripeAPI.swift; sourceTree = "<group>"; };
31E242FE26FA424900064908 /* STPApplePayTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = STPApplePayTest.swift; sourceTree = "<group>"; };
31EFEE0D258AE3F40069BC5F /* Stripe3DS2.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Stripe3DS2.framework; sourceTree = BUILT_PRODUCTS_DIR; };
36002B772584251700E46F8B /* CheckboxButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxButton.swift; sourceTree = "<group>"; };
@ -1271,10 +1273,7 @@
448895AE245255D800F7D0C2 /* STPPaymentMethodPrzelewy24ParamsTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STPPaymentMethodPrzelewy24ParamsTests.m; sourceTree = "<group>"; };
44BDCFDE245A46CC007EE6D5 /* STPPaymentMethodBancontactParamsTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STPPaymentMethodBancontactParamsTests.m; sourceTree = "<group>"; };
4A0D74F918F6106100966D7B /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
618E787826EFDA2A0034A01F /* ServerErrorMapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerErrorMapper.swift; sourceTree = "<group>"; };
618E787A26EFDD310034A01F /* ServerErrorMapperTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerErrorMapperTest.swift; sourceTree = "<group>"; };
61B4BC3026D53E5F0099D768 /* PaymentRequirementProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PaymentRequirementProvider.swift; sourceTree = "<group>"; };
61B4BC3226D53E790099D768 /* PaymentSheet+HelperTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "PaymentSheet+HelperTest.swift"; sourceTree = "<group>"; };
61B4BC3226D53E790099D768 /* PaymentSheet+PaymentMethodAvailabilityTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "PaymentSheet+PaymentMethodAvailabilityTest.swift"; sourceTree = "<group>"; };
61D30DB826D5B5F2002872DE /* TestModeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestModeView.swift; sourceTree = "<group>"; };
61EA8CED26DD84DF00B2879D /* Error+PaymentSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Error+PaymentSheet.swift"; sourceTree = "<group>"; };
@ -1383,7 +1382,6 @@
B6D6C934223078840092AFC8 /* STPPaymentMethodBillingDetailsTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STPPaymentMethodBillingDetailsTest.m; sourceTree = "<group>"; };
B6D98971251C07FA00C3D894 /* StripeiOS Tests-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "StripeiOS Tests-Bridging-Header.h"; sourceTree = "<group>"; };
B6D98972251C07FA00C3D894 /* APIRequestTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APIRequestTest.swift; sourceTree = "<group>"; };
B6D9CF02251AD14E00AAD424 /* StripeAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = StripeAPI.swift; path = Stripe/StripeAPI.swift; sourceTree = SOURCE_ROOT; };
B6DF4C962411BE4D005C1AE0 /* STPApplePayContextFunctionalTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STPApplePayContextFunctionalTest.m; sourceTree = "<group>"; };
B6E40E8E254253E400A5BABD /* PanModalPresentable+Defaults.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "PanModalPresentable+Defaults.swift"; sourceTree = "<group>"; };
B6E40E8F254253E400A5BABD /* PanModalPresentable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PanModalPresentable.swift; sourceTree = "<group>"; };
@ -1775,8 +1773,9 @@
3144E124253E7D2200FE2605 /* API Bindings */ = {
isa = PBXGroup;
children = (
31B49E9C26E826A700A0464A /* Legacy Compatibility */,
3144E125253E7D3F00FE2605 /* Models */,
317ABD8625117C9800CC59EF /* STPAPIClient.swift */,
317ABD8625117C9800CC59EF /* STPAPIClient+Payments.swift */,
317ABDCF25117C9C00CC59EF /* STPAPIClient+ApplePay.swift */,
B61545FF2656A449006029D1 /* STPAPIClient+Radar.swift */,
317ABDB325117C9B00CC59EF /* STPEphemeralKeyProvider.swift */,
@ -1784,7 +1783,6 @@
317ABE0625117C9F00CC59EF /* STPPushProvisioningContext.swift */,
317ABD6325117C9600CC59EF /* STPPushProvisioningDetailsParams.swift */,
317ABDBD25117C9B00CC59EF /* STPRedirectContext.swift */,
B6D9CF02251AD14E00AAD424 /* StripeAPI.swift */,
);
name = "API Bindings";
sourceTree = "<group>";
@ -1799,7 +1797,6 @@
3144E12A253E7D6B00FE2605 /* Sources */,
317ABD8725117C9800CC59EF /* STPAddress.swift */,
317ABDDF25117C9D00CC59EF /* STPAPIResponseDecodable.swift */,
317ABE0325117C9F00CC59EF /* STPAppInfo.swift */,
317ABDB225117C9B00CC59EF /* STPCardBrand.swift */,
317ABDF125117C9E00CC59EF /* STPConnectAccountAddress.swift */,
317ABD4625117C9400CC59EF /* STPConnectAccountCompanyParams.swift */,
@ -1938,7 +1935,6 @@
317ABD9B25117C9900CC59EF /* NSArray+Stripe.swift */,
317ABD7225117C9700CC59EF /* NSDecimalNumber+Stripe_Currency.swift */,
317ABDC625117C9C00CC59EF /* NSDictionary+Stripe.swift */,
317ABDA525117C9A00CC59EF /* NSError+Stripe.swift */,
317ABD9D25117C9900CC59EF /* NSString+Stripe.swift */,
317ABD4225117C9400CC59EF /* NSURLComponents+Stripe.swift */,
317ABDB925117C9B00CC59EF /* PKAddPaymentPassRequest+Stripe_Error.swift */,
@ -1975,7 +1971,6 @@
317ABDA825117C9A00CC59EF /* STPPostalCodeValidator.swift */,
317ABD8525117C9800CC59EF /* STPPromise.swift */,
317ABE1925117CA100CC59EF /* STPStringUtils.swift */,
317ABD5925117C9500CC59EF /* STPURLCallbackHandler.swift */,
E6598C8426952F7000278740 /* StripeBundleLocator.swift */,
E6598C862695342000278740 /* String+Localized.swift */,
);
@ -2135,7 +2130,6 @@
317ABDCA25117C9C00CC59EF /* STPBlocks.swift */,
317ABD2825117C9200CC59EF /* STPCardScanner.swift */,
317ABDCC25117C9C00CC59EF /* STPCardValidator.swift */,
317ABDFD25117C9F00CC59EF /* STPError.swift */,
317ABDD725117C9D00CC59EF /* STPImageLibrary.swift */,
318321E025C864CB00D96469 /* STPPaymentConfirmation+SwiftUI.swift */,
31686173260ED62A00BF1C69 /* URLSession+Retry.swift */,
@ -2286,6 +2280,19 @@
path = FPX;
sourceTree = "<group>";
};
31B49E9C26E826A700A0464A /* Legacy Compatibility */ = {
isa = PBXGroup;
children = (
31B49E9A26E8269C00A0464A /* _stpobjc_STPAPIClient.swift */,
317ABDFD25117C9F00CC59EF /* _stpobjc_STPError.swift */,
316E9F7826FA9FDF00986485 /* _stpobjc_STPAppInfo.swift */,
31B49EA726E9743C00A0464A /* StripeCore+Import.swift */,
310AF467271A5151007339F4 /* StripeAPI+Deprecated.swift */,
31E242FC26FA3EBC00064908 /* _stpobjc_StripeAPI.swift */,
);
name = "Legacy Compatibility";
sourceTree = "<group>";
};
3666589723FF48F100D00354 /* Backend */ = {
isa = PBXGroup;
children = (
@ -2415,8 +2422,6 @@
isa = PBXGroup;
children = (
61EA8CED26DD84DF00B2879D /* Error+PaymentSheet.swift */,
618E787826EFDA2A0034A01F /* ServerErrorMapper.swift */,
B6E40EB92542541100A5BABD /* Events.swift */,
B6BB89CF266EF7F8005E044F /* Intent.swift */,
B6689185265324C600A5488F /* New Payment Method Screen */,
B6E40E8C254253E400A5BABD /* PanModal */,
@ -2611,9 +2616,7 @@
F3064296268C42BE0076CDDA /* PaymentSheet+APITest.swift */,
61B4BC3226D53E790099D768 /* PaymentSheet+PaymentMethodAvailabilityTest.swift */,
3111C3E5252BC79A00207E32 /* PKPayment+StripeTest.swift */,
B649351326A73DDB00B8EC66 /* SectionElement+AddressTest.swift */,
618E787A26EFDD310034A01F /* ServerErrorMapperTest.swift */,
B633B4AE2678405D0072CA65 /* SectionElementTest.swift */,
3111C3F5252BC79D00207E32 /* STPAddCardViewControllerTest.swift */,
C1080F4B1CBED48A007B2D89 /* STPAddressTests.m */,
3111C3BA252BC79300207E32 /* STPAddressViewModelTest.swift */,
@ -3325,6 +3328,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
319E3659271A03B300460867 /* STPAPIClient+Payments.swift in Sources */,
317ABF3425118C1E00CC59EF /* STPCardScanner.swift in Sources */,
3176C233251A6B0600300ADE /* STPThreeDSLabelCustomization.swift in Sources */,
B67BBBBA26F1763C002645A9 /* PaymentMethodElement.swift in Sources */,
@ -3341,6 +3345,7 @@
B67243912526378C002E1AAF /* STPSetupIntentConfirmParams.swift in Sources */,
3176C242251A6B5E00300ADE /* STPThreeDSUICustomization.swift in Sources */,
B672436425251A5C002E1AAF /* STPSourceWeChatPayDetails.swift in Sources */,
31E242FD26FA3EBC00064908 /* _stpobjc_StripeAPI.swift in Sources */,
31281BF5252586F800591A95 /* STPBankAccountParams.swift in Sources */,
36DFC23B251D5852003AC264 /* STPMandateOnlineParams.swift in Sources */,
3176C25F251A8FDA00300ADE /* STPPushProvisioningDetails.swift in Sources */,
@ -3354,6 +3359,7 @@
31D4D6882512EBAC00809066 /* UIToolbar+Stripe_InputAccessory.swift in Sources */,
366ECD36254B4AFA0082868E /* STPCardNumberInputTextFieldValidator.swift in Sources */,
61D30DB926D5B5F2002872DE /* TestModeView.swift in Sources */,
31F9015E26FEA07000F9E11D /* STPEphemeralKeyManager.swift in Sources */,
B684476725538740005C4089 /* ChoosePaymentOptionViewController.swift in Sources */,
31D4D6662512BCDC00809066 /* STPCardLoadingIndicator.swift in Sources */,
3111C33D2526C2A300207E32 /* STPPromise.swift in Sources */,
@ -3407,10 +3413,13 @@
36AC3D2C252521D700F252D7 /* STPPaymentIntentParams.swift in Sources */,
B67243212524E514002E1AAF /* STPPaymentMethodSEPADebit.swift in Sources */,
317ABF462511983100CC59EF /* STPColorUtils.swift in Sources */,
31B49EA826E9743D00A0464A /* StripeCore+Import.swift in Sources */,
B6E6C0E92655705100445507 /* Images.swift in Sources */,
36DFC20525156A57003AC264 /* STPIntentActionUseStripeSDK.swift in Sources */,
317ABF53251292B400CC59EF /* STPAppInfo.swift in Sources */,
317ABF53251292B400CC59EF /* (null) in Sources */,
31B49E9B26E8269C00A0464A /* _stpobjc_STPAPIClient.swift in Sources */,
3194909B25144D7800AD8F0B /* STPPaymentContext.swift in Sources */,
316E9F7926FA9FDF00986485 /* _stpobjc_STPAppInfo.swift in Sources */,
366ECD3B254B4AFA0082868E /* STPCardExpiryInputTextField.swift in Sources */,
3194907B25140D1500AD8F0B /* STPShippingMethodsViewController.swift in Sources */,
366ECD2F254B4AFA0082868E /* STPNumericDigitInputTextFormatter.swift in Sources */,
@ -3466,7 +3475,7 @@
367F1E7325140B9B002E866B /* STPTheme.swift in Sources */,
36F61208254C8890006656BD /* PaymentSheetViewController.swift in Sources */,
36F61207254C8890006656BD /* AddPaymentMethodViewController.swift in Sources */,
3137A74D26FD7AF5008BEF7B /* STPURLCallbackHandler.swift in Sources */,
3137A74D26FD7AF5008BEF7B /* (null) in Sources */,
3111C3762527EB6800207E32 /* STPAuthenticationContext.swift in Sources */,
B672433A2524F062002E1AAF /* STPPaymentMethodiDEAL.swift in Sources */,
B6D9CEDB251AA99100AAD424 /* STPPinManagementService.swift in Sources */,
@ -3474,9 +3483,10 @@
3194907425140C9700AD8F0B /* STPPaymentOptionsViewController.swift in Sources */,
B6E40EBC2542541100A5BABD /* PaymentSheet.swift in Sources */,
366ECD38254B4AFA0082868E /* STPCardExpiryInputTextFieldFormatter.swift in Sources */,
3111C30225268ED800207E32 /* STPError.swift in Sources */,
3111C30225268ED800207E32 /* _stpobjc_STPError.swift in Sources */,
316F8110254109FC000A80B5 /* STPIntentActionOXXODisplayDetails.swift in Sources */,
B6E40EA1254253E400A5BABD /* PanModalPresentable.swift in Sources */,
310AF468271A5151007339F4 /* StripeAPI+Deprecated.swift in Sources */,
D060826126E9125E0002D656 /* STPPaymentMethodBoleto.swift in Sources */,
31319EE125B11C8A00C89E30 /* PaymentSheet+SwiftUI.swift in Sources */,
B6E40EAA254253E400A5BABD /* PanModalPresentationController.swift in Sources */,
@ -3523,7 +3533,6 @@
368E1F5B254CB29D00150A2D /* STPPostalCodeInputTextField.swift in Sources */,
B68A9E3A257EE77100E904B5 /* PaymentSheetError.swift in Sources */,
31D4D67A2512E7B200809066 /* UINavigationBar+Stripe_Theme.swift in Sources */,
3111C3422526C71A00207E32 /* STPEphemeralKeyManager.swift in Sources */,
3111BE8925130A3600288D28 /* STPAUBECSDebitFormView.swift in Sources */,
31D4D65F2512B1EC00809066 /* STPBSBNumberValidator.swift in Sources */,
3176C270251A9A6100300ADE /* STPFormTextField.swift in Sources */,
@ -3548,7 +3557,6 @@
317ABF3225117D0F00CC59EF /* STPPaymentMethodCardPresent.swift in Sources */,
3171E93225783D1100F03DD1 /* CardScanningView.swift in Sources */,
B6E40EA4254253E400A5BABD /* PanModalPresentable+UIViewController.swift in Sources */,
B6D98967251AFA9B00C3D894 /* STPAPIClient.swift in Sources */,
B672435A2525188B002E1AAF /* STPSourceReceiver.swift in Sources */,
B672431F2524E504002E1AAF /* STPPaymentMethodPrzelewy24Params.swift in Sources */,
367220B525DDCBDC00708160 /* CircularButton.swift in Sources */,
@ -3561,7 +3569,6 @@
36F61205254C888F006656BD /* SavedPaymentOptionsViewController.swift in Sources */,
B672438B252614F0002E1AAF /* STPSetupIntentLastSetupError.swift in Sources */,
31949091251449C600AD8F0B /* STPPostalCodeValidator.swift in Sources */,
B6D9CF03251AD14E00AAD424 /* StripeAPI.swift in Sources */,
B67243172524E3E5002E1AAF /* STPPaymentMethodPrzelewy24.swift in Sources */,
B67BC546257B024200B7349B /* PaymentMethodTypeCollectionView.swift in Sources */,
36ADAE182523A5B100302DFB /* STPPaymentIntentLastPaymentError.swift in Sources */,
@ -3570,7 +3577,6 @@
368E1F57254CB28900150A2D /* STPPostalCodeInputTextFieldValidator.swift in Sources */,
B67242CD25238D8B002E1AAF /* STPMultipartFormDataEncoder.swift in Sources */,
315E4B302639C86B00C1D955 /* STPIntentActionWeChatPayRedirectToApp.swift in Sources */,
3111C3082526956500207E32 /* NSError+Stripe.swift in Sources */,
36AC3D3025252B3500F252D7 /* STPPaymentIntentEnums.swift in Sources */,
B684476B25538874005C4089 /* PaymentSheetFlowController.swift in Sources */,
B67243032524172E002E1AAF /* STPPaymentMethodGiropay.swift in Sources */,
@ -3603,7 +3609,6 @@
B65E749B258829550080D9B3 /* STPAnalyticsClient+PaymentSheet.swift in Sources */,
366ECD35254B4AFA0082868E /* STPInputTextFieldValidator.swift in Sources */,
B633B4B9267981AC0072CA65 /* SepaMandateView.swift in Sources */,
618E787926EFDA2A0034A01F /* ServerErrorMapper.swift in Sources */,
31D4D66D2512BDC000809066 /* STPCardValidator.swift in Sources */,
36DFC226251BECB3003AC264 /* STPConnectAccountCompanyParams.swift in Sources */,
B6D9CEB625151E6200AAD424 /* STPPaymentMethodCardWalletMasterpass.swift in Sources */,
@ -3731,7 +3736,14 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 04F39F101AEF2AFE005B926E /* StripeiOS-Debug.xcconfig */;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
DEFINES_MODULE = YES;
INFOPLIST_FILE = Stripe/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MODULEMAP_FILE = Stripe/Stripe.modulemap;
PRODUCT_BUNDLE_IDENTIFIER = "com.stripe.stripe-ios";
PRODUCT_NAME = Stripe;
@ -3744,7 +3756,14 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 04F39F111AEF2AFE005B926E /* StripeiOS-Release.xcconfig */;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
DEFINES_MODULE = YES;
INFOPLIST_FILE = Stripe/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MODULEMAP_FILE = Stripe/Stripe.modulemap;
PRODUCT_BUNDLE_IDENTIFIER = "com.stripe.stripe-ios";
PRODUCT_NAME = Stripe;

View File

@ -149,26 +149,26 @@ class APIRequest<ResponseType: STPAPIResponseDecodable>: NSObject {
}
}
// HACK:
// STPEmptyStripeResponse will always parse successfully and never return an error, as we're
// don't inspect the HTTP error code or the error dictionary.
// I'm afraid this will cause issues if anyone is depending on the old behavior, so let's treat
// STPEmptyStripeResponse as special.
// We probably always want errors to override object deserialization: re-evaluate
// this hack when building the new API client.
if ResponseType.self == STPEmptyStripeResponse.self {
if let error: Error =
NSError.stp_error(fromStripeResponse: jsonDictionary, httpResponse: httpResponse)
{
safeCompletion(nil, error)
} else if let responseObject = ResponseType.decodedObject(fromAPIResponse: jsonDictionary) {
safeCompletion(responseObject, nil)
} else {
safeCompletion(nil, NSError.stp_genericFailedToParseResponseError())
}
return
}
// END OF STPEmptyStripeResponse HACK
// HACK:
// STPEmptyStripeResponse will always parse successfully and never return an error, as we're
// not looking at the HTTP error code or the error dictionary.
// I'm afraid this will cause issues if anyone is depending on the old behavior, so let's treat
// STPEmptyStripeResponse as special.
// We probably always want errors to override object deserialization: re-evaluate
// this hack when building the new API client.
if ResponseType.self == STPEmptyStripeResponse.self {
if let error: Error =
NSError.stp_error(fromStripeResponse: jsonDictionary, httpResponse: httpResponse)
{
safeCompletion(nil, error)
} else if let responseObject = ResponseType.decodedObject(fromAPIResponse: jsonDictionary) {
safeCompletion(responseObject, nil)
} else {
safeCompletion(nil, NSError.stp_genericFailedToParseResponseError())
}
return
}
// END OF STPEmptyStripeResponse HACK
if let responseObject = ResponseType.decodedObject(fromAPIResponse: jsonDictionary) {
safeCompletion(responseObject, nil)

View File

@ -8,6 +8,7 @@
import ObjectiveC
import PassKit
@_spi(STP) import StripeCore
typealias STPApplePayPaymentMethodHandlerBlock = (STPPaymentMethod, @escaping STPPaymentStatusBlock)
-> Void

View File

@ -8,6 +8,7 @@
import Foundation
import UIKit
@_spi(STP) import StripeCore
@_spi(STP) import StripeUICore
@available(iOSApplicationExtension, unavailable)

View File

@ -7,6 +7,7 @@
//
import Foundation
@_spi(STP) import StripeCore
extension PaymentSheet {

View File

@ -297,12 +297,6 @@
/* An error message. */
"The IBAN you entered is invalid, \"%@\" is not a supported country code." = "The IBAN you entered is invalid, \"%@\" is not a supported country code.";
/* An error message displayed when the customer's iban is invalid. */
"The IBAN you entered is invalid." = "The IBAN you entered is invalid.";
/* Error when there is a problem processing the credit card */
"There was an error processing your card -- try again in a few seconds" = "There was an error processing your card -- try again in a few seconds";
/* Error when 3DS2 authentication timed out. */
"Timed out authenticating your payment method -- try again" = "Timed out authenticating your payment method -- try again";
@ -331,54 +325,33 @@
Source type brand name */
"WeChat Pay" = "WeChat Pay";
/* Error when the card has already expired */
"Your card has expired" = "Your card has expired";
/* Error message for card form when card number is incomplete */
"Your card number is incomplete." = "Your card number is incomplete.";
/* Error message for card form when card number is invalid */
"Your card number is invalid." = "Your card number is invalid.";
/* Error when the card was declined by the credit card networks */
"Your card was declined" = "Your card was declined";
/* Error message for card details form when expiration date isn't entered completely */
"Your card's expiration date is incomplete." = "Your card's expiration date is incomplete.";
/* Error message for card details form when expiration date is invalid */
"Your card's expiration date is invalid." = "Your card's expiration date is invalid.";
/* Error when the card's expiration month is not valid */
"Your card's expiration month is invalid" = "Your card's expiration month is invalid";
/* String to describe an invalid month in expiry date. */
"Your card's expiration month is invalid." = "Your card's expiration month is invalid.";
/* Error when the card's expiration year is not valid */
"Your card's expiration year is invalid" = "Your card's expiration year is invalid";
/* String to describe an invalid year in expiry date. */
"Your card's expiration year is invalid." = "Your card's expiration year is invalid.";
/* Error when the card number is not valid */
"Your card's number is invalid" = "Your card's number is invalid";
/* Error message for card entry form when CVC/CVV is incomplete. */
"Your card's security code is incomplete." = "Your card's security code is incomplete.";
/* Error when the card's CVC is not valid */
"Your card's security code is invalid" = "Your card's security code is invalid";
/* Error message for card entry form when CVC/CVV is invalid */
"Your card's security code is invalid." = "Your card's security code is invalid.";
/* An error message. */
"Your IBAN should start with a two-letter country code." = "Your IBAN should start with a two-letter country code.";
/* Error when customer's name is invalid */
"Your name is invalid." = "Your name is invalid.";
/* Error message for when postal code in form is incomplete */
"Your postal code is incomplete." = "Your postal code is incomplete.";

View File

@ -7,6 +7,7 @@
import Foundation
import PassKit
@_spi(STP) import StripeCore
/// STPAPIClient extensions to create Stripe Tokens, Sources, or PaymentMethods from Apple Pay PKPayment objects.
extension STPAPIClient {
@ -14,7 +15,6 @@ extension STPAPIClient {
/// - Parameters:
/// - payment: The user's encrypted payment information as returned from a PKPaymentAuthorizationController. Cannot be nil.
/// - completion: The callback to run with the returned Stripe token (and any errors that may have occurred).
@objc(createTokenWithPayment:completion:)
public func createToken(with payment: PKPayment, completion: @escaping STPTokenCompletionBlock)
{
var params = parameters(for: payment)
@ -29,7 +29,6 @@ extension STPAPIClient {
/// - Parameters:
/// - payment: The user's encrypted payment information as returned from a PKPaymentAuthorizationController. Cannot be nil.
/// - completion: The callback to run with the returned Stripe source (and any errors that may have occurred).
@objc(createSourceWithPayment:completion:)
public func createSource(
with payment: PKPayment, completion: @escaping STPSourceCompletionBlock
) {
@ -49,7 +48,6 @@ extension STPAPIClient {
/// - Parameters:
/// - payment: The user's encrypted payment information as returned from a PKPaymentAuthorizationController. Cannot be nil.
/// - completion: The callback to run with the returned Stripe source (and any errors that may have occurred).
@objc(createPaymentMethodWithPayment:completion:)
public func createPaymentMethod(
with payment: PKPayment, completion: @escaping STPPaymentMethodCompletionBlock
) {
@ -76,7 +74,6 @@ extension STPAPIClient {
/// Currently, we convert billing address related errors into a PKPaymentError that helpfully points to the billing address field in the Apple Pay sheet.
/// Note that Apple Pay should prevent most card errors (e.g. invalid CVC, expired cards) when you add a card to the wallet.
/// - Parameter stripeError: An error from the Stripe SDK.
@objc(pkPaymentErrorForStripeError:)
public class func pkPaymentError(forStripeError stripeError: Error?) -> Error? {
guard let stripeError = stripeError else {
return nil
@ -157,7 +154,6 @@ extension STPAPIClient {
return params
}
@objc(parametersForPayment:)
func parameters(for payment: PKPayment) -> [String: Any] {
let paymentString = String(data: payment.token.paymentData, encoding: .utf8)
var payload: [String: Any] = [:]

View File

@ -16,82 +16,20 @@ import UIKit
#endif
/// A client for making connections to the Stripe API.
public class STPAPIClient: NSObject {
/// The current version of this library.
@objc public static let STPSDKVersion = StripeAPIConfiguration.STPSDKVersion
/// A shared singleton API client.
/// By default, the SDK uses this instance to make API requests
/// eg in STPPaymentHandler, STPPaymentContext, STPCustomerContext, etc.
@objc(sharedClient)
public static let shared: STPAPIClient = {
let client = STPAPIClient()
STPAnalyticsClient.sharedClient.publishableKeyProvider = client
return client
}()
/// The client's publishable key.
/// The default value is `StripeAPI.defaultPublishableKey`.
@objc public var publishableKey: String? {
get {
if let publishableKey = _publishableKey {
return publishableKey
}
return StripeAPI.defaultPublishableKey
}
set {
_publishableKey = newValue
Self.validateKey(newValue)
}
}
var _publishableKey: String?
extension STPAPIClient {
/// The client's configuration.
/// Defaults to `STPPaymentConfiguration.shared`.
@objc public var configuration: STPPaymentConfiguration = .shared
/// In order to perform API requests on behalf of a connected account, e.g. to
/// create a Source or Payment Method on a connected account, set this property to the ID of the
/// account for which this request is being made.
/// - seealso: https://stripe.com/docs/connect/authentication#authentication-via-the-stripe-account-header
@objc public var stripeAccount: String?
/// Libraries wrapping the Stripe SDK should set this, so that Stripe can contact you about future issues or critical updates.
/// - seealso: https://stripe.com/docs/building-plugins#setappinfo
@objc public var appInfo: STPAppInfo?
/// The API version used to communicate with Stripe.
@objc public static let apiVersion = APIVersion
// MARK: Internal/private properties
var apiURL: URL! = URL(string: APIBaseURL)
var urlSession = URLSession(configuration: StripeAPIConfiguration.sharedUrlSessionConfiguration)
private var sourcePollers: [String: NSObject]?
private var sourcePollersQueue: DispatchQueue?
/// A set of beta headers to add to Stripe API requests e.g. `Set(["alipay_beta=v1"])`
var betas: Set<String> = []
/// Returns `true` if `publishableKey` is actually a user key, `false` otherwise.
private var publishableKeyIsUserKey: Bool {
return publishableKey?.hasPrefix("uk_") ?? false
}
// MARK: Initializers
override init() {
super.init()
configuration = STPPaymentConfiguration.shared
sourcePollers = [:]
sourcePollersQueue = DispatchQueue(label: "com.stripe.sourcepollers")
}
/// Initializes an API client with the given publishable key.
/// - Parameter publishableKey: The publishable key to use.
/// - Returns: An instance of STPAPIClient.
@objc
public convenience init(publishableKey: String) {
self.init()
self.publishableKey = publishableKey
public var configuration: STPPaymentConfiguration {
get {
if let config = _stored_configuration as? STPPaymentConfiguration {
return config
} else {
return .shared
}
}
set {
_stored_configuration = newValue
}
}
/// Initializes an API client with the given configuration.
@ -102,7 +40,6 @@ public class STPAPIClient: NSObject {
message:
"This initializer previously configured publishableKey and stripeAccount via the STPPaymentConfiguration instance. This behavior is deprecated; set the STPAPIClient configuration, publishableKey, and stripeAccount properties directly on the STPAPIClient instead."
)
@objc
public convenience init(configuration: STPPaymentConfiguration) {
// For legacy reasons, we'll support this initializer and use the deprecated configuration.{publishableKey, stripeAccount} properties
self.init()
@ -110,33 +47,15 @@ public class STPAPIClient: NSObject {
stripeAccount = configuration.stripeAccount
}
@objc(configuredRequestForURL:additionalHeaders:)
func configuredRequest(for url: URL, additionalHeaders: [String: String] = [:])
-> NSMutableURLRequest
{
let request = NSMutableURLRequest(url: url)
var headers = defaultHeaders()
for (k, v) in additionalHeaders { headers[k] = v } // additionalHeaders can overwrite defaultHeaders
headers.forEach { key, value in
request.setValue(value, forHTTPHeaderField: key)
}
return request
/// A helper method that returns the Authorization header to use for API requests. If ephemeralKey is nil, uses self.publishableKey instead.
func authorizationHeader(using ephemeralKey: STPEphemeralKey? = nil) -> [String: String] {
return authorizationHeader(using: ephemeralKey?.secret)
}
}
/// Headers common to all API requests for a given API Client.
@objc func defaultHeaders() -> [String: String] {
var defaultHeaders: [String: String] = [:]
defaultHeaders["X-Stripe-User-Agent"] = STPAPIClient.stripeUserAgentDetails(with: appInfo)
var stripeVersion = APIVersion
for beta in betas {
stripeVersion = stripeVersion + "; \(beta)"
}
defaultHeaders["Stripe-Version"] = stripeVersion
defaultHeaders["Stripe-Account"] = stripeAccount
for (k, v) in authorizationHeader() { defaultHeaders[k] = v }
return defaultHeaders
}
// MARK: Tokens
extension STPAPIClient {
func createToken(
withParameters parameters: [String: Any],
completion: @escaping STPTokenCompletionBlock
@ -154,118 +73,6 @@ public class STPAPIClient: NSObject {
completion(object, error)
}
}
// MARK: Helpers
static var didShowTestmodeKeyWarning = false
class func validateKey(_ publishableKey: String?) {
guard let publishableKey = publishableKey, !publishableKey.isEmpty else {
assertionFailure(
"You must use a valid publishable key. For more info, see https://stripe.com/docs/keys"
)
return
}
if publishableKey.isSecretKey {
fatalError("You are using a secret key. Use a publishable key instead. For more info, see https://stripe.com/docs/keys")
}
#if !DEBUG
if publishableKey.lowercased().hasPrefix("pk_test") && !didShowTestmodeKeyWarning {
print(
" You're using your Stripe testmode key. Make sure to use your livemode key when submitting to the App Store!"
)
didShowTestmodeKeyWarning = true
}
#endif
}
static var paymentUserAgent: String {
var paymentUserAgent = "stripe-ios/\(STPAPIClient.STPSDKVersion)"
let components = [paymentUserAgent] + STPAnalyticsClient.sharedClient.productUsage
paymentUserAgent = components.joined(separator: "; ")
return paymentUserAgent
}
class func paramsAddingPaymentUserAgent(_ params: [String: Any]) -> [String: Any] {
var newParams = params
newParams["payment_user_agent"] = Self.paymentUserAgent
return newParams
}
class func stripeUserAgentDetails(with appInfo: STPAppInfo?) -> String {
var details: [String: String] = [
"lang": "objective-c",
"bindings_version": STPSDKVersion,
]
let version = UIDevice.current.systemVersion
if version != "" {
details["os_version"] = version
}
var systemInfo = utsname()
uname(&systemInfo)
// Thanks to https://stackoverflow.com/questions/26028918/how-to-determine-the-current-iphone-device-model
let machineMirror = Mirror(reflecting: systemInfo.machine)
let deviceType = machineMirror.children.reduce("") { identifier, element in
guard let value = element.value as? Int8, value != 0 else { return identifier }
return identifier + String(UnicodeScalar(UInt8(value)))
}
details["type"] = deviceType
let model = UIDevice.current.localizedModel
if model != "" {
details["model"] = model
}
let vendorIdentifier = UIDevice.current.identifierForVendor?.uuidString
if let vendorIdentifier = vendorIdentifier {
details["vendor_identifier"] = vendorIdentifier
}
if let appInfo = appInfo {
details["name"] = appInfo.name
details["partner_id"] = appInfo.partnerId
if appInfo.version != nil {
details["version"] = appInfo.version
}
if appInfo.url != nil {
details["url"] = appInfo.url
}
}
let data = try? JSONSerialization.data(withJSONObject: details, options: [])
return String(data: data ?? Data(), encoding: .utf8) ?? ""
}
/// A helper method that returns the Authorization header to use for API requests. If ephemeralKey is nil, uses self.publishableKey instead.
@objc(authorizationHeaderUsingEphemeralKey:)
func authorizationHeader(using ephemeralKey: STPEphemeralKey? = nil) -> [String: String] {
authorizationHeader(using: ephemeralKey?.secret)
}
func authorizationHeader(using ephemeralKeySecret: String?) -> [String: String] {
var authorizationBearer = publishableKey ?? ""
if let ephemeralKeySecret = ephemeralKeySecret {
authorizationBearer = ephemeralKeySecret
}
var headers: [String: String] = [
"Authorization": "Bearer " + authorizationBearer
]
if publishableKeyIsUserKey {
if ProcessInfo.processInfo.environment["Stripe-Livemode"] == "false" {
headers["Stripe-Livemode"] = "false"
} else {
headers["Stripe-Livemode"] = "true"
}
}
return headers
}
var isTestmode: Bool {
guard let publishableKey = publishableKey, !publishableKey.isEmpty else {
return false
}
return publishableKey.lowercased().hasPrefix("pk_test")
}
}
// MARK: Bank Accounts
@ -276,7 +83,6 @@ extension STPAPIClient {
/// - Parameters:
/// - bankAccount: The user's bank account details. Cannot be nil. - seealso: https://stripe.com/docs/api#create_bank_account_token
/// - completion: The callback to run with the returned Stripe token (and any errors that may have occurred).
@objc
public func createToken(
withBankAccount bankAccount: STPBankAccountParams,
completion: @escaping STPTokenCompletionBlock
@ -296,7 +102,6 @@ extension STPAPIClient {
/// - Parameters:
/// - pii: The user's personal identification number. Cannot be nil. - seealso: https://stripe.com/docs/api#create_pii_token
/// - completion: The callback to run with the returned Stripe token (and any errors that may have occurred).
@objc
public func createToken(
withPersonalIDNumber pii: String, completion: STPTokenCompletionBlock?
) {
@ -316,7 +121,6 @@ extension STPAPIClient {
/// - Parameters:
/// - ssnLast4: The last 4 digits of the user's SSN. Cannot be nil.
/// - completion: The callback to run with the returned Stripe token (and any errors that may have occurred).
@objc
public func createToken(
withSSNLast4 ssnLast4: String, completion: @escaping STPTokenCompletionBlock
) {
@ -340,7 +144,6 @@ extension STPAPIClient {
/// - Parameters:
/// - account: The Connect Account parameters. Cannot be nil.
/// - completion: The callback to run with the returned Stripe token (and any errors that may have occurred).
@objc
public func createToken(
withConnectAccount account: STPConnectAccountParams, completion: STPTokenCompletionBlock?
) {
@ -388,7 +191,6 @@ extension STPAPIClient {
/// - completion: The callback to run with the returned Stripe file
/// (and any errors that may have occurred).
/// - seealso: https://stripe.com/docs/file-upload
@objc
public func uploadImage(
_ image: UIImage,
purpose: STPFilePurpose,
@ -466,7 +268,6 @@ extension STPAPIClient {
/// - Parameters:
/// - cardParams: The user's card details. Cannot be nil. - seealso: https://stripe.com/docs/api#create_card_token
/// - completion: The callback to run with the returned Stripe token (and any errors that may have occurred).
@objc
public func createToken(
withCard cardParams: STPCardParams, completion: @escaping STPTokenCompletionBlock
) {
@ -480,7 +281,6 @@ extension STPAPIClient {
/// - Parameters:
/// - cvc: The CVC/CVV number used to create the token. Cannot be nil.
/// - completion: The callback to run with the returned Stripe token (and any errors that may have occurred).
@objc
public func createToken(forCVCUpdate cvc: String, completion: STPTokenCompletionBlock? = nil) {
var params: [String: Any] = [
"cvc_update": [
@ -506,7 +306,6 @@ extension STPAPIClient {
/// - Parameters:
/// - sourceParams: The details of the source to create. Cannot be nil. - seealso: https://stripe.com/docs/api#create_source
/// - completion: The callback to run with the returned Source object, or an error.
@objc(createSourceWithParams:completion:)
public func createSource(
with sourceParams: STPSourceParams, completion: @escaping STPSourceCompletionBlock
) {
@ -533,7 +332,6 @@ extension STPAPIClient {
/// - identifier: The identifier of the source to be retrieved. Cannot be nil.
/// - secret: The client secret of the source. Cannot be nil.
/// - completion: The callback to run with the returned Source object, or an error.
@objc
public func retrieveSource(
withId identifier: String, clientSecret secret: String,
completion: @escaping STPSourceCompletionBlock
@ -577,7 +375,6 @@ extension STPAPIClient {
/// - completion: The callback to run with the returned Source object, or an error.
@available(iOSApplicationExtension, unavailable)
@available(macCatalystApplicationExtension, unavailable)
@objc
public func startPollingSource(
withId identifier: String, clientSecret secret: String, timeout: TimeInterval,
completion: @escaping STPSourceCompletionBlock
@ -599,7 +396,6 @@ extension STPAPIClient {
/// - Parameter identifier: The identifier of the source to be retrieved. Cannot be nil.
@available(iOSApplicationExtension, unavailable)
@available(macCatalystApplicationExtension, unavailable)
@objc
public func stopPollingSource(withId identifier: String) {
sourcePollersQueue?.async(execute: {
let poller = self.sourcePollers?[identifier] as? STPSourcePoller
@ -619,7 +415,6 @@ extension STPAPIClient {
/// - Parameters:
/// - secret: The client secret of the payment intent to be retrieved. Cannot be nil.
/// - completion: The callback to run with the returned PaymentIntent object, or an error.
@objc
public func retrievePaymentIntent(
withClientSecret secret: String,
completion: @escaping STPPaymentIntentCompletionBlock
@ -635,7 +430,6 @@ extension STPAPIClient {
/// - secret: The client secret of the payment intent to be retrieved. Cannot be nil.
/// - expand: An array of string keys to expand on the returned PaymentIntent object. These strings should match one or more of the parameter names that are marked as expandable. - seealso: https://stripe.com/docs/api/payment_intents/object
/// - completion: The callback to run with the returned PaymentIntent object, or an error.
@objc
public func retrievePaymentIntent(
withClientSecret secret: String,
expand: [String]?,
@ -681,7 +475,6 @@ extension STPAPIClient {
/// - Parameters:
/// - paymentIntentParams: The `STPPaymentIntentParams` to pass to `/confirm`
/// - completion: The callback to run with the returned PaymentIntent object, or an error.
@objc(confirmPaymentIntentWithParams:completion:) dynamic
public func confirmPaymentIntent(
with paymentIntentParams: STPPaymentIntentParams,
completion: @escaping STPPaymentIntentCompletionBlock
@ -701,7 +494,6 @@ extension STPAPIClient {
/// - paymentIntentParams: The `STPPaymentIntentParams` to pass to `/confirm`
/// - expand: An array of string keys to expand on the returned PaymentIntent object. These strings should match one or more of the parameter names that are marked as expandable. - seealso: https://stripe.com/docs/api/payment_intents/object
/// - completion: The callback to run with the returned PaymentIntent object, or an error.
@objc(confirmPaymentIntentWithParams:expand:completion:)
public func confirmPaymentIntent(
with paymentIntentParams: STPPaymentIntentParams,
expand: [String]?,
@ -776,7 +568,6 @@ extension STPAPIClient {
/// - Parameters:
/// - secret: The client secret of the SetupIntent to be retrieved. Cannot be nil.
/// - completion: The callback to run with the returned SetupIntent object, or an error.
@objc
public func retrieveSetupIntent(
withClientSecret secret: String,
completion: @escaping STPSetupIntentCompletionBlock
@ -807,7 +598,6 @@ extension STPAPIClient {
/// - Parameters:
/// - setupIntentParams: The `STPSetupIntentConfirmParams` to pass to `/confirm`
/// - completion: The callback to run with the returned PaymentIntent object, or an error.
@objc(confirmSetupIntentWithParams:completion:) dynamic
public func confirmSetupIntent(
with setupIntentParams: STPSetupIntentConfirmParams,
completion: @escaping STPSetupIntentCompletionBlock
@ -869,7 +659,6 @@ extension STPAPIClient {
/// - Parameters:
/// - paymentMethodParams: The `STPPaymentMethodParams` to pass to `/v1/payment_methods`. Cannot be nil.
/// - completion: The callback to run with the returned PaymentMethod object, or an error.
@objc(createPaymentMethodWithParams:completion:)
public func createPaymentMethod(
with paymentMethodParams: STPPaymentMethodParams,
completion: @escaping STPPaymentMethodCompletionBlock
@ -891,7 +680,7 @@ extension STPAPIClient {
// MARK: FPX
/// Retrieves the online status of the FPX banks from the Stripe API.
/// - Parameter completion: The callback to run with the returned FPX bank list, or an error.
@objc func retrieveFPXBankStatus(
func retrieveFPXBankStatus(
withCompletion completion: @escaping STPFPXBankStatusCompletionBlock
) {
APIRequest<STPFPXBankStatusResponse>.getWith(
@ -910,7 +699,7 @@ extension STPAPIClient {
extension STPAPIClient {
/// Retrieve a customer
/// - seealso: https://stripe.com/docs/api#retrieve_customer
@objc(retrieveCustomerUsingKey:completion:) func retrieveCustomer(
func retrieveCustomer(
using ephemeralKey: STPEphemeralKey, completion: @escaping STPCustomerCompletionBlock
) {
let endpoint = "\(APIEndpointCustomers)/\(ephemeralKey.customerID ?? "")"
@ -926,7 +715,7 @@ extension STPAPIClient {
/// Update a customer with parameters
/// - seealso: https://stripe.com/docs/api#update_customer
@objc(updateCustomerWithParameters:usingKey:completion:) func updateCustomer(
func updateCustomer(
withParameters parameters: [String: Any],
using ephemeralKey: STPEphemeralKey,
completion: @escaping STPCustomerCompletionBlock
@ -944,7 +733,7 @@ extension STPAPIClient {
/// Attach a Payment Method to a customer
/// - seealso: https://stripe.com/docs/api/payment_methods/attach
@objc(attachPaymentMethod:toCustomerUsingKey:completion:) func attachPaymentMethod(
func attachPaymentMethod(
_ paymentMethodID: String, toCustomerUsing ephemeralKey: STPEphemeralKey,
completion: @escaping STPErrorBlock
) {
@ -981,7 +770,7 @@ extension STPAPIClient {
/// Detach a Payment Method from a customer
/// - seealso: https://stripe.com/docs/api/payment_methods/detach
@objc(detachPaymentMethod:fromCustomerUsingKey:completion:) func detachPaymentMethod(
func detachPaymentMethod(
_ paymentMethodID: String, fromCustomerUsing ephemeralKey: STPEphemeralKey,
completion: @escaping STPErrorBlock
) {
@ -1013,7 +802,7 @@ extension STPAPIClient {
/// Retrieves a list of Payment Methods attached to a customer.
/// @note This only fetches card type Payment Methods
@objc(listPaymentMethodsForCustomerUsingKey:completion:) func listPaymentMethodsForCustomer(
func listPaymentMethodsForCustomer(
using ephemeralKey: STPEphemeralKey, completion: @escaping STPPaymentMethodsCompletionBlock
) {
listPaymentMethods(
@ -1069,7 +858,7 @@ extension STPAPIClient {
// MARK: - ThreeDS2
extension STPAPIClient {
/// Kicks off 3DS2 authentication.
@objc func authenticate3DS2(
func authenticate3DS2(
_ authRequestParams: STDSAuthenticationRequestParameters,
sourceIdentifier sourceID: String,
returnURL returnURLString: String?,
@ -1105,7 +894,7 @@ extension STPAPIClient {
}
/// Endpoint to call to indicate that the challenge flow for a 3DS2 authentication has finished.
@objc func complete3DS2Authentication(
func complete3DS2Authentication(
forSource sourceID: String, completion: @escaping STPBooleanSuccessBlock
) {
@ -1233,11 +1022,6 @@ extension STPAPIClient {
}
}
/// :nodoc:
@_spi(STP) extension STPAPIClient: PublishableKeyProvider { }
private let APIVersion = "2020-08-27"
private let APIBaseURL = "https://api.stripe.com/v1"
private let APIEndpointToken = "tokens"
private let APIEndpointSources = "sources"
private let APIEndpointCustomers = "customers"

View File

@ -10,7 +10,6 @@ import Foundation
typealias STPPushProvisioningDetailsCompletionBlock = (STPPushProvisioningDetails?, Error?) -> Void
extension STPAPIClient {
@objc(retrievePushProvisioningDetailsWithParams:ephemeralKey:completion:)
func retrievePushProvisioningDetails(
with params: STPPushProvisioningDetailsParams,
ephemeralKey: STPEphemeralKey,

View File

@ -7,6 +7,7 @@
//
import Foundation
@_spi(STP) import StripeCore
private let APIEndpointRadarSession = "radar/session"
@ -23,7 +24,7 @@ extension STPAPIClient {
- Parameters:
- completion: The callback to run with the returned `STPRadarSession` (and any errors that may have occurred).
*/
@objc public func createRadarSession(
public func createRadarSession(
completion: @escaping STPRadarSessionCompletionBlock
) {
STPTelemetryClient.shared.updateFraudDetectionIfNecessary() { result in

View File

@ -66,7 +66,19 @@ public class STPAddCardViewController: STPCoreTableViewController, STPAddressVie
/// The API Client to use to make requests.
/// Defaults to `STPAPIClient.shared`
@objc public var apiClient: STPAPIClient = STPAPIClient.shared
public var apiClient: STPAPIClient = STPAPIClient.shared
/// The API Client to use to make requests.
/// Defaults to `STPAPIClient.shared`.
@available(swift, deprecated: 0.0.1, renamed: "apiClient")
@objc(apiClient) public var _objc_apiClient: _stpobjc_STPAPIClient {
get {
_stpobjc_STPAPIClient(apiClient: apiClient)
}
set {
apiClient = newValue._apiClient
}
}
/// Use init: or initWithConfiguration:theme:
required init(theme: STPTheme?) {

View File

@ -168,7 +168,19 @@ import PassKit
/// The STPAPIClient instance to use to make API requests to Stripe.
/// Defaults to `STPAPIClient.shared`.
@objc public var apiClient: STPAPIClient = .shared
public var apiClient: STPAPIClient = .shared
/// The STPAPIClient instance to use to make API requests to Stripe.
/// Defaults to `STPAPIClient.shared`.
@available(swift, deprecated: 0.0.1, renamed: "apiClient")
@objc(apiClient) public var _objc_apiClient: _stpobjc_STPAPIClient {
get {
_stpobjc_STPAPIClient(apiClient: apiClient)
}
set {
apiClient = newValue._apiClient
}
}
private weak var delegate: STPApplePayContextDelegate?
@objc var authorizationController: PKPaymentAuthorizationController?

View File

@ -69,9 +69,23 @@ public class STPBankSelectionViewController: STPCoreTableViewController, UITable
/// The view controller's delegate. This must be set before showing the view controller in order for it to work properly. - seealso: STPBankSelectionViewControllerDelegate
@objc public weak var delegate: STPBankSelectionViewControllerDelegate?
/// The API Client to use to make requests.
/// Defaults to `STPAPIClient.shared`
@objc public var apiClient: STPAPIClient = .shared
public var apiClient: STPAPIClient = .shared
/// The API Client to use to make requests.
/// Defaults to `STPAPIClient.shared`
@available(swift, deprecated: 0.0.1, renamed: "apiClient")
@objc(apiClient) public var _objc_apiClient: _stpobjc_STPAPIClient {
get {
_stpobjc_STPAPIClient(apiClient: apiClient)
}
set {
apiClient = newValue._apiClient
}
}
private var bankMethod: STPBankSelectionMethod = .unknown
private var selectedBank: STPFPXBankBrand = .unknown
private var configuration: STPPaymentConfiguration?

View File

@ -7,6 +7,7 @@
//
import Foundation
@_spi(STP) import StripeCore
/// An `STPCustomer` represents a deserialized Customer object from the Stripe API.
/// You shouldn't need to instantiate an `STPCustomer` you should instead use

View File

@ -39,7 +39,6 @@ open class STPCustomerContext: NSObject, STPBackendAPIAdapter {
/// - keyProvider: The key provider the customer context will use.
/// - apiClient: The API Client to use to make requests.
/// - Returns: the newly-instantiated customer context.
@objc(initWithKeyProvider:apiClient:)
public convenience init(
keyProvider: STPCustomerEphemeralKeyProvider?, apiClient: STPAPIClient
) {
@ -50,6 +49,24 @@ open class STPCustomerContext: NSObject, STPBackendAPIAdapter {
self.init(keyManager: keyManager, apiClient: apiClient)
}
/// Initializes a new `STPCustomerContext` with the specified key provider.
/// Upon initialization, a CustomerContext will fetch a new ephemeral key from
/// your backend and use it to prefetch the customer object specified in the key.
/// Subsequent customer and payment method retrievals (e.g. by `STPPaymentContext`)
/// will return the prefetched customer / attached payment methods immediately if
/// its age does not exceed 60 seconds.
/// - Parameters:
/// - keyProvider: The key provider the customer context will use.
/// - apiClient: The API Client to use to make requests.
/// - Returns: the newly-instantiated customer context.
@objc(initWithKeyProvider:apiClient:)
@available(swift, deprecated: 0.0.1, renamed: "init(keyProvider:apiClient:)")
public convenience init(
keyProvider: STPCustomerEphemeralKeyProvider?, apiClient: _stpobjc_STPAPIClient
) {
self.init(keyProvider: keyProvider, apiClient: apiClient._apiClient)
}
/// `STPCustomerContext` will cache its customer object and associated payment methods
/// for up to 60 seconds. If your current user logs out of your app and a new user logs
/// in, be sure to either call this method or create a new instance of `STPCustomerContext`.

View File

@ -8,6 +8,7 @@
import Foundation
import UIKit
@_spi(STP) import StripeCore
protocol STPEphemeralKeyManagerProtocol {
/// If the retriever's stored ephemeral key has not expired, it will be
@ -20,11 +21,10 @@ protocol STPEphemeralKeyManagerProtocol {
typealias STPEphemeralKeyCompletionBlock = (STPEphemeralKey?, Error?) -> Void
class STPEphemeralKeyManager: NSObject, STPEphemeralKeyManagerProtocol {
private var _expirationInterval: TimeInterval = 0.0
/// If the current ephemeral key expires in less than this time interval, a call
/// to `getOrCreateKey` will request a new key from the manager's key provider.
/// The maximum allowed value is one hour higher values will be clamped.
private var _expirationInterval: TimeInterval = 0.0
var expirationInterval: TimeInterval {
get {
_expirationInterval

View File

@ -344,8 +344,19 @@ public class STPPaymentContext: NSObject, STPAuthenticationContext,
@objc public var addCardViewControllerFooterView: UIView?
/// The API Client to use to make requests.
/// Defaults to STPAPIClient.shared
@objc public var apiClient: STPAPIClient = .shared
public var apiClient: STPAPIClient = .shared
/// The STPAPIClient instance to use to make API requests.
/// Defaults to `STPAPIClient.shared`.
@available(swift, deprecated: 0.0.1, renamed: "apiClient")
@objc(apiClient) public var _objc_apiClient: _stpobjc_STPAPIClient {
get {
_stpobjc_STPAPIClient(apiClient: apiClient)
}
set {
apiClient = newValue._apiClient
}
}
/// If `paymentContext:didFailToLoadWithError:` is called on your delegate, you
/// can in turn call this method to try loading again (if that hasn't been called,
/// calling this will do nothing). If retrying in turn fails, `paymentContext:didFailToLoadWithError:`

View File

@ -88,7 +88,7 @@ public typealias STPPaymentHandlerActionSetupIntentCompletionBlock = (
/// - seealso: https://stripe.com/docs/mobile/ios/authentication
@available(iOSApplicationExtension, unavailable)
@available(macCatalystApplicationExtension, unavailable)
public class STPPaymentHandler: NSObject, SFSafariViewControllerDelegate, STPURLCallbackListener {
public class STPPaymentHandler: NSObject, SFSafariViewControllerDelegate {
/// The error domain for errors in `STPPaymentHandler`.
@objc public static let errorDomain = "STPPaymentHandlerErrorDomain"
@ -119,7 +119,18 @@ public class STPPaymentHandler: NSObject, SFSafariViewControllerDelegate, STPURL
}
/// By default `sharedHandler` initializes with STPAPIClient.shared.
@objc public var apiClient: STPAPIClient
public var apiClient: STPAPIClient
/// By default `sharedHandler` initializes with STPAPIClient.shared.
@available(swift, deprecated: 0.0.1, renamed: "apiClient")
@objc(apiClient) public var _objc_apiClient: _stpobjc_STPAPIClient {
get {
_stpobjc_STPAPIClient(apiClient: apiClient)
}
set {
apiClient = newValue._apiClient
}
}
/// Customizable settings to use when performing 3DS2 authentication.
/// Note: Configure this before calling any methods.
@ -1372,26 +1383,6 @@ public class STPPaymentHandler: NSObject, SFSafariViewControllerDelegate, STPURL
_retrieveAndCheckIntentForCurrentAction()
}
// MARK: - STPURLCallbackListener
func handleURLCallback(_ url: URL) -> Bool {
let context = currentAction?.authenticationContext
if context?.responds(
to: #selector(STPAuthenticationContext.authenticationContextWillDismiss(_:))) ?? false,
let safariViewController = safariViewController
{
context?.authenticationContextWillDismiss?(safariViewController)
}
NotificationCenter.default.removeObserver(
self, name: UIApplication.willEnterForegroundNotification, object: nil)
STPURLCallbackHandler.shared().unregisterListener(self)
safariViewController?.dismiss(animated: true) {
self.safariViewController = nil
}
_retrieveAndCheckIntentForCurrentAction()
return true
}
// This is only called after web-redirects because native 3DS2 cancels go directly
// to the ACS
func _markChallengeCanceled(withCompletion completion: @escaping STPBooleanSuccessBlock) {
@ -1586,6 +1577,31 @@ public class STPPaymentHandler: NSObject, SFSafariViewControllerDelegate, STPURL
}
}
@available(iOSApplicationExtension, unavailable)
@available(macCatalystApplicationExtension, unavailable)
/// :nodoc:
@_spi(STP) extension STPPaymentHandler: STPURLCallbackListener {
/// :nodoc:
@_spi(STP) public func handleURLCallback(_ url: URL) -> Bool {
let context = currentAction?.authenticationContext
if context?.responds(
to: #selector(STPAuthenticationContext.authenticationContextWillDismiss(_:))) ?? false,
let safariViewController = safariViewController
{
context?.authenticationContextWillDismiss?(safariViewController)
}
NotificationCenter.default.removeObserver(
self, name: UIApplication.willEnterForegroundNotification, object: nil)
STPURLCallbackHandler.shared().unregisterListener(self)
safariViewController?.dismiss(animated: true) {
self.safariViewController = nil
}
_retrieveAndCheckIntentForCurrentAction()
return true
}
}
@available(iOSApplicationExtension, unavailable)
@available(macCatalystApplicationExtension, unavailable)
extension STPPaymentHandler {

View File

@ -11,6 +11,7 @@ import Foundation
#if canImport(Stripe3DS2)
import Stripe3DS2
#endif
@_spi(STP) import StripeCore
@available(iOSApplicationExtension, unavailable)
@available(macCatalystApplicationExtension, unavailable)

View File

@ -234,7 +234,19 @@ public class STPPaymentOptionsViewController: STPCoreViewController,
@objc public var addCardViewControllerFooterView: UIView?
/// The API Client to use to make requests.
/// Defaults to STPAPIClient.shared
@objc public var apiClient: STPAPIClient = .shared
public var apiClient: STPAPIClient = .shared
/// The STPAPIClient instance to use to make API requests.
/// Defaults to `STPAPIClient.shared`.
@available(swift, deprecated: 0.0.1, renamed: "apiClient")
@objc(apiClient) public var _objc_apiClient: _stpobjc_STPAPIClient {
get {
_stpobjc_STPAPIClient(apiClient: apiClient)
}
set {
apiClient = newValue._apiClient
}
}
/// If you're pushing `STPPaymentOptionsViewController` onto an existing
/// `UINavigationController`'s stack, you should use this method to dismiss it,

View File

@ -13,7 +13,19 @@ import UIKit
public class STPPinManagementService: NSObject {
/// The API Client to use to make requests.
/// Defaults to STPAPIClient.shared
@objc public var apiClient: STPAPIClient = STPAPIClient.shared
public var apiClient: STPAPIClient = STPAPIClient.shared
/// The STPAPIClient instance to use to make API requests to Stripe.
/// Defaults to `STPAPIClient.shared`.
@available(swift, deprecated: 0.0.1, renamed: "apiClient")
@objc(apiClient) public var _objc_apiClient: _stpobjc_STPAPIClient {
get {
_stpobjc_STPAPIClient(apiClient: apiClient)
}
set {
apiClient = newValue._apiClient
}
}
/// Create a STPPinManagementService, you must provide an implementation of STPIssuingCardEphemeralKeyProvider
@objc

View File

@ -8,12 +8,25 @@
import Foundation
import PassKit
@_spi(STP) import StripeCore
/// This class makes it easier to implement "Push Provisioning", the process by which an end-user can add a card to their Apple Pay wallet without having to type their number. This process is mediated by an Apple class called `PKAddPaymentPassViewController`; this class will help you implement that class' delegate methods. Note that this flow requires a special entitlement from Apple; for more information please see https://stripe.com/docs/issuing/cards/digital-wallets .
public class STPPushProvisioningContext: NSObject {
/// The API Client to use to make requests.
/// Defaults to STPAPIClient.shared
@objc public var apiClient: STPAPIClient = .shared
public var apiClient: STPAPIClient = .shared
/// The STPAPIClient instance to use to make API requests to Stripe.
/// Defaults to `STPAPIClient.shared`.
@available(swift, deprecated: 0.0.1, renamed: "apiClient")
@objc(apiClient) public var _objc_apiClient: _stpobjc_STPAPIClient {
get {
_stpobjc_STPAPIClient(apiClient: apiClient)
}
set {
apiClient = newValue._apiClient
}
}
/// This is a helper method to generate a PKAddPaymentPassRequestConfiguration that will work with
/// Stripe's Issuing APIs. Pass the returned configuration object to `PKAddPaymentPassViewController`'s `initWithRequestConfiguration:delegate:` initializer.

View File

@ -74,7 +74,7 @@ public typealias STPRedirectContextPaymentIntentCompletionBlock = (String, Error
/// See https://stripe.com/docs/sources/best-practices
@available(iOSApplicationExtension, unavailable)
@available(macCatalystApplicationExtension, unavailable)
public class STPRedirectContext: NSObject, SFSafariViewControllerDelegate, STPURLCallbackListener,
public class STPRedirectContext: NSObject, SFSafariViewControllerDelegate,
UIViewControllerTransitioningDelegate, STPSafariViewControllerDismissalDelegate
{
@ -450,16 +450,6 @@ public class STPRedirectContext: NSObject, SFSafariViewControllerDelegate, STPUR
})
}
func handleURLCallback(_ url: URL) -> Bool {
stpDispatchToMainThreadIfNecessary({
self.handleRedirectCompletionWithError(
nil,
shouldDismissViewController: true)
})
// We handle all returned urls that match what we registered for
return true
}
@objc dynamic func handleRedirectCompletionWithError(
_ error: Error?,
shouldDismissViewController: Bool
@ -552,6 +542,22 @@ public class STPRedirectContext: NSObject, SFSafariViewControllerDelegate, STPUR
}
}
@available(iOSApplicationExtension, unavailable)
@available(macCatalystApplicationExtension, unavailable)
/// :nodoc:
@_spi(STP) extension STPRedirectContext: STPURLCallbackListener {
/// :nodoc:
@_spi(STP) public func handleURLCallback(_ url: URL) -> Bool {
stpDispatchToMainThreadIfNecessary({
self.handleRedirectCompletionWithError(
nil,
shouldDismissViewController: true)
})
// We handle all returned urls that match what we registered for
return true
}
}
@objc protocol STPSafariViewControllerDismissalDelegate: NSObjectProtocol {
func safariViewControllerDidCompleteDismissal(_ controller: SFSafariViewController)
}

View File

@ -8,6 +8,7 @@
import Foundation
import UIKit
@_spi(STP) import StripeCore
@available(iOSApplicationExtension, unavailable)
@available(macCatalystApplicationExtension, unavailable)

View File

@ -0,0 +1,146 @@
//
// StripeAPI+Deprecated.swift
// StripeiOS
//
// Created by David Estes on 10/15/21.
// Copyright © 2021 Stripe, Inc. All rights reserved.
//
import Foundation
import PassKit
extension StripeAPI {
/// A convenience method to build a `PKPaymentRequest` with sane default values.
/// You will still need to configure the `paymentSummaryItems` property to indicate
/// what the user is purchasing, as well as the optional `requiredShippingAddressFields`,
/// `requiredBillingAddressFields`, and `shippingMethods` properties to indicate
/// what contact information your application requires.
/// Note that this method sets the payment request's countryCode to "US" and its
/// currencyCode to "USD".
/// - Parameter merchantIdentifier: Your Apple Merchant ID.
/// - Returns: a `PKPaymentRequest` with proper default values. Returns nil if running on < iOS8.
/// @deprecated Use `paymentRequestWithMerchantIdentifier:country:currency:` instead.
/// Apple Pay is available in many countries and currencies, and you should use
/// the appropriate values for your business.
@available(
*, deprecated,
message: "Use `paymentRequestWithMerchantIdentifier:country:currency:` instead."
)
public class func paymentRequest(withMerchantIdentifier merchantIdentifier: String)
-> PKPaymentRequest
{
return self.paymentRequest(
withMerchantIdentifier: merchantIdentifier, country: "US", currency: "USD")
}
}
// MARK: Deprecated top-level Stripe functions.
// These are included so Xcode can offer guidance on how to replace top-level Stripe usage.
/// :nodoc:
@available(
*, deprecated,
message:
"Use StripeAPI.defaultPublishableKey instead. (StripeAPI.defaultPublishableKey = \"pk_12345_xyzabc\")"
)
public func setDefaultPublishableKey(_ publishableKey: String) {
StripeAPI.defaultPublishableKey = publishableKey
}
/// :nodoc:
@available(
*, deprecated,
message: "Use StripeAPI.advancedFraudSignalsEnabled instead."
)
public var advancedFraudSignalsEnabled: Bool {
get {
StripeAPI.advancedFraudSignalsEnabled
}
set {
StripeAPI.advancedFraudSignalsEnabled = newValue
}
}
/// :nodoc:
@available(
*, deprecated,
message: "Use StripeAPI.jcbPaymentNetworkSupported instead."
)
public var jcbPaymentNetworkSupported: Bool {
get {
StripeAPI.jcbPaymentNetworkSupported
}
set {
StripeAPI.jcbPaymentNetworkSupported = newValue
}
}
/// :nodoc:
@available(
*, deprecated,
message: "Use StripeAPI.additionalEnabledApplePayNetworks instead."
)
public var additionalEnabledApplePayNetworks: [PKPaymentNetwork] {
get {
StripeAPI.additionalEnabledApplePayNetworks
}
set {
StripeAPI.additionalEnabledApplePayNetworks = newValue
}
}
/// :nodoc:
@available(
*, deprecated,
message: "Use StripeAPI.canSubmitPaymentRequest(_:) instead."
)
public func canSubmitPaymentRequest(_ paymentRequest: PKPaymentRequest) -> Bool {
return StripeAPI.canSubmitPaymentRequest(paymentRequest)
}
/// :nodoc:
@available(
*, deprecated,
message: "Use StripeAPI.deviceSupportsApplePay() instead."
)
public func deviceSupportsApplePay() -> Bool {
return StripeAPI.deviceSupportsApplePay()
}
/// :nodoc:
@available(
*, deprecated,
message: "Use StripeAPI.paymentRequest(withMerchantIdentifier:country:currency:) instead."
)
public func paymentRequest(
withMerchantIdentifier merchantIdentifier: String,
country countryCode: String,
currency currencyCode: String
) -> PKPaymentRequest {
return StripeAPI.paymentRequest(
withMerchantIdentifier: merchantIdentifier, country: countryCode, currency: currencyCode)
}
/// :nodoc:
@available(
*, deprecated,
message: "Use StripeAPI.paymentRequest(withMerchantIdentifier:country:currency:) instead."
)
func paymentRequest(withMerchantIdentifier merchantIdentifier: String)
-> PKPaymentRequest
{
return StripeAPI.paymentRequest(
withMerchantIdentifier: merchantIdentifier, country: "US", currency: "USD")
}
/// :nodoc:
@available(
*, deprecated,
message: "Use StripeAPI.handleURLCallback(with:) instead."
)
public func handleURLCallback(with url: URL) -> Bool {
return StripeAPI.handleURLCallback(with: url)
}

View File

@ -0,0 +1,10 @@
//
// StripeCore+Import.swift
// StripeiOS
//
// Created by David Estes on 9/8/21.
// Copyright © 2021 Stripe, Inc. All rights reserved.
//
import Foundation
@_exported import StripeCore

View File

@ -9,6 +9,7 @@
import Foundation
import UIKit
@_spi(STP) import StripeUICore
@_spi(STP) import StripeCore
extension TextFieldElement {
static func makeIBAN() -> TextFieldElement {

View File

@ -0,0 +1,462 @@
//
// _stpobjc_STPAPIClient.swift
// StripeiOS
//
// Created by David Estes on 9/7/21.
// Copyright © 2021 Stripe, Inc. All rights reserved.
//
// This is a workaround for the lack of cross-Swift-module extension support in
// the iOS 11 and iOS 12 Objective-C runtime.
import Foundation
import PassKit
import UIKit
@_spi(STP) import StripeCore
/*
NOTE: Because '@objc' is not supported in cross-module extensions below iOS 13, a separate
Objective-C compatible wrapper of `STPAPIClient` is needed. When updating
documentation comments, make sure to update the corresponding comments in
`STPAPIClient` as well.
*/
/// An Objective-C bridge for STPAPIClient.
/// :nodoc:
@objc(STPAPIClient)
@available(swift, deprecated: 0.0.1, renamed: "STPAPIClient")
public class _stpobjc_STPAPIClient: NSObject {
var _apiClient: STPAPIClient
/// The current version of this library.
@objc public static let STPSDKVersion = STPAPIClient.STPSDKVersion
/// A shared singleton API client.
/// By default, the SDK uses this instance to make API requests
/// eg in STPPaymentHandler, STPPaymentContext, STPCustomerContext, etc.
@objc(sharedClient)
@available(swift, deprecated: 0.0.1)
public static let shared: _stpobjc_STPAPIClient = {
return _stpobjc_STPAPIClient(apiClient: .shared)
}()
/// The client's publishable key.
/// The default value is `StripeAPI.defaultPublishableKey`.
@objc public var publishableKey: String? {
get {
_apiClient.publishableKey
}
set {
_apiClient.publishableKey = newValue
}
}
/// The client's configuration.
/// Defaults to `STPPaymentConfiguration.shared`.
@objc public var configuration: STPPaymentConfiguration {
get {
_apiClient.configuration
}
set {
_apiClient.configuration = newValue
}
}
/// In order to perform API requests on behalf of a connected account, e.g. to
/// create a Source or Payment Method on a connected account, set this property to the ID of the
/// account for which this request is being made.
/// - seealso: https://stripe.com/docs/connect/authentication#authentication-via-the-stripe-account-header
@objc public var stripeAccount: String? {
get {
_apiClient.stripeAccount
}
set {
_apiClient.stripeAccount = newValue
}
}
/// Libraries wrapping the Stripe SDK should set this, so that Stripe can contact you about future issues or critical updates.
/// - seealso: https://stripe.com/docs/building-plugins#setappinfo
@objc public var appInfo: _stpobjc_STPAppInfo? {
get {
_stpobjc_STPAppInfo(appInfo: _apiClient.appInfo)
}
set {
_apiClient.appInfo = newValue?._appInfo
}
}
/// The API version used to communicate with Stripe.
@objc public static let apiVersion = STPAPIClient.apiVersion
init(apiClient: STPAPIClient) {
STPAnalyticsClient.sharedClient.addClass(toProductUsageIfNecessary: _stpobjc_STPAPIClient.self)
_apiClient = apiClient
super.init()
}
/// Initializes an API client with the given publishable key.
/// - Parameter publishableKey: The publishable key to use.
/// - Returns: An instance of STPAPIClient.
@objc
public init(publishableKey: String) {
STPAnalyticsClient.sharedClient.addClass(toProductUsageIfNecessary: _stpobjc_STPAPIClient.self)
_apiClient = STPAPIClient(publishableKey: publishableKey)
super.init()
}
/// Initializes an API client with the given configuration.
/// - Parameter configuration: The configuration to use.
/// - Returns: An instance of STPAPIClient.
@available(
*, deprecated,
message:
"This initializer previously configured publishableKey and stripeAccount via the STPPaymentConfiguration instance. This behavior is deprecated; set the STPAPIClient configuration, publishableKey, and stripeAccount properties directly on the STPAPIClient instead."
)
@objc
public init(configuration: STPPaymentConfiguration) {
_apiClient = STPAPIClient()
super.init()
publishableKey = configuration.publishableKey
stripeAccount = configuration.stripeAccount
}
// MARK: API Functions
/// Converts an STPBankAccount object into a Stripe token using the Stripe API.
/// - Parameters:
/// - bankAccount: The user's bank account details. Cannot be nil. - seealso: https://stripe.com/docs/api#create_bank_account_token
/// - completion: The callback to run with the returned Stripe token (and any errors that may have occurred).
@objc
public func createToken(
withBankAccount bankAccount: STPBankAccountParams,
completion: @escaping STPTokenCompletionBlock
) {
_apiClient.createToken(withBankAccount:bankAccount, completion: completion)
}
// MARK: PII
/// Converts a personal identification number into a Stripe token using the Stripe API.
/// - Parameters:
/// - pii: The user's personal identification number. Cannot be nil. - seealso: https://stripe.com/docs/api#create_pii_token
/// - completion: The callback to run with the returned Stripe token (and any errors that may have occurred).
@objc
public func createToken(
withPersonalIDNumber pii: String, completion: STPTokenCompletionBlock?
) {
_apiClient.createToken(withPersonalIDNumber: pii, completion: completion)
}
/// Converts the last 4 SSN digits into a Stripe token using the Stripe API.
/// - Parameters:
/// - ssnLast4: The last 4 digits of the user's SSN. Cannot be nil.
/// - completion: The callback to run with the returned Stripe token (and any errors that may have occurred).
@objc
public func createToken(
withSSNLast4 ssnLast4: String, completion: @escaping STPTokenCompletionBlock
) {
_apiClient.createToken(withSSNLast4: ssnLast4, completion: completion)
}
// MARK: Connect Accounts
/// Converts an `STPConnectAccountParams` object into a Stripe token using the Stripe API.
/// This allows the connected account to accept the Terms of Service, and/or send Legal Entity information.
/// - Parameters:
/// - account: The Connect Account parameters. Cannot be nil.
/// - completion: The callback to run with the returned Stripe token (and any errors that may have occurred).
@objc
public func createToken(
withConnectAccount account: STPConnectAccountParams, completion: STPTokenCompletionBlock?
) {
_apiClient.createToken(withConnectAccount: account, completion: completion)
}
// MARK: Upload
/// Uses the Stripe file upload API to upload an image. This can be used for
/// identity verification and evidence disputes.
/// - Parameters:
/// - image: The image to be uploaded. The maximum allowed file size is 4MB
/// for identity documents and 8MB for evidence disputes. Cannot be nil.
/// Your image will be automatically resized down if you pass in one that
/// is too large
/// - purpose: The purpose of this file. This can be either an identifing
/// document or an evidence dispute.
/// - completion: The callback to run with the returned Stripe file
/// (and any errors that may have occurred).
/// - seealso: https://stripe.com/docs/file-upload
@objc
public func uploadImage(
_ image: UIImage,
purpose: STPFilePurpose,
completion: STPFileCompletionBlock?
) {
_apiClient.uploadImage(image, purpose: purpose, completion: completion)
}
// MARK: Credit Cards
/// Converts an STPCardParams object into a Stripe token using the Stripe API.
/// - Parameters:
/// - cardParams: The user's card details. Cannot be nil. - seealso: https://stripe.com/docs/api#create_card_token
/// - completion: The callback to run with the returned Stripe token (and any errors that may have occurred).
@objc
public func createToken(
withCard cardParams: STPCardParams, completion: @escaping STPTokenCompletionBlock
) {
_apiClient.createToken(withCard: cardParams, completion: completion)
}
/// Converts a CVC string into a Stripe token using the Stripe API.
/// - Parameters:
/// - cvc: The CVC/CVV number used to create the token. Cannot be nil.
/// - completion: The callback to run with the returned Stripe token (and any errors that may have occurred).
@objc
public func createToken(forCVCUpdate cvc: String, completion: STPTokenCompletionBlock? = nil) {
_apiClient.createToken(forCVCUpdate: cvc, completion: completion)
}
// MARK: Sources
/// Creates a Source object using the provided details.
/// Note: in order to create a source on a connected account, you can set your
/// API client's `stripeAccount` property to the ID of the account.
/// - seealso: https://stripe.com/docs/sources/connect#creating-direct-charges
/// - Parameters:
/// - sourceParams: The details of the source to create. Cannot be nil. - seealso: https://stripe.com/docs/api#create_source
/// - completion: The callback to run with the returned Source object, or an error.
@objc(createSourceWithParams:completion:)
public func createSource(
with sourceParams: STPSourceParams, completion: @escaping STPSourceCompletionBlock
) {
_apiClient.createSource(with: sourceParams, completion: completion)
}
/// Retrieves the Source object with the given ID. - seealso: https://stripe.com/docs/api#retrieve_source
/// - Parameters:
/// - identifier: The identifier of the source to be retrieved. Cannot be nil.
/// - secret: The client secret of the source. Cannot be nil.
/// - completion: The callback to run with the returned Source object, or an error.
@objc
public func retrieveSource(
withId identifier: String, clientSecret secret: String,
completion: @escaping STPSourceCompletionBlock
) {
_apiClient.retrieveSource(withId: identifier, clientSecret: secret, completion: completion)
}
/// Starts polling the Source object with the given ID. For payment methods that require
/// additional customer action (e.g. authorizing a payment with their bank), polling
/// allows you to determine if the action was successful. Polling will stop and the
/// provided callback will be called once the source's status is no longer `pending`,
/// or if the given timeout is reached and the source is still `pending`. If polling
/// stops due to an error, the callback will be fired with the latest retrieved
/// source and the error.
/// Note that if a poll is already running for a source, subsequent calls to `startPolling`
/// with the same source ID will do nothing.
/// - Parameters:
/// - identifier: The identifier of the source to be retrieved. Cannot be nil.
/// - secret: The client secret of the source. Cannot be nil.
/// - timeout: The timeout for the polling operation, in seconds. Timeouts are capped at 5 minutes.
/// - completion: The callback to run with the returned Source object, or an error.
@available(iOSApplicationExtension, unavailable)
@available(macCatalystApplicationExtension, unavailable)
@objc
public func startPollingSource(
withId identifier: String, clientSecret secret: String, timeout: TimeInterval,
completion: @escaping STPSourceCompletionBlock
) {
_apiClient.startPollingSource(withId: identifier, clientSecret: secret, timeout: timeout, completion: completion)
}
/// Stops polling the Source object with the given ID. Note that the completion block passed to
/// `startPolling` will not be fired when `stopPolling` is called.
/// - Parameter identifier: The identifier of the source to be retrieved. Cannot be nil.
@available(iOSApplicationExtension, unavailable)
@available(macCatalystApplicationExtension, unavailable)
@objc
public func stopPollingSource(withId identifier: String) {
_apiClient.stopPollingSource(withId: identifier)
}
// MARK: Payment Intents
/// Retrieves the PaymentIntent object using the given secret. - seealso: https://stripe.com/docs/api#retrieve_payment_intent
/// - Parameters:
/// - secret: The client secret of the payment intent to be retrieved. Cannot be nil.
/// - completion: The callback to run with the returned PaymentIntent object, or an error.
@objc
public func retrievePaymentIntent(
withClientSecret secret: String,
completion: @escaping STPPaymentIntentCompletionBlock
) {
_apiClient.retrievePaymentIntent(withClientSecret: secret, completion: completion)
}
/// Retrieves the PaymentIntent object using the given secret. - seealso: https://stripe.com/docs/api#retrieve_payment_intent
/// - Parameters:
/// - secret: The client secret of the payment intent to be retrieved. Cannot be nil.
/// - expand: An array of string keys to expand on the returned PaymentIntent object. These strings should match one or more of the parameter names that are marked as expandable. - seealso: https://stripe.com/docs/api/payment_intents/object
/// - completion: The callback to run with the returned PaymentIntent object, or an error.
@objc
public func retrievePaymentIntent(
withClientSecret secret: String,
expand: [String]?,
completion: @escaping STPPaymentIntentCompletionBlock
) {
_apiClient.retrievePaymentIntent(withClientSecret: secret, expand: expand, completion: completion)
}
/// Confirms the PaymentIntent object with the provided params object.
/// At a minimum, the params object must include the `clientSecret`.
/// - seealso: https://stripe.com/docs/api#confirm_payment_intent
/// @note Use the `confirmPayment:withAuthenticationContext:completion:` method on `STPPaymentHandler` instead
/// of calling this method directly. It handles any authentication necessary for you. - seealso: https://stripe.com/docs/mobile/ios/authentication
/// - Parameters:
/// - paymentIntentParams: The `STPPaymentIntentParams` to pass to `/confirm`
/// - completion: The callback to run with the returned PaymentIntent object, or an error.
@objc(confirmPaymentIntentWithParams:completion:) dynamic
public func confirmPaymentIntent(
with paymentIntentParams: STPPaymentIntentParams,
completion: @escaping STPPaymentIntentCompletionBlock
) {
_apiClient.confirmPaymentIntent(with: paymentIntentParams, completion: completion)
}
/// Confirms the PaymentIntent object with the provided params object.
/// At a minimum, the params object must include the `clientSecret`.
/// - seealso: https://stripe.com/docs/api#confirm_payment_intent
/// @note Use the `confirmPayment:withAuthenticationContext:completion:` method on `STPPaymentHandler` instead
/// of calling this method directly. It handles any authentication necessary for you. - seealso: https://stripe.com/docs/mobile/ios/authentication
/// - Parameters:
/// - paymentIntentParams: The `STPPaymentIntentParams` to pass to `/confirm`
/// - expand: An array of string keys to expand on the returned PaymentIntent object. These strings should match one or more of the parameter names that are marked as expandable. - seealso: https://stripe.com/docs/api/payment_intents/object
/// - completion: The callback to run with the returned PaymentIntent object, or an error.
@objc(confirmPaymentIntentWithParams:expand:completion:)
public func confirmPaymentIntent(
with paymentIntentParams: STPPaymentIntentParams,
expand: [String]?,
completion: @escaping STPPaymentIntentCompletionBlock
) {
_apiClient.confirmPaymentIntent(with: paymentIntentParams, expand: expand, completion: completion)
}
// MARK: Setup Intents
/// Retrieves the SetupIntent object using the given secret. - seealso: https://stripe.com/docs/api/setup_intents/retrieve
/// - Parameters:
/// - secret: The client secret of the SetupIntent to be retrieved. Cannot be nil.
/// - completion: The callback to run with the returned SetupIntent object, or an error.
@objc
public func retrieveSetupIntent(
withClientSecret secret: String,
completion: @escaping STPSetupIntentCompletionBlock
) {
_apiClient.retrieveSetupIntent(withClientSecret: secret, completion: completion)
}
/// Confirms the SetupIntent object with the provided params object.
/// At a minimum, the params object must include the `clientSecret`.
/// - seealso: https://stripe.com/docs/api/setup_intents/confirm
/// @note Use the `confirmSetupIntent:withAuthenticationContext:completion:` method on `STPPaymentHandler` instead
/// of calling this method directly. It handles any authentication necessary for you. - seealso: https://stripe.com/docs/mobile/ios/authentication
/// - Parameters:
/// - setupIntentParams: The `STPSetupIntentConfirmParams` to pass to `/confirm`
/// - completion: The callback to run with the returned PaymentIntent object, or an error.
@objc(confirmSetupIntentWithParams:completion:) dynamic
public func confirmSetupIntent(
with setupIntentParams: STPSetupIntentConfirmParams,
completion: @escaping STPSetupIntentCompletionBlock
) {
_apiClient.confirmSetupIntent(with: setupIntentParams, completion: completion)
}
// MARK: Payment Methods
/// Creates a PaymentMethod object with the provided params object.
/// - seealso: https://stripe.com/docs/api/payment_methods/create
/// - Parameters:
/// - paymentMethodParams: The `STPPaymentMethodParams` to pass to `/v1/payment_methods`. Cannot be nil.
/// - completion: The callback to run with the returned PaymentMethod object, or an error.
@objc(createPaymentMethodWithParams:completion:)
public func createPaymentMethod(
with paymentMethodParams: STPPaymentMethodParams,
completion: @escaping STPPaymentMethodCompletionBlock
) {
_apiClient.createPaymentMethod(with: paymentMethodParams, completion: completion)
}
// MARK: Radar
/**
Creates a Radar Session.
- Note: See https://stripe.com/docs/radar/radar-session
- Note: This API and the guide linked above require special permissions to use. Contact support@stripe.com.
- Note: `StripeAPI.advancedFraudSignalsEnabled` must be `true` to use this method.
- Note: See `STPRadarSession`
- Parameters:
- completion: The callback to run with the returned `STPRadarSession` (and any errors that may have occurred).
*/
@objc public func createRadarSession(
completion: @escaping STPRadarSessionCompletionBlock
) {
_apiClient.createRadarSession(completion: completion)
}
// MARK: Apple Pay
/// Converts a PKPayment object into a Stripe token using the Stripe API.
/// - Parameters:
/// - payment: The user's encrypted payment information as returned from a PKPaymentAuthorizationController. Cannot be nil.
/// - completion: The callback to run with the returned Stripe token (and any errors that may have occurred).
@objc(createTokenWithPayment:completion:)
public func createToken(with payment: PKPayment, completion: @escaping STPTokenCompletionBlock)
{
_apiClient.createToken(with: payment, completion: completion)
}
/// Converts a PKPayment object into a Stripe source using the Stripe API.
/// - Parameters:
/// - payment: The user's encrypted payment information as returned from a PKPaymentAuthorizationController. Cannot be nil.
/// - completion: The callback to run with the returned Stripe source (and any errors that may have occurred).
@objc(createSourceWithPayment:completion:)
public func createSource(
with payment: PKPayment, completion: @escaping STPSourceCompletionBlock
) {
_apiClient.createSource(with: payment, completion: completion)
}
/// Converts a PKPayment object into a Stripe Payment Method using the Stripe API.
/// - Parameters:
/// - payment: The user's encrypted payment information as returned from a PKPaymentAuthorizationController. Cannot be nil.
/// - completion: The callback to run with the returned Stripe source (and any errors that may have occurred).
@objc(createPaymentMethodWithPayment:completion:)
public func createPaymentMethod(
with payment: PKPayment, completion: @escaping STPPaymentMethodCompletionBlock
) {
_apiClient.createPaymentMethod(with: payment, completion: completion)
}
/// Converts Stripe errors into the appropriate Apple Pay error, for use in `PKPaymentAuthorizationResult`.
/// If the error can be fixed by the customer within the Apple Pay sheet, we return an NSError that can be displayed in the Apple Pay sheet.
/// Otherwise, the original error is returned, resulting in the Apple Pay sheet being dismissed. You should display the error message to the customer afterwards.
/// Currently, we convert billing address related errors into a PKPaymentError that helpfully points to the billing address field in the Apple Pay sheet.
/// Note that Apple Pay should prevent most card errors (e.g. invalid CVC, expired cards) when you add a card to the wallet.
/// - Parameter stripeError: An error from the Stripe SDK.
@objc public class func pkPaymentError(forStripeError stripeError: Error?) -> Error? {
STPAPIClient.pkPaymentError(forStripeError: stripeError)
}
}
@available(swift, deprecated: 0.0.1, renamed: "STPAPIClient")
/// :nodoc:
@_spi(STP) extension _stpobjc_STPAPIClient: STPAnalyticsProtocol {
@_spi(STP) public static var stp_analyticsIdentifier = "objc_STPAPIClient"
}

View File

@ -0,0 +1,59 @@
//
// _stpobjc_STPAppInfo.swift
// StripeiOS
//
// Created by David Estes on 9/21/21.
// Copyright © 2021 Stripe, Inc. All rights reserved.
//
import UIKit
import StripeCore
/// Libraries wrapping the Stripe SDK should use this object to provide information about the library, and set it
/// in on `STPAPIClient`. This information is passed to Stripe so that we can contact you about future issues or critical updates.
/// - seealso: https://stripe.com/docs/building-plugins#setappinfo
/// :nodoc:
@objc(STPAppInfo)
public class _stpobjc_STPAppInfo: NSObject {
var _appInfo: STPAppInfo
/// Initializes an instance of `STPAppInfo`.
/// - Parameters:
/// - name: The name of your library (e.g. "MyAwesomeLibrary").
/// - partnerId: Your Stripe Partner ID (e.g. "pp_partner_1234"). Required for Stripe Verified Partners, optional otherwise.
/// - version: The version of your library (e.g. "1.2.34"). Optional.
/// - url: The website for your library (e.g. "https://myawesomelibrary.info"). Optional.
@objc public init(
name: String,
partnerId: String?,
version: String?,
url: String?
) {
_appInfo = STPAppInfo(name: name, partnerId: partnerId, version: version, url: url)
}
init?(appInfo: STPAppInfo?) {
if let appInfo = appInfo {
_appInfo = appInfo
} else {
return nil
}
}
/// The name of your library (e.g. "MyAwesomeLibrary").
@objc public var name: String {
_appInfo.name
}
/// Your Stripe Partner ID (e.g. "pp_partner_1234").
@objc public var partnerId: String? {
_appInfo.partnerId
}
/// The version of your library (e.g. "1.2.34").
@objc public var version: String? {
_appInfo.version
}
/// The website for your library (e.g. "https://myawesomelibrary.info").
@objc public var url: String? {
_appInfo.url
}
}

View File

@ -0,0 +1,101 @@
//
// STPError.swift
// Stripe
//
// Created by Saikat Chakrabarti on 11/4/12.
//
//
import Foundation
@_spi(STP) import StripeCore
// These must line up with the codes in STPError.swift.
/// Possible error code values for NSErrors with the `StripeDomain` domain
@available(swift, deprecated: 0.0.1, renamed: "STPErrorCode")
@objc(STPErrorCode) public enum _stpobjc_STPErrorCode: Int {
/// Trouble connecting to Stripe.
@objc(STPConnectionError) case connectionError = 40
/// Your request had invalid parameters.
@objc(STPInvalidRequestError) case invalidRequestError = 50
/// General-purpose API error.
@objc(STPAPIError) case apiError = 60
/// Something was wrong with the given card details.
@objc(STPCardError) case cardError = 70
/// The operation was cancelled.
@objc(STPCancellationError) case cancellationError = 80
/// The ephemeral key could not be decoded. Make sure your backend is sending
/// the unmodified JSON of the ephemeral key to your app.
/// https://stripe.com/docs/mobile/ios/standard#prepare-your-api
@objc(STPEphemeralKeyDecodingError) case ephemeralKeyDecodingError = 1000
}
// MARK: - STPError
/// Top-level class for Stripe error constants.
@available(swift, deprecated: 0.0.1, renamed: "STPError")
@objc(STPError) public class _stpobjc_STPError: NSObject {
// MARK: userInfo keys
/// All Stripe iOS errors will be under this domain.
@objc public static let stripeDomain = STPError.stripeDomain
/// A human-readable message providing more details about the error.
/// For card errors, these messages can be shown to your users.
/// - seealso: https://stripe.com/docs/api/errors#errors-message
@objc public static let errorMessageKey = STPError.errorMessageKey
/// An SDK-supplied "hint" that is intended to help you, the developer, fix the error
@objc public static let hintKey = STPError.hintKey
/// What went wrong with your STPCard (e.g., STPInvalidCVC. See below for full list).
@objc public static let cardErrorCodeKey = STPError.cardErrorCodeKey
/// Which parameter on the STPCard had an error (e.g., "cvc"). Useful for marking up the
/// right UI element.
@objc public static let errorParameterKey = STPError.errorParameterKey
/// The error code returned by the Stripe API.
/// - seealso: https://stripe.com/docs/api#errors-code
/// - seealso: https://stripe.com/docs/error-codes
@objc public static let stripeErrorCodeKey = STPError.stripeErrorCodeKey
/// The error type returned by the Stripe API.
/// - seealso: https://stripe.com/docs/api#errors-type
@objc public static let stripeErrorTypeKey = STPError.stripeErrorTypeKey
/// If the value of `userInfo[stripeErrorCodeKey]` is `STPError.cardDeclined`,
/// the value for this key contains the decline code.
/// - seealso: https://stripe.com/docs/declines/codes
@objc public static let stripeDeclineCodeKey = STPError.stripeDeclineCodeKey
// MARK: Card errors
/// The card number is not a valid credit card number.
@objc public static let invalidNumber = STPError.invalidNumber
/// The card has an invalid expiration month.
@objc public static let invalidExpMonth = STPError.invalidExpMonth
/// The card has an invalid expiration year.
@objc public static let invalidExpYear = STPError.invalidExpYear
/// The card has an invalid CVC.
@objc public static let invalidCVC = STPError.invalidCVC
/// The card number is incorrect.
@objc public static let incorrectNumber = STPError.incorrectNumber
/// The card is expired.
@objc public static let expiredCard = STPError.expiredCard
/// The card was declined.
@objc public static let cardDeclined = STPError.cardDeclined
/// An error occured while processing this card.
@objc public static let processingError = STPError.processingError
/// The card has an incorrect CVC.
@objc public static let incorrectCVC = STPError.incorrectCVC
/// The postal code is incorrect.
@objc public static let incorrectZip = STPError.incorrectZip
}
/// NSError extensions for creating error objects from Stripe API responses.
@objc extension NSError {
/// Creates an NSError object from a given Stripe API json response.
/// - Parameter jsonDictionary: The root dictionary from the JSON response.
/// - Returns: An NSError object with the error information from the JSON response,
/// or nil if there was no error information included in the JSON dictionary.
@available(swift, deprecated: 0.0.1, renamed: "stp_error(fromStripeResponse:)")
@objc(stp_errorFromStripeResponse:) public static func _stpobjc_stp_error(fromStripeResponse jsonDictionary: [AnyHashable: Any]?)
-> NSError?
{
return stp_error(fromStripeResponse: jsonDictionary)
}
}

View File

@ -0,0 +1,171 @@
//
// StripeAPI_objc.swift
// StripeiOS
//
// Created by Mel Ludowise on 9/3/21.
// Copyright © 2021 Stripe, Inc. All rights reserved.
//
import PassKit
@_spi(STP) import StripeCore
/*
NOTE: Because '@objc' is not supported in extensions below iOS 13, a separate
Objective-C compatible wrapper of `StripeAPI` is needed. When updating
documentation comments, make sure to update the corresponding comments in
`StripeAPI` as well.
*/
/**
A top-level class that imports the rest of the Stripe SDK.
:nodoc:
*/
@available(swift, obsoleted: 0.0.1, message: "Use 'StripeAPI' instead.")
@objc(StripeAPI)
public class _stpobjc_StripeAPI: NSObject {
/// Set this to your Stripe publishable API key, obtained from https://dashboard.stripe.com/apikeys.
/// Set this as early as possible in your application's lifecycle, preferably in your AppDelegate or SceneDelegate.
/// New instances of STPAPIClient will be initialized with this value.
/// @warning Make sure not to ship your test API keys to the App Store! This will log a warning if you use your test key in a release build.
@objc public static var defaultPublishableKey: String? {
get {
return StripeAPI.defaultPublishableKey
} set {
StripeAPI.defaultPublishableKey = newValue
}
}
/// A Boolean value that determines whether additional device data is sent to Stripe for fraud prevention.
/// If YES, additional device signals will be sent to Stripe.
/// For more details on the information we collect, visit https://stripe.com/docs/disputes/prevention/advanced-fraud-detection
/// Disabling this setting will reduce Stripe's ability to protect your business from fraudulent payments.
/// The default value is YES.
@objc public static var advancedFraudSignalsEnabled: Bool {
get {
return StripeAPI.advancedFraudSignalsEnabled
} set {
StripeAPI.advancedFraudSignalsEnabled = newValue
}
}
/// If the SDK receives a "Too Many Requests" (429) status code from Stripe,
/// it will automatically retry the request.
/// The default value is 3.
/// See https://stripe.com/docs/rate-limits for more information.
@objc public static var maxRetries: Int {
get {
return StripeAPI.maxRetries
} set {
StripeAPI.maxRetries = newValue
}
}
/// Call this method in your app delegate whenever you receive an URL in your
/// app delegate for a Stripe callback.
/// For convenience, you can pass all URL's you receive in your app delegate
/// to this method first, and check the return value
/// to easily determine whether it is a callback URL that Stripe will handle
/// or if your app should process it normally.
/// If you are using a universal link URL, you will receive the callback in `application:continueUserActivity:restorationHandler:`
/// To learn more about universal links, see https://developer.apple.com/library/content/documentation/General/Conceptual/AppSearch/UniversalLinks.html
/// If you are using a native scheme URL, you will receive the callback in `application:openURL:options:`
/// To learn more about native url schemes, see https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Inter-AppCommunication/Inter-AppCommunication.html#//apple_ref/doc/uid/TP40007072-CH6-SW10
/// - Parameter url: The URL that you received in your app delegate
/// - Returns: YES if the URL is expected and will be handled by Stripe. NO otherwise.
@objc(handleStripeURLCallbackWithURL:) @discardableResult public static func handleURLCallback(
with url: URL
) -> Bool {
return StripeAPI.handleURLCallback(with: url)
}
/// Japanese users can enable JCB for Apple Pay by setting this to `YES`, after they have been approved by JCB.
/// The default value is NO.
/// @note JCB is only supported on iOS 10.1+
@objc public class var jcbPaymentNetworkSupported: Bool {
get {
return StripeAPI.jcbPaymentNetworkSupported
} set {
StripeAPI.jcbPaymentNetworkSupported = newValue
}
}
/// The SDK accepts Amex, Mastercard, Visa, and Discover for Apple Pay.
/// Set this property to enable other card networks in addition to these.
/// For example, `additionalEnabledApplePayNetworks = [.JCB]` enables JCB (note this requires onboarding from JCB and Stripe).
@objc public static var additionalEnabledApplePayNetworks: [PKPaymentNetwork] {
get {
return StripeAPI.additionalEnabledApplePayNetworks
} set {
StripeAPI.additionalEnabledApplePayNetworks = newValue
}
}
/// Whether or not this device is capable of using Apple Pay. This checks both
/// whether the device supports Apple Pay, as well as whether or not they have
/// stored Apple Pay cards on their device.
/// - Parameter paymentRequest: The return value of this method depends on the
/// `supportedNetworks` property of this payment request, which by default should be
/// `[.amex, .masterCard, .visa, .discover]`.
/// - Returns: whether or not the user is currently able to pay with Apple Pay.
@objc
public class func canSubmitPaymentRequest(_ paymentRequest: PKPaymentRequest) -> Bool {
return StripeAPI.canSubmitPaymentRequest(paymentRequest)
}
/// Whether or not this can make Apple Pay payments via a card network supported
/// by Stripe.
/// The Stripe supported Apple Pay card networks are:
/// American Express, Visa, Mastercard, Discover, Maestro.
/// Japanese users can enable JCB by setting `JCBPaymentNetworkSupported` to YES,
/// after they have been approved by JCB.
/// - Returns: YES if the device is currently able to make Apple Pay payments via one
/// of the supported networks. NO if the user does not have a saved card of a
/// supported type, or other restrictions prevent payment (such as parental controls).
@objc dynamic public class func deviceSupportsApplePay() -> Bool {
return StripeAPI.deviceSupportsApplePay()
}
/// A convenience method to build a `PKPaymentRequest` with sane default values.
/// You will still need to configure the `paymentSummaryItems` property to indicate
/// what the user is purchasing, as well as the optional `requiredShippingAddressFields`,
/// `requiredBillingAddressFields`, and `shippingMethods` properties to indicate
/// what contact information your application requires.
/// Note that this method sets the payment request's countryCode to "US" and its
/// currencyCode to "USD".
/// - Parameter merchantIdentifier: Your Apple Merchant ID.
/// - Returns: a `PKPaymentRequest` with proper default values. Returns nil if running on < iOS8.
/// @deprecated Use `paymentRequestWithMerchantIdentifier:country:currency:` instead.
/// Apple Pay is available in many countries and currencies, and you should use
/// the appropriate values for your business.
@available(
*, deprecated,
message: "Use `paymentRequestWithMerchantIdentifier:country:currency:` instead."
)
@objc public class func paymentRequest(withMerchantIdentifier merchantIdentifier: String)
-> PKPaymentRequest
{
return StripeAPI.paymentRequest(withMerchantIdentifier: merchantIdentifier)
}
/// A convenience method to build a `PKPaymentRequest` with sane default values.
/// You will still need to configure the `paymentSummaryItems` property to indicate
/// what the user is purchasing, as well as the optional `requiredShippingContactFields`,
/// `requiredBillingContactFields`, and `shippingMethods` properties to indicate
/// what additional contact information your application requires.
/// - Parameters:
/// - merchantIdentifier: Your Apple Merchant ID.
/// - countryCode: The two-letter code for the country where the payment
/// will be processed. This should be the country of your Stripe account.
/// - currencyCode: The three-letter code for the currency used by this
/// payment request. Apple Pay interprets the amounts provided by the summary items
/// attached to this request as amounts in this currency.
/// - Returns: a `PKPaymentRequest` with proper default values.
@objc public class func paymentRequest(
withMerchantIdentifier merchantIdentifier: String,
country countryCode: String,
currency currencyCode: String
) -> PKPaymentRequest {
return StripeAPI.paymentRequest(withMerchantIdentifier: merchantIdentifier, country: countryCode, currency: currencyCode)
}
}

View File

@ -7,6 +7,14 @@
objects = {
/* Begin PBXBuildFile section */
319E36582719EBF700460867 /* ServerErrorMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 319E36572719EBF700460867 /* ServerErrorMapper.swift */; };
31B49E9E26E951EB00A0464A /* STPAPIClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31B49E9D26E951EB00A0464A /* STPAPIClient.swift */; };
31B49EA026E9523700A0464A /* StripeAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31B49E9F26E9523700A0464A /* StripeAPI.swift */; };
31B49EA226E9528200A0464A /* STPAppInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31B49EA126E9528200A0464A /* STPAppInfo.swift */; };
31B49EA426E95DDA00A0464A /* STPURLCallbackHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31B49EA326E95DDA00A0464A /* STPURLCallbackHandler.swift */; };
31B49EA626E95E0600A0464A /* NSURLComponents+Stripe.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31B49EA526E95E0600A0464A /* NSURLComponents+Stripe.swift */; };
31B49EAC26E9838E00A0464A /* NSError+Stripe.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31B49EAB26E9838E00A0464A /* NSError+Stripe.swift */; };
31F9015D26FEA05200F9E11D /* STPError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31B49EA926E9821100A0464A /* STPError.swift */; };
6142353626E12272004E4B37 /* AnalyticLoggableError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6142353526E12272004E4B37 /* AnalyticLoggableError.swift */; };
619E233526E9419700E06F1C /* NSError_AnalyticLoggableErrorTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 619E233426E9419700E06F1C /* NSError_AnalyticLoggableErrorTest.swift */; };
E614ACA0268BE14B00C59B3D /* StripeAPIConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = E614AC96268BE14B00C59B3D /* StripeAPIConfiguration.swift */; };
@ -70,6 +78,14 @@
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
319E36572719EBF700460867 /* ServerErrorMapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerErrorMapper.swift; sourceTree = "<group>"; };
31B49E9D26E951EB00A0464A /* STPAPIClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = STPAPIClient.swift; sourceTree = "<group>"; };
31B49E9F26E9523700A0464A /* StripeAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StripeAPI.swift; sourceTree = "<group>"; };
31B49EA126E9528200A0464A /* STPAppInfo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPAppInfo.swift; sourceTree = "<group>"; };
31B49EA326E95DDA00A0464A /* STPURLCallbackHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = STPURLCallbackHandler.swift; sourceTree = "<group>"; };
31B49EA526E95E0600A0464A /* NSURLComponents+Stripe.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSURLComponents+Stripe.swift"; sourceTree = "<group>"; };
31B49EA926E9821100A0464A /* STPError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = STPError.swift; sourceTree = "<group>"; };
31B49EAB26E9838E00A0464A /* NSError+Stripe.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSError+Stripe.swift"; sourceTree = "<group>"; };
6142353526E12272004E4B37 /* AnalyticLoggableError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalyticLoggableError.swift; sourceTree = "<group>"; };
619E233426E9419700E06F1C /* NSError_AnalyticLoggableErrorTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSError_AnalyticLoggableErrorTest.swift; sourceTree = "<group>"; };
E614AC96268BE14B00C59B3D /* StripeAPIConfiguration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StripeAPIConfiguration.swift; sourceTree = "<group>"; };
@ -175,7 +191,10 @@
isa = PBXGroup;
children = (
E614AC96268BE14B00C59B3D /* StripeAPIConfiguration.swift */,
31B49E9D26E951EB00A0464A /* STPAPIClient.swift */,
31B49E9F26E9523700A0464A /* StripeAPI.swift */,
E6E38EE7268BE48300233B24 /* StripeAPIConfiguration+Version.swift */,
31B49EA126E9528200A0464A /* STPAppInfo.swift */,
E6E38EE9268BE69F00233B24 /* PublishableKeyProvider.swift */,
);
path = "API Bindings";
@ -195,6 +214,7 @@
E614AC9B268BE14B00C59B3D /* Categories */ = {
isa = PBXGroup;
children = (
31B49EA526E95E0600A0464A /* NSURLComponents+Stripe.swift */,
E61ADACA270E6146004ED998 /* NSArray+Stripe.swift */,
E614AC9C268BE14B00C59B3D /* NSBundle+Stripe_AppName.swift */,
E681E5652698EC9700692E45 /* NSError+StripeCore.swift */,
@ -210,6 +230,10 @@
E66784B026980677005F7CC8 /* BundleLocatorProtocol.swift */,
E6539B3F269E4D9200E05D26 /* STPDeviceUtils.swift */,
E66784AF26980677005F7CC8 /* StripeCoreBundleLocator.swift */,
31B49EA326E95DDA00A0464A /* STPURLCallbackHandler.swift */,
31B49EA926E9821100A0464A /* STPError.swift */,
319E36572719EBF700460867 /* ServerErrorMapper.swift */,
31B49EAB26E9838E00A0464A /* NSError+Stripe.swift */,
E614AC9F268BE14B00C59B3D /* URLEncoder.swift */,
);
path = Helpers;
@ -577,25 +601,33 @@
buildActionMask = 2147483647;
files = (
E6752D7826F413A00062B821 /* String+StripeCore.swift in Sources */,
319E36582719EBF700460867 /* ServerErrorMapper.swift in Sources */,
E6598C8F269615E000278740 /* STPLocalizedString.swift in Sources */,
E6598C8126952BC500278740 /* STPLocalizationUtils.swift in Sources */,
E614ACA5268BE14B00C59B3D /* NSMutableURLRequest+Stripe.swift in Sources */,
E6E38EE8268BE48300233B24 /* StripeAPIConfiguration+Version.swift in Sources */,
E6E38EEA268BE69F00233B24 /* PublishableKeyProvider.swift in Sources */,
31B49EAC26E9838E00A0464A /* NSError+Stripe.swift in Sources */,
31B49EA626E95E0600A0464A /* NSURLComponents+Stripe.swift in Sources */,
E6AF1ED7269FD8510091BE99 /* UIFont+Stripe.swift in Sources */,
31F9015D26FEA05200F9E11D /* STPError.swift in Sources */,
E6AF1EDB269FD9030091BE99 /* UIActivityIndicatorView+Stripe.swift in Sources */,
31B49EA426E95DDA00A0464A /* STPURLCallbackHandler.swift in Sources */,
E6A36A5F26BB404A002A4427 /* String+Localized.swift in Sources */,
E681E5662698EC9700692E45 /* NSError+StripeCore.swift in Sources */,
E66784B126980677005F7CC8 /* StripeCoreBundleLocator.swift in Sources */,
E614ACA0268BE14B00C59B3D /* StripeAPIConfiguration.swift in Sources */,
E61ADACB270E6146004ED998 /* NSArray+Stripe.swift in Sources */,
6142353626E12272004E4B37 /* AnalyticLoggableError.swift in Sources */,
31B49EA026E9523700A0464A /* StripeAPI.swift in Sources */,
E620C243269F9B210054DD6D /* STPDeviceUtils.swift in Sources */,
E614ACA3268BE14B00C59B3D /* STPAnalyticsClient.swift in Sources */,
31B49EA226E9528200A0464A /* STPAppInfo.swift in Sources */,
E66784B226980677005F7CC8 /* BundleLocatorProtocol.swift in Sources */,
E614ACA6268BE14B00C59B3D /* URLEncoder.swift in Sources */,
E614ACA4268BE14B00C59B3D /* NSBundle+Stripe_AppName.swift in Sources */,
E614ACA2268BE14B00C59B3D /* Analytic.swift in Sources */,
31B49E9E26E951EB00A0464A /* STPAPIClient.swift in Sources */,
E614ACA1268BE14B00C59B3D /* STPAnalyticEvent.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;

View File

@ -1,6 +1,33 @@
/* Text for close button */
"Close" = "Close";
/* An error message displayed when the customer's iban is invalid. */
"The IBAN you entered is invalid." = "The IBAN you entered is invalid.";
/* Error when there is a problem processing the credit card */
"There was an error processing your card -- try again in a few seconds" = "There was an error processing your card -- try again in a few seconds";
/* Unexpected error, such as a 500 from Stripe or a JSON parse error */
"There was an unexpected error -- try again in a few seconds" = "There was an unexpected error -- try again in a few seconds";
/* Error when the card has already expired */
"Your card has expired" = "Your card has expired";
/* Error when the card was declined by the credit card networks */
"Your card was declined" = "Your card was declined";
/* Error when the card's expiration month is not valid */
"Your card's expiration month is invalid" = "Your card's expiration month is invalid";
/* Error when the card's expiration year is not valid */
"Your card's expiration year is invalid" = "Your card's expiration year is invalid";
/* Error when the card number is not valid */
"Your card's number is invalid" = "Your card's number is invalid";
/* Error when the card's CVC is not valid */
"Your card's security code is invalid" = "Your card's security code is invalid";
/* Error when customer's name is invalid */
"Your name is invalid." = "Your name is invalid.";

View File

@ -0,0 +1,223 @@
//
// STPAPIClient.swift
// StripeExample
//
// Created by Jack Flintermann on 12/18/14.
// Copyright (c) 2014 Stripe. All rights reserved.
//
import Foundation
import UIKit
/// A client for making connections to the Stripe API.
public class STPAPIClient {
/// The current version of this library.
public static let STPSDKVersion = StripeAPIConfiguration.STPSDKVersion
/// A shared singleton API client.
/// By default, the SDK uses this instance to make API requests
/// eg in STPPaymentHandler, STPPaymentContext, STPCustomerContext, etc.
public static let shared: STPAPIClient = {
let client = STPAPIClient()
STPAnalyticsClient.sharedClient.publishableKeyProvider = client
return client
}()
/// The client's publishable key.
/// The default value is `StripeAPI.defaultPublishableKey`.
public var publishableKey: String? {
get {
if let publishableKey = _publishableKey {
return publishableKey
}
return StripeAPI.defaultPublishableKey
}
set {
_publishableKey = newValue
Self.validateKey(newValue)
}
}
var _publishableKey: String?
// Stored STPPaymentConfiguration: Type checking handled in STPAPIClient+Payments.swift
@_spi(STP) public var _stored_configuration: NSObject?
/// In order to perform API requests on behalf of a connected account, e.g. to
/// create a Source or Payment Method on a connected account, set this property to the ID of the
/// account for which this request is being made.
/// - seealso: https://stripe.com/docs/connect/authentication#authentication-via-the-stripe-account-header
public var stripeAccount: String?
/// Libraries wrapping the Stripe SDK should set this, so that Stripe can contact you about future issues or critical updates.
/// - seealso: https://stripe.com/docs/building-plugins#setappinfo
public var appInfo: STPAppInfo?
/// The API version used to communicate with Stripe.
public static let apiVersion = APIVersion
// MARK: Internal/private properties
@_spi(STP) public var apiURL: URL! = URL(string: APIBaseURL)
@_spi(STP) public var urlSession = URLSession(configuration: StripeAPIConfiguration.sharedUrlSessionConfiguration)
@_spi(STP) public var sourcePollers: [String: NSObject]?
@_spi(STP) public var sourcePollersQueue: DispatchQueue?
/// A set of beta headers to add to Stripe API requests e.g. `Set(["alipay_beta=v1"])`
var betas: Set<String> = []
/// Returns `true` if `publishableKey` is actually a user key, `false` otherwise.
@_spi(STP) public var publishableKeyIsUserKey: Bool {
return publishableKey?.hasPrefix("uk_") ?? false
}
// MARK: Initializers
public init() {
sourcePollers = [:]
sourcePollersQueue = DispatchQueue(label: "com.stripe.sourcepollers")
}
/// Initializes an API client with the given publishable key.
/// - Parameter publishableKey: The publishable key to use.
/// - Returns: An instance of STPAPIClient.
public convenience init(publishableKey: String) {
self.init()
self.publishableKey = publishableKey
}
@_spi(STP) public func configuredRequest(for url: URL, additionalHeaders: [String: String] = [:])
-> NSMutableURLRequest
{
let request = NSMutableURLRequest(url: url)
var headers = defaultHeaders()
for (k, v) in additionalHeaders { headers[k] = v } // additionalHeaders can overwrite defaultHeaders
headers.forEach { key, value in
request.setValue(value, forHTTPHeaderField: key)
}
return request
}
/// Headers common to all API requests for a given API Client.
func defaultHeaders() -> [String: String] {
var defaultHeaders: [String: String] = [:]
defaultHeaders["X-Stripe-User-Agent"] = STPAPIClient.stripeUserAgentDetails(with: appInfo)
var stripeVersion = APIVersion
for beta in betas {
stripeVersion = stripeVersion + "; \(beta)"
}
defaultHeaders["Stripe-Version"] = stripeVersion
defaultHeaders["Stripe-Account"] = stripeAccount
for (k, v) in authorizationHeader() { defaultHeaders[k] = v }
return defaultHeaders
}
// MARK: Helpers
static var didShowTestmodeKeyWarning = false
class func validateKey(_ publishableKey: String?) {
guard let publishableKey = publishableKey, !publishableKey.isEmpty else {
assertionFailure(
"You must use a valid publishable key. For more info, see https://stripe.com/docs/keys"
)
return
}
let secretKey = publishableKey.hasPrefix("sk_")
assert(
!secretKey,
"You are using a secret key. Use a publishable key instead. For more info, see https://stripe.com/docs/keys"
)
#if !DEBUG
if publishableKey.lowercased().hasPrefix("pk_test") && !didShowTestmodeKeyWarning {
print(
" You're using your Stripe testmode key. Make sure to use your livemode key when submitting to the App Store!"
)
didShowTestmodeKeyWarning = true
}
#endif
}
@_spi(STP) public static var paymentUserAgent: String {
var paymentUserAgent = "stripe-ios/\(STPAPIClient.STPSDKVersion)"
let components = [paymentUserAgent] + STPAnalyticsClient.sharedClient.productUsage
paymentUserAgent = components.joined(separator: "; ")
return paymentUserAgent
}
@_spi(STP) public class func paramsAddingPaymentUserAgent(_ params: [String: Any]) -> [String: Any] {
var newParams = params
newParams["payment_user_agent"] = Self.paymentUserAgent
return newParams
}
class func stripeUserAgentDetails(with appInfo: STPAppInfo?) -> String {
var details: [String: String] = [
"lang": "objective-c",
"bindings_version": STPSDKVersion,
]
let version = UIDevice.current.systemVersion
if version != "" {
details["os_version"] = version
}
var systemInfo = utsname()
uname(&systemInfo)
// Thanks to https://stackoverflow.com/questions/26028918/how-to-determine-the-current-iphone-device-model
let machineMirror = Mirror(reflecting: systemInfo.machine)
let deviceType = machineMirror.children.reduce("") { identifier, element in
guard let value = element.value as? Int8, value != 0 else { return identifier }
return identifier + String(UnicodeScalar(UInt8(value)))
}
details["type"] = deviceType
let model = UIDevice.current.localizedModel
if model != "" {
details["model"] = model
}
let vendorIdentifier = UIDevice.current.identifierForVendor?.uuidString
if let vendorIdentifier = vendorIdentifier {
details["vendor_identifier"] = vendorIdentifier
}
if let appInfo = appInfo {
details["name"] = appInfo.name
details["partner_id"] = appInfo.partnerId
if appInfo.version != nil {
details["version"] = appInfo.version
}
if appInfo.url != nil {
details["url"] = appInfo.url
}
}
let data = try? JSONSerialization.data(withJSONObject: details, options: [])
return String(data: data ?? Data(), encoding: .utf8) ?? ""
}
@_spi(STP) public func authorizationHeader(using ephemeralKeySecret: String? = nil) -> [String: String] {
var authorizationBearer = publishableKey ?? ""
if let ephemeralKeySecret = ephemeralKeySecret {
authorizationBearer = ephemeralKeySecret
}
var headers: [String: String] = [
"Authorization": "Bearer " + authorizationBearer
]
if publishableKeyIsUserKey {
if ProcessInfo.processInfo.environment["Stripe-Livemode"] == "false" {
headers["Stripe-Livemode"] = "false"
} else {
headers["Stripe-Livemode"] = "true"
}
}
return headers
}
@_spi(STP) public var isTestmode: Bool {
guard let publishableKey = publishableKey, !publishableKey.isEmpty else {
return false
}
return publishableKey.lowercased().hasPrefix("pk_test")
}
}
/// :nodoc:
@_spi(STP) extension STPAPIClient: PublishableKeyProvider { }
private let APIVersion = "2020-08-27"
private let APIBaseURL = "https://api.stripe.com/v1"

View File

@ -11,14 +11,13 @@ import Foundation
/// Libraries wrapping the Stripe SDK should use this object to provide information about the library, and set it
/// in on `STPAPIClient`. This information is passed to Stripe so that we can contact you about future issues or critical updates.
/// - seealso: https://stripe.com/docs/building-plugins#setappinfo
public class STPAppInfo: NSObject {
public class STPAppInfo {
/// Initializes an instance of `STPAppInfo`.
/// - Parameters:
/// - name: The name of your library (e.g. "MyAwesomeLibrary").
/// - partnerId: Your Stripe Partner ID (e.g. "pp_partner_1234"). Required for Stripe Verified Partners, optional otherwise.
/// - version: The version of your library (e.g. "1.2.34"). Optional.
/// - url: The website for your library (e.g. "https://myawesomelibrary.info"). Optional.
@objc
public init(
name: String,
partnerId: String?,
@ -29,15 +28,14 @@ public class STPAppInfo: NSObject {
self.partnerId = partnerId
self.version = version
self.url = url
super.init()
}
/// The name of your library (e.g. "MyAwesomeLibrary").
@objc public private(set) var name: String
public private(set) var name: String
/// Your Stripe Partner ID (e.g. "pp_partner_1234").
@objc public private(set) var partnerId: String?
public private(set) var partnerId: String?
/// The version of your library (e.g. "1.2.34").
@objc public private(set) var version: String?
public private(set) var version: String?
/// The website for your library (e.g. "https://myawesomelibrary.info").
@objc public private(set) var url: String?
public private(set) var url: String?
}

View File

@ -10,12 +10,12 @@ import Foundation
import PassKit
/// A top-level class that imports the rest of the Stripe SDK.
public class StripeAPI: NSObject {
public class StripeAPI {
/// Set this to your Stripe publishable API key, obtained from https://dashboard.stripe.com/apikeys.
/// Set this as early as possible in your application's lifecycle, preferably in your AppDelegate or SceneDelegate.
/// New instances of STPAPIClient will be initialized with this value.
/// @warning Make sure not to ship your test API keys to the App Store! This will log a warning if you use your test key in a release build.
@objc public static var defaultPublishableKey: String?
public static var defaultPublishableKey: String?
/// Set this to your Stripe publishable API key, obtained from https://dashboard.stripe.com/apikeys.
/// Set this as early as possible in your application's lifecycle, preferably in your AppDelegate or SceneDelegate.
@ -30,20 +30,20 @@ public class StripeAPI: NSObject {
/// For more details on the information we collect, visit https://stripe.com/docs/disputes/prevention/advanced-fraud-detection
/// Disabling this setting will reduce Stripe's ability to protect your business from fraudulent payments.
/// The default value is YES.
@objc public static var advancedFraudSignalsEnabled: Bool = true
public static var advancedFraudSignalsEnabled: Bool = true
/// If the SDK receives a "Too Many Requests" (429) status code from Stripe,
/// it will automatically retry the request.
/// The default value is 3.
/// See https://stripe.com/docs/rate-limits for more information.
@objc public static var maxRetries = 3
public static var maxRetries = 3
// MARK: - Apple Pay
/// Japanese users can enable JCB for Apple Pay by setting this to `YES`, after they have been approved by JCB.
/// The default value is NO.
/// @note JCB is only supported on iOS 10.1+
@objc public class var jcbPaymentNetworkSupported: Bool {
public class var jcbPaymentNetworkSupported: Bool {
get {
if #available(iOS 10.1, *) {
return self.additionalEnabledApplePayNetworks.contains(.JCB)
@ -71,7 +71,7 @@ public class StripeAPI: NSObject {
/// The SDK accepts Amex, Mastercard, Visa, and Discover for Apple Pay.
/// Set this property to enable other card networks in addition to these.
/// For example, `additionalEnabledApplePayNetworks = [.JCB]` enables JCB (note this requires onboarding from JCB and Stripe).
@objc public static var additionalEnabledApplePayNetworks: [PKPaymentNetwork] = []
public static var additionalEnabledApplePayNetworks: [PKPaymentNetwork] = []
/// Whether or not this device is capable of using Apple Pay. This checks both
/// whether the device supports Apple Pay, as well as whether or not they have
@ -80,7 +80,6 @@ public class StripeAPI: NSObject {
/// `supportedNetworks` property of this payment request, which by default should be
/// `[.amex, .masterCard, .visa, .discover]`.
/// - Returns: whether or not the user is currently able to pay with Apple Pay.
@objc
public class func canSubmitPaymentRequest(_ paymentRequest: PKPaymentRequest) -> Bool {
if !self.deviceSupportsApplePay() {
return false
@ -96,7 +95,7 @@ public class StripeAPI: NSObject {
}
}
@objc class func supportedPKPaymentNetworks() -> [PKPaymentNetwork] {
class func supportedPKPaymentNetworks() -> [PKPaymentNetwork] {
var additionalOSSupportedNetworks: [PKPaymentNetwork] = []
if #available(iOS 12.0, *) {
additionalOSSupportedNetworks.append(.maestro)
@ -118,35 +117,11 @@ public class StripeAPI: NSObject {
/// - Returns: YES if the device is currently able to make Apple Pay payments via one
/// of the supported networks. NO if the user does not have a saved card of a
/// supported type, or other restrictions prevent payment (such as parental controls).
@objc dynamic public class func deviceSupportsApplePay() -> Bool {
public class func deviceSupportsApplePay() -> Bool {
return PKPaymentAuthorizationController.canMakePayments(
usingNetworks: self.supportedPKPaymentNetworks())
}
/// A convenience method to build a `PKPaymentRequest` with sane default values.
/// You will still need to configure the `paymentSummaryItems` property to indicate
/// what the user is purchasing, as well as the optional `requiredShippingAddressFields`,
/// `requiredBillingAddressFields`, and `shippingMethods` properties to indicate
/// what contact information your application requires.
/// Note that this method sets the payment request's countryCode to "US" and its
/// currencyCode to "USD".
/// - Parameter merchantIdentifier: Your Apple Merchant ID.
/// - Returns: a `PKPaymentRequest` with proper default values. Returns nil if running on < iOS8.
/// @deprecated Use `paymentRequestWithMerchantIdentifier:country:currency:` instead.
/// Apple Pay is available in many countries and currencies, and you should use
/// the appropriate values for your business.
@available(
*, deprecated,
message: "Use `paymentRequestWithMerchantIdentifier:country:currency:` instead."
)
@objc
public class func paymentRequest(withMerchantIdentifier merchantIdentifier: String)
-> PKPaymentRequest
{
return self.paymentRequest(
withMerchantIdentifier: merchantIdentifier, country: "US", currency: "USD")
}
/// A convenience method to build a `PKPaymentRequest` with sane default values.
/// You will still need to configure the `paymentSummaryItems` property to indicate
/// what the user is purchasing, as well as the optional `requiredShippingContactFields`,
@ -160,7 +135,6 @@ public class StripeAPI: NSObject {
/// payment request. Apple Pay interprets the amounts provided by the summary items
/// attached to this request as amounts in this currency.
/// - Returns: a `PKPaymentRequest` with proper default values.
@objc
public class func paymentRequest(
withMerchantIdentifier merchantIdentifier: String,
country countryCode: String,
@ -190,117 +164,9 @@ public class StripeAPI: NSObject {
/// To learn more about native url schemes, see https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Inter-AppCommunication/Inter-AppCommunication.html#//apple_ref/doc/uid/TP40007072-CH6-SW10
/// - Parameter url: The URL that you received in your app delegate
/// - Returns: YES if the URL is expected and will be handled by Stripe. NO otherwise.
@objc(handleStripeURLCallbackWithURL:) @discardableResult public static func handleURLCallback(
@discardableResult public static func handleURLCallback(
with url: URL
) -> Bool {
return STPURLCallbackHandler.shared().handleURLCallback(url)
}
}
// MARK: Deprecated top-level Stripe functions.
// These are included so Xcode can offer guidance on how to replace top-level Stripe usage.
/// :nodoc:
@available(
*, deprecated,
message:
"Use StripeAPI.defaultPublishableKey instead. (StripeAPI.defaultPublishableKey = \"pk_12345_xyzabc\")"
)
public func setDefaultPublishableKey(_ publishableKey: String) {
StripeAPI.defaultPublishableKey = publishableKey
}
/// :nodoc:
@available(
*, deprecated,
message: "Use StripeAPI.advancedFraudSignalsEnabled instead."
)
public var advancedFraudSignalsEnabled: Bool {
get {
StripeAPI.advancedFraudSignalsEnabled
}
set {
StripeAPI.advancedFraudSignalsEnabled = newValue
}
}
/// :nodoc:
@available(
*, deprecated,
message: "Use StripeAPI.jcbPaymentNetworkSupported instead."
)
public var jcbPaymentNetworkSupported: Bool {
get {
StripeAPI.jcbPaymentNetworkSupported
}
set {
StripeAPI.jcbPaymentNetworkSupported = newValue
}
}
/// :nodoc:
@available(
*, deprecated,
message: "Use StripeAPI.additionalEnabledApplePayNetworks instead."
)
public var additionalEnabledApplePayNetworks: [PKPaymentNetwork] {
get {
StripeAPI.additionalEnabledApplePayNetworks
}
set {
StripeAPI.additionalEnabledApplePayNetworks = newValue
}
}
/// :nodoc:
@available(
*, deprecated,
message: "Use StripeAPI.canSubmitPaymentRequest(_:) instead."
)
public func canSubmitPaymentRequest(_ paymentRequest: PKPaymentRequest) -> Bool {
return StripeAPI.canSubmitPaymentRequest(paymentRequest)
}
/// :nodoc:
@available(
*, deprecated,
message: "Use StripeAPI.deviceSupportsApplePay() instead."
)
public func deviceSupportsApplePay() -> Bool {
return StripeAPI.deviceSupportsApplePay()
}
/// :nodoc:
@available(
*, deprecated,
message: "Use StripeAPI.paymentRequest(withMerchantIdentifier:country:currency:) instead."
)
public func paymentRequest(
withMerchantIdentifier merchantIdentifier: String,
country countryCode: String,
currency currencyCode: String
) -> PKPaymentRequest {
return StripeAPI.paymentRequest(
withMerchantIdentifier: merchantIdentifier, country: countryCode, currency: currencyCode)
}
/// :nodoc:
@available(
*, deprecated,
message: "Use StripeAPI.paymentRequest(withMerchantIdentifier:country:currency:) instead."
)
func paymentRequest(withMerchantIdentifier merchantIdentifier: String)
-> PKPaymentRequest
{
return StripeAPI.paymentRequest(
withMerchantIdentifier: merchantIdentifier, country: "US", currency: "USD")
}
/// :nodoc:
@available(
*, deprecated,
message: "Use StripeAPI.handleURLCallback(with:) instead."
)
public func handleURLCallback(with url: URL) -> Bool {
return StripeAPI.handleURLCallback(with: url)
}

View File

@ -7,10 +7,9 @@
//
import Foundation
@_spi(STP) import StripeCore
extension NSError {
@objc class func stp_genericConnectionError() -> NSError {
@objc @_spi(STP) public class func stp_genericConnectionError() -> NSError {
let userInfo = [
NSLocalizedDescriptionKey: self.stp_unexpectedErrorMessage(),
STPError.errorMessageKey: "There was an error connecting to Stripe.",
@ -21,7 +20,7 @@ extension NSError {
)
}
@objc class func stp_genericFailedToParseResponseError() -> NSError {
@objc @_spi(STP) public class func stp_genericFailedToParseResponseError() -> NSError {
let userInfo = [
NSLocalizedDescriptionKey: self.stp_unexpectedErrorMessage(),
STPError.errorMessageKey:
@ -31,7 +30,7 @@ extension NSError {
domain: STPError.stripeDomain, code: STPErrorCode.apiError.rawValue, userInfo: userInfo)
}
@objc class func stp_ephemeralKeyDecodingError() -> NSError {
@objc @_spi(STP) public class func stp_ephemeralKeyDecodingError() -> NSError {
let userInfo = [
NSLocalizedDescriptionKey: self.stp_unexpectedErrorMessage(),
STPError.errorMessageKey:
@ -42,7 +41,7 @@ extension NSError {
userInfo: userInfo)
}
@objc class func stp_clientSecretError() -> NSError {
@objc @_spi(STP) public class func stp_clientSecretError() -> NSError {
let userInfo = [
NSLocalizedDescriptionKey: self.stp_unexpectedErrorMessage(),
STPError.errorMessageKey:
@ -53,6 +52,8 @@ extension NSError {
userInfo: userInfo)
}
// TODO(davide): We'll want to move these into StripePayments, once it exists.
// MARK: Strings
@objc class func stp_cardErrorInvalidNumberUserMessage() -> String {
return STPLocalizedString(
@ -101,7 +102,7 @@ extension NSError {
)
}
static var stp_invalidBankAccountIban: String {
@_spi(STP) public static var stp_invalidBankAccountIban: String {
return STPLocalizedString(
"The IBAN you entered is invalid.",
"An error message displayed when the customer's iban is invalid."

View File

@ -7,72 +7,72 @@
//
import Foundation
@_spi(STP) import StripeCore
// These must line up with the codes in _stpobjc_STPError.swift.
/// Possible error code values for NSErrors with the `StripeDomain` domain
@objc public enum STPErrorCode: Int {
public enum STPErrorCode: Int {
/// Trouble connecting to Stripe.
@objc(STPConnectionError) case connectionError = 40
case connectionError = 40
/// Your request had invalid parameters.
@objc(STPInvalidRequestError) case invalidRequestError = 50
case invalidRequestError = 50
/// General-purpose API error.
@objc(STPAPIError) case apiError = 60
case apiError = 60
/// Something was wrong with the given card details.
@objc(STPCardError) case cardError = 70
case cardError = 70
/// The operation was cancelled.
@objc(STPCancellationError) case cancellationError = 80
case cancellationError = 80
/// The ephemeral key could not be decoded. Make sure your backend is sending
/// the unmodified JSON of the ephemeral key to your app.
/// https://stripe.com/docs/mobile/ios/standard#prepare-your-api
@objc(STPEphemeralKeyDecodingError) case ephemeralKeyDecodingError = 1000
case ephemeralKeyDecodingError = 1000
}
// MARK: - STPError
/// Top-level class for Stripe error constants.
public class STPError: NSObject {
public class STPError {
// MARK: userInfo keys
/// All Stripe iOS errors will be under this domain.
@objc public static let stripeDomain = "com.stripe.lib"
public static let stripeDomain = "com.stripe.lib"
/// A human-readable message providing more details about the error.
/// For card errors, these messages can be shown to your users.
/// - seealso: https://stripe.com/docs/api/errors#errors-message
@objc public static let errorMessageKey = "com.stripe.lib:ErrorMessageKey"
public static let errorMessageKey = "com.stripe.lib:ErrorMessageKey"
/// An SDK-supplied "hint" that is intended to help you, the developer, fix the error
@objc public static let hintKey = "com.stripe.lib:hintKey"
public static let hintKey = "com.stripe.lib:hintKey"
/// What went wrong with your STPCard (e.g., STPInvalidCVC. See below for full list).
@objc public static let cardErrorCodeKey = "com.stripe.lib:CardErrorCodeKey"
public static let cardErrorCodeKey = "com.stripe.lib:CardErrorCodeKey"
/// Which parameter on the STPCard had an error (e.g., "cvc"). Useful for marking up the
/// right UI element.
@objc public static let errorParameterKey = "com.stripe.lib:ErrorParameterKey"
public static let errorParameterKey = "com.stripe.lib:ErrorParameterKey"
/// The error code returned by the Stripe API.
/// - seealso: https://stripe.com/docs/api#errors-code
/// - seealso: https://stripe.com/docs/error-codes
@objc public static let stripeErrorCodeKey = "com.stripe.lib:StripeErrorCodeKey"
public static let stripeErrorCodeKey = "com.stripe.lib:StripeErrorCodeKey"
/// The error type returned by the Stripe API.
/// - seealso: https://stripe.com/docs/api#errors-type
@objc public static let stripeErrorTypeKey = "com.stripe.lib:StripeErrorTypeKey"
public static let stripeErrorTypeKey = "com.stripe.lib:StripeErrorTypeKey"
/// If the value of `userInfo[stripeErrorCodeKey]` is `STPError.cardDeclined`,
/// the value for this key contains the decline code.
/// - seealso: https://stripe.com/docs/declines/codes
@objc public static let stripeDeclineCodeKey = "com.stripe.lib:DeclineCodeKey"
public static let stripeDeclineCodeKey = "com.stripe.lib:DeclineCodeKey"
}
/// NSError extensions for creating error objects from Stripe API responses.
@objc extension NSError {
static func stp_error(
extension NSError {
@_spi(STP) public static func stp_error(
fromStripeResponse jsonDictionary: [AnyHashable: Any]?, httpResponse: HTTPURLResponse?
) -> NSError? {
guard let dict = (jsonDictionary as NSDictionary?),
let errorDictionary = dict.stp_dictionary(forKey: "error") as NSDictionary?
let errorDictionary = dict["error"] as? NSDictionary
else {
return nil
}
let errorType = errorDictionary.stp_string(forKey: "type")
let errorParam = errorDictionary.stp_string(forKey: "param")
let stripeErrorMessage = errorDictionary.stp_string(forKey: "message")
let stripeErrorCode = errorDictionary.stp_string(forKey: "code")
let errorType = errorDictionary["type"] as? String
let errorParam = errorDictionary["param"] as? String
let stripeErrorMessage = errorDictionary["message"] as? String
let stripeErrorCode = errorDictionary["code"] as? String
var code = 0
var userInfo: [AnyHashable: Any] = [

View File

@ -8,18 +8,24 @@
import Foundation
@objc protocol STPURLCallbackListener: NSObjectProtocol {
/// :nodoc:
@_spi(STP) @objc public protocol STPURLCallbackListener: NSObjectProtocol {
/// :nodoc:
func handleURLCallback(_ url: URL) -> Bool
}
class STPURLCallbackHandler: NSObject {
static var sharedHandler: STPURLCallbackHandler = STPURLCallbackHandler()
/// :nodoc:
@_spi(STP) public class STPURLCallbackHandler: NSObject {
/// :nodoc:
@_spi(STP) public static var sharedHandler: STPURLCallbackHandler = STPURLCallbackHandler()
@objc class func shared() -> STPURLCallbackHandler {
/// :nodoc:
@objc @_spi(STP) public class func shared() -> STPURLCallbackHandler {
return sharedHandler
}
@objc @discardableResult func handleURLCallback(_ url: URL) -> Bool {
/// :nodoc:
@objc @discardableResult @_spi(STP) public func handleURLCallback(_ url: URL) -> Bool {
guard
let components = NSURLComponents(
url: url,
@ -41,7 +47,8 @@ class STPURLCallbackHandler: NSObject {
return resultsOrred
}
@objc(registerListener:forURL:) func register(
/// :nodoc:
@objc(registerListener:forURL:) @_spi(STP) public func register(
_ listener: STPURLCallbackListener,
for url: URL
) {
@ -59,7 +66,8 @@ class STPURLCallbackHandler: NSObject {
callbacks = callbacksCopy
}
@objc func unregisterListener(_ listener: STPURLCallbackListener) {
/// :nodoc:
@objc @_spi(STP) public func unregisterListener(_ listener: STPURLCallbackListener) {
var callbacksToRemove: [AnyHashable] = []
for callback in callbacks {

View File

@ -9,7 +9,7 @@
import Foundation
import OHHTTPStubs
@testable import Stripe
@testable import StripeCore
@testable @_spi(STP) import StripeCore
/* A test case offering a custom STPAPIClient with manual JSON stubbing. */
class APIStubbedTestCase: XCTestCase {

View File

@ -63,8 +63,6 @@
NSString *testKey = @"pk_test_123";
StripeAPI.defaultPublishableKey = testKey;
XCTAssertEqualObjects(testKey, StripeAPI.defaultPublishableKey);
STPAPIClient *client = [[STPAPIClient alloc] init];
XCTAssertEqualObjects(testKey, client.publishableKey);
StripeAPI.defaultPublishableKey = nil;
}

View File

@ -13,7 +13,7 @@ import Foundation
import OHHTTPStubs
@available(iOS 13.0, *)
class STPApplePayContextFunctionalTestAPIClient: STPAPIClient {
class STPApplePayContextFunctionalTestAPIClient: _stpobjc_STPAPIClient {
@objc var applePayContext: STPApplePayContext
@objc var shouldSimulateCancelAfterConfirmBegins: Bool = false

View File

@ -8,6 +8,7 @@
import XCTest
@testable import Stripe
@testable import StripeCore
class ServerErrorMapperTest: XCTestCase {