From bc769a815d5e30f52e2d739116b87438190836dd Mon Sep 17 00:00:00 2001 From: Shengwei Wu Date: Thu, 14 May 2020 22:35:51 +0800 Subject: [PATCH 1/6] Add EPS PaymentMethod --- Stripe.xcodeproj/project.pbxproj | 28 ++++++++++ Stripe/Payments/STPPaymentHandler.m | 1 + Stripe/PublicHeaders/STPPaymentMethod.h | 6 +++ Stripe/PublicHeaders/STPPaymentMethodEnums.h | 7 ++- Stripe/PublicHeaders/STPPaymentMethodParams.h | 6 +++ Stripe/PublicHeaders/Stripe.h | 2 + Stripe/STPPaymentMethod.m | 8 +++ Stripe/STPPaymentMethodEPS.h | 36 +++++++++++++ Stripe/STPPaymentMethodEPS.m | 51 +++++++++++++++++++ Stripe/STPPaymentMethodEPSParams.h | 22 ++++++++ Stripe/STPPaymentMethodEPSParams.m | 28 ++++++++++ Stripe/STPPaymentMethodParams.m | 25 +++++++++ 12 files changed, 219 insertions(+), 1 deletion(-) create mode 100644 Stripe/STPPaymentMethodEPS.h create mode 100644 Stripe/STPPaymentMethodEPS.m create mode 100644 Stripe/STPPaymentMethodEPSParams.h create mode 100644 Stripe/STPPaymentMethodEPSParams.m diff --git a/Stripe.xcodeproj/project.pbxproj b/Stripe.xcodeproj/project.pbxproj index d867271c8ea..b66daf1033f 100644 --- a/Stripe.xcodeproj/project.pbxproj +++ b/Stripe.xcodeproj/project.pbxproj @@ -754,6 +754,12 @@ 448895AC2452456800F7D0C2 /* STPPaymentMethodPrzelewy24Params.m in Sources */ = {isa = PBXBuildFile; fileRef = 448895A4245244FE00F7D0C2 /* STPPaymentMethodPrzelewy24Params.m */; }; 448895AF245255D800F7D0C2 /* STPPaymentMethodPrzelewy24ParamsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 448895AE245255D800F7D0C2 /* STPPaymentMethodPrzelewy24ParamsTests.m */; }; 448895B1245262E500F7D0C2 /* STPPaymentMethodPrzelewy24Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 448895B0245262E500F7D0C2 /* STPPaymentMethodPrzelewy24Tests.m */; }; + 69A6C2F8246D4A66005FF304 /* STPPaymentMethodEPS.h in Headers */ = {isa = PBXBuildFile; fileRef = 69A6C2F7246D4A66005FF304 /* STPPaymentMethodEPS.h */; }; + 69A6C2FA246D4AA0005FF304 /* STPPaymentMethodEPS.m in Sources */ = {isa = PBXBuildFile; fileRef = 69A6C2F9246D4AA0005FF304 /* STPPaymentMethodEPS.m */; }; + 69A6C2FC246D7869005FF304 /* STPPaymentMethodEPSParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 69A6C2FB246D7869005FF304 /* STPPaymentMethodEPSParams.h */; }; + 69A6C2FE246D788D005FF304 /* STPPaymentMethodEPSParams.m in Sources */ = {isa = PBXBuildFile; fileRef = 69A6C2FD246D788D005FF304 /* STPPaymentMethodEPSParams.m */; }; + 69A6C2FF246D8834005FF304 /* STPPaymentMethodEPS.m in Headers */ = {isa = PBXBuildFile; fileRef = 69A6C2F9246D4AA0005FF304 /* STPPaymentMethodEPS.m */; }; + 69A6C300246D8834005FF304 /* STPPaymentMethodEPSParams.m in Headers */ = {isa = PBXBuildFile; fileRef = 69A6C2FD246D788D005FF304 /* STPPaymentMethodEPSParams.m */; }; 8B013C891F1E784A00DD831B /* STPPaymentConfigurationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B013C881F1E784A00DD831B /* STPPaymentConfigurationTest.m */; }; 8B39128220E2F99600098401 /* EPSSource.json in Resources */ = {isa = PBXBuildFile; fileRef = 8B39128120E2F99600098401 /* EPSSource.json */; }; 8B39128320E2F9A100098401 /* BancontactSource.json in Resources */ = {isa = PBXBuildFile; fileRef = 8B39127F20E2F6A500098401 /* BancontactSource.json */; }; @@ -2001,6 +2007,10 @@ 448895AE245255D800F7D0C2 /* STPPaymentMethodPrzelewy24ParamsTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STPPaymentMethodPrzelewy24ParamsTests.m; sourceTree = ""; }; 448895B0245262E500F7D0C2 /* STPPaymentMethodPrzelewy24Tests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STPPaymentMethodPrzelewy24Tests.m; sourceTree = ""; }; 4A0D74F918F6106100966D7B /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; + 69A6C2F7246D4A66005FF304 /* STPPaymentMethodEPS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = STPPaymentMethodEPS.h; sourceTree = ""; }; + 69A6C2F9246D4AA0005FF304 /* STPPaymentMethodEPS.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STPPaymentMethodEPS.m; sourceTree = ""; }; + 69A6C2FB246D7869005FF304 /* STPPaymentMethodEPSParams.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = STPPaymentMethodEPSParams.h; sourceTree = ""; }; + 69A6C2FD246D788D005FF304 /* STPPaymentMethodEPSParams.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STPPaymentMethodEPSParams.m; sourceTree = ""; }; 7E0B1132203572FB00271AD3 /* fi */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = fi; path = Localizations/fi.lproj/Localizable.strings; sourceTree = ""; }; 8B013C881F1E784A00DD831B /* STPPaymentConfigurationTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = STPPaymentConfigurationTest.m; sourceTree = ""; }; 8B39127F20E2F6A500098401 /* BancontactSource.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = BancontactSource.json; sourceTree = ""; }; @@ -2739,6 +2749,7 @@ 3626615F23C8F9CA00B13AE0 /* PaymentMethods */ = { isa = PBXGroup; children = ( + 69A6C301246D8BD2005FF304 /* EPS */, 3666589F240F177400D00354 /* AU BECS Debit */, B656293023E10F6300458A8E /* Bacs Debit */, 3626616523C9048500B13AE0 /* Card */, @@ -3167,6 +3178,17 @@ name = Przelewy24; sourceTree = ""; }; + 69A6C301246D8BD2005FF304 /* EPS */ = { + isa = PBXGroup; + children = ( + 69A6C2F7246D4A66005FF304 /* STPPaymentMethodEPS.h */, + 69A6C2F9246D4AA0005FF304 /* STPPaymentMethodEPS.m */, + 69A6C2FB246D7869005FF304 /* STPPaymentMethodEPSParams.h */, + 69A6C2FD246D788D005FF304 /* STPPaymentMethodEPSParams.m */, + ); + name = EPS; + sourceTree = ""; + }; 8BD2133A1F0458B7007F6FD1 /* Source */ = { isa = PBXGroup; children = ( @@ -4177,6 +4199,7 @@ B640DB1722C69A8E003C8810 /* STPSetupIntent+Private.h in Headers */, 049A3F7A1CC18D5300F57DE7 /* UIView+Stripe_FirstResponder.h in Headers */, 04CDB50E1A5F30A700B854EE /* STPCard.h in Headers */, + 69A6C2F8246D4A66005FF304 /* STPPaymentMethodEPS.h in Headers */, C1BD9B391E39416700CEE925 /* STPSourceOwner.h in Headers */, C1080F491CBECF7B007B2D89 /* STPAddress.h in Headers */, B604CF2122C56E9B00A23CC4 /* STPIntentActionRedirectToURL.h in Headers */, @@ -4295,6 +4318,8 @@ 315CB8DE22E7D96100E612A3 /* STDSNotInitializedException.h in Headers */, 315CB8DF22E7D96100E612A3 /* STDSConfigParameters.h in Headers */, 315CB8E022E7D96100E612A3 /* STDSStripe3DS2Error.h in Headers */, + 69A6C2FF246D8834005FF304 /* STPPaymentMethodEPS.m in Headers */, + 69A6C300246D8834005FF304 /* STPPaymentMethodEPSParams.m in Headers */, 04CDB5021A5F30A700B854EE /* STPFormEncoder.h in Headers */, C1CFCB671ED4E38900BE45DF /* STPInternalAPIResponseDecodable.h in Headers */, 04695ADB1C77F9EF00E08063 /* STPPhoneNumberValidator.h in Headers */, @@ -4310,6 +4335,7 @@ 04E39F541CECF7A100AF3B96 /* STPPaymentOptionTuple.h in Headers */, 3604007422C18C78004CF80B /* STPThreeDSSelectionCustomization.h in Headers */, 3604007522C18C78004CF80B /* STPThreeDSTextFieldCustomization.h in Headers */, + 69A6C2FC246D7869005FF304 /* STPPaymentMethodEPSParams.h in Headers */, 36B6CB9C235A3CF300331C38 /* STPMandateCustomerAcceptanceParams.h in Headers */, F15232241EA9303800D65C67 /* STPURLCallbackHandler.h in Headers */, C18410761EC2529400178149 /* STPEphemeralKeyManager.h in Headers */, @@ -5367,6 +5393,7 @@ 045D71101CEEE30500F6CD65 /* STPAspects.m in Sources */, F152321D1EA92FC100D65C67 /* STPRedirectContext.m in Sources */, 36B8DDEB241AEB5400BB908E /* STPAUBECSFormViewModel.m in Sources */, + 69A6C2FE246D788D005FF304 /* STPPaymentMethodEPSParams.m in Sources */, 0413CB24233FECD5006429EA /* STPPushProvisioningDetailsParams.m in Sources */, B32B176020F6D2C4000D6EF8 /* STPGenericStripeObject.m in Sources */, B621F055223454E9002141B7 /* STPPaymentMethodCardWallet.m in Sources */, @@ -5481,6 +5508,7 @@ C124A17E1CCAA0C2007D42EE /* NSMutableURLRequest+Stripe.m in Sources */, 36E8B98E2413159B007546C1 /* STPNumericStringValidator.m in Sources */, 04695ADA1C77F9EF00E08063 /* STPDelegateProxy.m in Sources */, + 69A6C2FA246D4AA0005FF304 /* STPPaymentMethodEPS.m in Sources */, B664D65722B817C800E6354B /* STPThreeDSFooterCustomization.m in Sources */, 36B6CB55234BD59F00331C38 /* STPPaymentMethodSEPADebitParams.m in Sources */, B621F05B22346243002141B7 /* STPPaymentMethodCardWalletMasterpass.m in Sources */, diff --git a/Stripe/Payments/STPPaymentHandler.m b/Stripe/Payments/STPPaymentHandler.m index 87e1239c1be..28724b06dde 100644 --- a/Stripe/Payments/STPPaymentHandler.m +++ b/Stripe/Payments/STPPaymentHandler.m @@ -314,6 +314,7 @@ + (BOOL)_isProcessingIntentSuccessForType:(STPPaymentMethodType)type { case STPPaymentMethodTypeFPX: case STPPaymentMethodTypeCardPresent: case STPPaymentMethodTypeGiropay: + case STPPaymentMethodTypeEPS: case STPPaymentMethodTypePrzelewy24: // fall through case STPPaymentMethodTypeUnknown: diff --git a/Stripe/PublicHeaders/STPPaymentMethod.h b/Stripe/PublicHeaders/STPPaymentMethod.h index eb31fbbc057..beb29f98548 100644 --- a/Stripe/PublicHeaders/STPPaymentMethod.h +++ b/Stripe/PublicHeaders/STPPaymentMethod.h @@ -17,6 +17,7 @@ STPPaymentMethodBacsDebit, STPPaymentMethodBillingDetails, STPPaymentMethodCard, STPPaymentMethodCardPresent, +STPPaymentMethodEPS, STPPaymentMethodFPX, STPPaymentMethodGiropay, STPPaymentMethodiDEAL, @@ -98,6 +99,11 @@ NS_ASSUME_NONNULL_BEGIN */ @property (nonatomic, nullable, readonly) STPPaymentMethodGiropay *giropay; +/** + If this is an EPS PaymentMethod (i.e. `self.type == STPPaymentMethodTypeEPS`), this contains additional details. + */ +@property (nonatomic, nullable, readonly) STPPaymentMethodEPS *EPS; + /** If this is a Przelewy24 PaymentMethod (i.e. `self.type == STPPaymentMethodTypePrzelewy24`), this contains additional details. */ diff --git a/Stripe/PublicHeaders/STPPaymentMethodEnums.h b/Stripe/PublicHeaders/STPPaymentMethodEnums.h index 4ac2770419f..0fcf5c250ef 100644 --- a/Stripe/PublicHeaders/STPPaymentMethodEnums.h +++ b/Stripe/PublicHeaders/STPPaymentMethodEnums.h @@ -54,7 +54,12 @@ typedef NS_ENUM(NSUInteger, STPPaymentMethodType) { A Przelewy24 Debit payment method. */ STPPaymentMethodTypePrzelewy24, - + + /** + An EPS payment method. + */ + STPPaymentMethodTypeEPS, + /** An unknown type. */ diff --git a/Stripe/PublicHeaders/STPPaymentMethodParams.h b/Stripe/PublicHeaders/STPPaymentMethodParams.h index 549cc8858ba..8a2ec351a74 100644 --- a/Stripe/PublicHeaders/STPPaymentMethodParams.h +++ b/Stripe/PublicHeaders/STPPaymentMethodParams.h @@ -17,6 +17,7 @@ STPPaymentMethodBacsDebitParams, STPPaymentMethodAUBECSDebitParams, STPPaymentMethodBillingDetails, STPPaymentMethodCardParams, +STPPaymentMethodEPSParams, STPPaymentMethodFPXParams, STPPaymentMethodGiropayParams, STPPaymentMethodiDEALParams, @@ -96,6 +97,11 @@ NS_ASSUME_NONNULL_BEGIN */ @property (nonatomic, nullable) STPPaymentMethodPrzelewy24Params *przelewy24; +/** + If this is an EPS PaymentMethod, this contains additional details. +*/ +@property (nonatomic, nullable) STPPaymentMethodEPSParams *eps; + /** Set of key-value pairs that you can attach to the PaymentMethod. This can be useful for storing additional information about the PaymentMethod in a structured format. */ diff --git a/Stripe/PublicHeaders/Stripe.h b/Stripe/PublicHeaders/Stripe.h index 3ce1c504407..b7508b59e99 100644 --- a/Stripe/PublicHeaders/Stripe.h +++ b/Stripe/PublicHeaders/Stripe.h @@ -88,6 +88,8 @@ #import "STPPaymentMethodEnums.h" #import "STPPaymentMethodiDEAL.h" #import "STPPaymentMethodiDEALParams.h" +#import "STPPaymentMethodEPS.h" +#import "STPPaymentMethodEPSParams.h" #import "STPPaymentMethodFPX.h" #import "STPPaymentMethodFPXParams.h" #import "STPPaymentMethodGiropay.h" diff --git a/Stripe/STPPaymentMethod.m b/Stripe/STPPaymentMethod.m index 0942e271981..d08811cfbf4 100644 --- a/Stripe/STPPaymentMethod.m +++ b/Stripe/STPPaymentMethod.m @@ -16,6 +16,7 @@ #import "STPPaymentMethodBillingDetails.h" #import "STPPaymentMethodCard.h" #import "STPPaymentMethodCardPresent.h" +#import "STPPaymentMethodEPS.h" #import "STPPaymentMethodFPX.h" #import "STPPaymentMethodGiropay.h" #import "STPPaymentMethodiDEAL.h" @@ -37,6 +38,7 @@ @interface STPPaymentMethod () @property (nonatomic, strong, nullable, readwrite) STPPaymentMethodSEPADebit *sepaDebit; @property (nonatomic, strong, nullable, readwrite) STPPaymentMethodAUBECSDebit *auBECSDebit; @property (nonatomic, strong, nullable, readwrite) STPPaymentMethodGiropay *giropay; +@property (nonatomic, strong, nullable, readwrite) STPPaymentMethodEPS *EPS; @property (nonatomic, strong, nullable, readwrite) STPPaymentMethodPrzelewy24 *przelewy24; @property (nonatomic, copy, nullable, readwrite) NSString *customerId; @property (nonatomic, copy, nullable, readwrite) NSDictionary *metadata; @@ -64,6 +66,7 @@ - (NSString *)description { [NSString stringWithFormat:@"created = %@", self.created], [NSString stringWithFormat:@"customerId = %@", self.customerId], [NSString stringWithFormat:@"ideal = %@", self.iDEAL], + [NSString stringWithFormat:@"eps = %@", self.EPS], [NSString stringWithFormat:@"fpx = %@", self.fpx], [NSString stringWithFormat:@"giropay = %@", self.giropay], [NSString stringWithFormat:@"przelewy24 = %@", self.przelewy24], @@ -88,6 +91,7 @@ - (NSString *)description { @"au_becs_debit": @(STPPaymentMethodTypeAUBECSDebit), @"giropay": @(STPPaymentMethodTypeGiropay), @"p24": @(STPPaymentMethodTypePrzelewy24), + @"eps": @(STPPaymentMethodTypeEPS), }; } @@ -143,6 +147,7 @@ + (nullable instancetype)decodedObjectFromAPIResponse:(nullable NSDictionary *)r paymentMethod.bacsDebit = [STPPaymentMethodBacsDebit decodedObjectFromAPIResponse:[dict stp_dictionaryForKey:@"bacs_debit"]]; paymentMethod.auBECSDebit = [STPPaymentMethodAUBECSDebit decodedObjectFromAPIResponse:[dict stp_dictionaryForKey:@"au_becs_debit"]]; paymentMethod.giropay = [STPPaymentMethodGiropay decodedObjectFromAPIResponse:[dict stp_dictionaryForKey:@"giropay"]]; + paymentMethod.EPS = [STPPaymentMethodEPS decodedObjectFromAPIResponse:[dict stp_dictionaryForKey:@"eps"]]; paymentMethod.przelewy24 = [STPPaymentMethodPrzelewy24 decodedObjectFromAPIResponse:[dict stp_dictionaryForKey:@"p24"]]; paymentMethod.customerId = [dict stp_stringForKey:@"customer"]; paymentMethod.metadata = [[dict stp_dictionaryForKey:@"metadata"] stp_dictionaryByRemovingNonStrings]; @@ -190,6 +195,8 @@ - (NSString *)label { return STPLocalizedString(@"AU BECS Debit", @"Payment Method type brand name."); case STPPaymentMethodTypeGiropay: return STPLocalizedString(@"giropay", @"Payment Method type brand name."); + case STPPaymentMethodTypeEPS: + return STPLocalizedString(@"EPS", @"Payment Method type brand name."); case STPPaymentMethodTypePrzelewy24: return STPLocalizedString(@"Przelewy24", @"Payment Method type brand name."); case STPPaymentMethodTypeBacsDebit: @@ -213,6 +220,7 @@ - (BOOL)isReusable { case STPPaymentMethodTypeFPX: case STPPaymentMethodTypeCardPresent: case STPPaymentMethodTypeGiropay: + case STPPaymentMethodTypeEPS: case STPPaymentMethodTypePrzelewy24: // fall through case STPPaymentMethodTypeUnknown: diff --git a/Stripe/STPPaymentMethodEPS.h b/Stripe/STPPaymentMethodEPS.h new file mode 100644 index 00000000000..b8141c1a573 --- /dev/null +++ b/Stripe/STPPaymentMethodEPS.h @@ -0,0 +1,36 @@ +// +// STPPaymentMethodEPS.h +// StripeiOS +// +// Created by Shengwei Wu on 5/14/20. +// Copyright © 2020 Stripe, Inc. All rights reserved. +// + +#import + +#import "STPAPIResponseDecodable.h" + +NS_ASSUME_NONNULL_BEGIN + +/** +A EPS Payment Method. +@see https://stripe.com/docs/api/payment_methods/object#payment_method_object-eps +*/ +@interface STPPaymentMethodEPS : NSObject + +/** +You cannot directly instantiate an `STPPaymentMethodEPS`. +You should only use one that is part of an existing `STPPaymentMethod` object. +*/ +- (instancetype)init NS_UNAVAILABLE; + +/** +You cannot directly instantiate an `STPPaymentMethodEPS`. +You should only use one that is part of an existing `STPPaymentMethod` object. +*/ ++ (instancetype)new NS_UNAVAILABLE; + +@end + + +NS_ASSUME_NONNULL_END diff --git a/Stripe/STPPaymentMethodEPS.m b/Stripe/STPPaymentMethodEPS.m new file mode 100644 index 00000000000..abe5bae003e --- /dev/null +++ b/Stripe/STPPaymentMethodEPS.m @@ -0,0 +1,51 @@ +// +// STPPaymentMethodEPS.m +// StripeiOS +// +// Created by Shengwei Wu on 5/14/20. +// Copyright © 2020 Stripe, Inc. All rights reserved. +// + +#import "STPPaymentMethodEPS.h" + +#import "NSDictionary+Stripe.h" + +NS_ASSUME_NONNULL_BEGIN + +@implementation STPPaymentMethodEPS + +@synthesize allResponseFields = _allResponseFields; + + +#pragma mark - Description + +- (NSString *)description { + NSArray *props = @[ + // Object + [NSString stringWithFormat:@"%@: %p", NSStringFromClass([self class]), self], + ]; + + return [NSString stringWithFormat:@"<%@>", [props componentsJoinedByString:@"; "]]; +} + +#pragma mark - STPAPIResponseDecodable + ++ (nullable instancetype)decodedObjectFromAPIResponse:(nullable NSDictionary *)response { + NSDictionary *dict = [response stp_dictionaryByRemovingNulls]; + if (!dict) { + return nil; + } + return [[self alloc] initWithDictionary:dict]; +} + +- (nullable instancetype)initWithDictionary:(NSDictionary *)dict { + self = [super init]; + if (self) { + _allResponseFields = dict.copy; + } + return self; +} + +@end + +NS_ASSUME_NONNULL_END diff --git a/Stripe/STPPaymentMethodEPSParams.h b/Stripe/STPPaymentMethodEPSParams.h new file mode 100644 index 00000000000..374df809844 --- /dev/null +++ b/Stripe/STPPaymentMethodEPSParams.h @@ -0,0 +1,22 @@ +// +// STPPaymentMethodEPSParams.h +// StripeiOS +// +// Created by Shengwei Wu on 5/14/20. +// Copyright © 2020 Stripe, Inc. All rights reserved. +// + +#import + +#import "STPFormEncodable.h" + +NS_ASSUME_NONNULL_BEGIN + +/** +An object representing parameters used to create a EPS Payment Method +*/ +@interface STPPaymentMethodEPSParams : NSObject + +@end + +NS_ASSUME_NONNULL_END diff --git a/Stripe/STPPaymentMethodEPSParams.m b/Stripe/STPPaymentMethodEPSParams.m new file mode 100644 index 00000000000..fd137a7a7c7 --- /dev/null +++ b/Stripe/STPPaymentMethodEPSParams.m @@ -0,0 +1,28 @@ +// +// STPPaymentMethodEPSParams.m +// StripeiOS +// +// Created by Shengwei Wu on 5/14/20. +// Copyright © 2020 Stripe, Inc. All rights reserved. +// + +#import "STPPaymentMethodEPSParams.h" + +NS_ASSUME_NONNULL_BEGIN + +@implementation STPPaymentMethodEPSParams + +@synthesize additionalAPIParameters = _additionalAPIParameters; + ++ (nullable NSString *)rootObjectName { + return @"eps"; +} + ++ (NSDictionary *)propertyNamesToFormFieldNamesMapping { + return @{ + }; +} + +@end + +NS_ASSUME_NONNULL_END diff --git a/Stripe/STPPaymentMethodParams.m b/Stripe/STPPaymentMethodParams.m index 3e253be707d..a880830787e 100644 --- a/Stripe/STPPaymentMethodParams.m +++ b/Stripe/STPPaymentMethodParams.m @@ -17,6 +17,7 @@ #import "STPPaymentMethod+Private.h" #import "STPPaymentMethodBacsDebit.h" #import "STPPaymentMethodCardParams.h" +#import "STPPaymentMethodEPSParams.h" #import "STPPaymentMethodFPX.h" #import "STPPaymentMethodFPXParams.h" #import "STPPaymentMethodGiropayParams.h" @@ -98,6 +99,17 @@ + (nullable STPPaymentMethodParams *)paramsWithGiropay:(STPPaymentMethodGiropayP return params; } ++ (nullable STPPaymentMethodParams *)paramsWithEPS:(STPPaymentMethodEPSParams *)eps + billingDetails:(STPPaymentMethodBillingDetails *)billingDetails + metadata:(nullable NSDictionary *)metadata { + STPPaymentMethodParams *params = [self new]; + params.type = STPPaymentMethodTypeEPS; + params.eps = eps; + params.billingDetails = billingDetails; + params.metadata = metadata; + return params; +} + + (STPPaymentMethodParams *)paramsWithPrzelewy24:(STPPaymentMethodPrzelewy24Params *)przelewy24 billingDetails:(STPPaymentMethodBillingDetails *)billingDetails metadata:(NSDictionary *)metadata { @@ -112,6 +124,15 @@ + (STPPaymentMethodParams *)paramsWithPrzelewy24:(STPPaymentMethodPrzelewy24Para + (nullable STPPaymentMethodParams *)paramsWithSingleUsePaymentMethod:(STPPaymentMethod *)paymentMethod { STPPaymentMethodParams *params = [self new]; switch ([paymentMethod type]) { + case STPPaymentMethodTypeEPS: + { + params.type = STPPaymentMethodTypeEPS; + STPPaymentMethodEPSParams *eps = [[STPPaymentMethodEPSParams alloc] init]; + params.eps = eps; + params.billingDetails = paymentMethod.billingDetails; + params.metadata = paymentMethod.metadata; + break; + } case STPPaymentMethodTypeFPX: { params.type = STPPaymentMethodTypeFPX; @@ -184,6 +205,7 @@ + (nonnull NSDictionary *)propertyNamesToFormFieldNamesMapping { NSStringFromSelector(@selector(billingDetails)): @"billing_details", NSStringFromSelector(@selector(card)): @"card", NSStringFromSelector(@selector(iDEAL)): @"ideal", + NSStringFromSelector(@selector(EPS)): @"eps", NSStringFromSelector(@selector(fpx)): @"fpx", NSStringFromSelector(@selector(sepaDebit)): @"sepa_debit", NSStringFromSelector(@selector(bacsDebit)): @"bacs_debit", @@ -243,6 +265,8 @@ - (NSString *)label { return @"giropay"; case STPPaymentMethodTypePrzelewy24: return @"Przelewy24"; + case STPPaymentMethodTypeEPS: + return @"EPS"; case STPPaymentMethodTypeCardPresent: case STPPaymentMethodTypeUnknown: return STPLocalizedString(@"Unknown", @"Default missing source type label"); @@ -263,6 +287,7 @@ - (BOOL)isReusable { case STPPaymentMethodTypeFPX: case STPPaymentMethodTypeCardPresent: case STPPaymentMethodTypeGiropay: + case STPPaymentMethodTypeEPS: case STPPaymentMethodTypePrzelewy24: // fall through case STPPaymentMethodTypeUnknown: From 32104c8a3c3506b3d62d1dd1fd3382d03f02dfdc Mon Sep 17 00:00:00 2001 From: Shengwei Wu Date: Fri, 15 May 2020 17:26:50 +0800 Subject: [PATCH 2/6] Add Examples --- .../project.pbxproj | 6 ++ .../BrowseExamplesViewController.m | 12 ++- .../EPSExampleViewController.h | 18 ++++ .../EPSExampleViewController.m | 94 +++++++++++++++++++ Stripe.xcodeproj/project.pbxproj | 4 +- Stripe/PublicHeaders/STPPaymentMethodParams.h | 11 +++ 6 files changed, 142 insertions(+), 3 deletions(-) create mode 100644 Example/Non-Card Payment Examples/EPSExampleViewController.h create mode 100644 Example/Non-Card Payment Examples/EPSExampleViewController.m diff --git a/Example/Non-Card Payment Examples.xcodeproj/project.pbxproj b/Example/Non-Card Payment Examples.xcodeproj/project.pbxproj index f9bdeb892d2..8b060ce42e8 100644 --- a/Example/Non-Card Payment Examples.xcodeproj/project.pbxproj +++ b/Example/Non-Card Payment Examples.xcodeproj/project.pbxproj @@ -25,6 +25,7 @@ 36B6CB5D234BEB8400331C38 /* SEPADebitExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 36B6CB5C234BEB8400331C38 /* SEPADebitExampleViewController.m */; }; 36B6CB64234FD9AA00331C38 /* iDEALExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 36B6CB63234FD9AA00331C38 /* iDEALExampleViewController.m */; }; 448895B424526C6B00F7D0C2 /* Przelewy24ExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 448895B324526C6B00F7D0C2 /* Przelewy24ExampleViewController.m */; }; + 69A6C306246E63A2005FF304 /* EPSExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 69A6C305246E63A2005FF304 /* EPSExampleViewController.m */; }; 8BBD79C6207FD2F900F85BED /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8BBD79C8207FD2F900F85BED /* Localizable.strings */; }; B607FFBD2321DA99004203E0 /* MyAPIClient.m in Sources */ = {isa = PBXBuildFile; fileRef = B607FFBC2321DA99004203E0 /* MyAPIClient.m */; }; B65E8FCC22FA078A0057E64A /* WeChatPayExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B65E8FCB22FA078A0057E64A /* WeChatPayExampleViewController.m */; }; @@ -79,6 +80,8 @@ 36B6CB63234FD9AA00331C38 /* iDEALExampleViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = iDEALExampleViewController.m; sourceTree = ""; }; 448895B224526C6B00F7D0C2 /* Przelewy24ExampleViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Przelewy24ExampleViewController.h; sourceTree = ""; }; 448895B324526C6B00F7D0C2 /* Przelewy24ExampleViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Przelewy24ExampleViewController.m; sourceTree = ""; }; + 69A6C304246E6225005FF304 /* EPSExampleViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EPSExampleViewController.h; sourceTree = ""; }; + 69A6C305246E63A2005FF304 /* EPSExampleViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EPSExampleViewController.m; sourceTree = ""; }; 8BBD79C7207FD2F900F85BED /* en */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; 8BBD79C9207FD31A00F85BED /* zh-Hans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = ""; }; 8BBD79CA207FD32100F85BED /* nl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = nl; path = nl.lproj/Localizable.strings; sourceTree = ""; }; @@ -176,6 +179,8 @@ 04533E8A1A687F5D00C7E52E /* Supporting Files */, B65E8FCA22FA078A0057E64A /* WeChatPayExampleViewController.h */, B65E8FCB22FA078A0057E64A /* WeChatPayExampleViewController.m */, + 69A6C304246E6225005FF304 /* EPSExampleViewController.h */, + 69A6C305246E63A2005FF304 /* EPSExampleViewController.m */, ); path = "Non-Card Payment Examples"; sourceTree = ""; @@ -319,6 +324,7 @@ 04533E8D1A687F5D00C7E52E /* main.m in Sources */, 31A8934D230F6ABD007ABE37 /* FPXExampleViewController.m in Sources */, 36B6CB5D234BEB8400331C38 /* SEPADebitExampleViewController.m in Sources */, + 69A6C306246E63A2005FF304 /* EPSExampleViewController.m in Sources */, C12C50DD1E57B3C800EC6D58 /* BrowseExamplesViewController.m in Sources */, 364FC2D024201F62002879EB /* AUBECSDebitExampleViewController.m in Sources */, 448895B424526C6B00F7D0C2 /* Przelewy24ExampleViewController.m in Sources */, diff --git a/Example/Non-Card Payment Examples/BrowseExamplesViewController.m b/Example/Non-Card Payment Examples/BrowseExamplesViewController.m index e4e4cc3fd5d..ead4cccf29f 100644 --- a/Example/Non-Card Payment Examples/BrowseExamplesViewController.m +++ b/Example/Non-Card Payment Examples/BrowseExamplesViewController.m @@ -20,6 +20,7 @@ #import "SEPADebitExampleViewController.h" #import "SofortExampleViewController.h" #import "WeChatPayExampleViewController.h" +#import "EPSExampleViewController.h" /** This view controller presents different examples, each of which demonstrates creating a payment using a different payment method or integration. @@ -41,7 +42,7 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - return 12; + return 13; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { @@ -83,6 +84,9 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N case 11: cell.textLabel.text = @"Przelewy24"; break; + case 12: + cell.textLabel.text = @"EPS"; + break; } return cell; } @@ -169,6 +173,12 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath viewController = exampleVC; break; } + case 12: { + EPSExampleViewController *exampleVC = [EPSExampleViewController new]; + exampleVC.delegate = self; + viewController = exampleVC; + break; + } } [self.navigationController pushViewController:viewController animated:YES]; } diff --git a/Example/Non-Card Payment Examples/EPSExampleViewController.h b/Example/Non-Card Payment Examples/EPSExampleViewController.h new file mode 100644 index 00000000000..ead711a92d6 --- /dev/null +++ b/Example/Non-Card Payment Examples/EPSExampleViewController.h @@ -0,0 +1,18 @@ +// +// EPSExampleViewControllewrViewController.h +// Non-Card Payment Examples +// +// Created by Shengwei Wu on 5/15/20. +// Copyright © 2020 Stripe. All rights reserved. +// + +#import "PaymentExampleViewController.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface EPSExampleViewController : PaymentExampleViewController + + +@end + +NS_ASSUME_NONNULL_END diff --git a/Example/Non-Card Payment Examples/EPSExampleViewController.m b/Example/Non-Card Payment Examples/EPSExampleViewController.m new file mode 100644 index 00000000000..370353bd235 --- /dev/null +++ b/Example/Non-Card Payment Examples/EPSExampleViewController.m @@ -0,0 +1,94 @@ +// +// EPSExampleViewController.m +// Non-Card Payment Examples +// +// Created by Shengwei Wu on 5/15/20. +// Copyright © 2020 Stripe. All rights reserved. +// + +#import "EPSExampleViewController.h" + +#import "MyAPIClient.h" + + +NS_ASSUME_NONNULL_BEGIN + +@interface EPSExampleViewController () +// Category Defintions +@end + +@implementation EPSExampleViewController { + UITextField *_nameField; +} + + +- (void)viewDidLoad { + [super viewDidLoad]; + + self.title = @"EPS"; + + _nameField = [[UITextField alloc] init]; + _nameField.borderStyle = UITextBorderStyleRoundedRect; + _nameField.textContentType = UITextContentTypeName; + _nameField.placeholder = @"Name"; + _nameField.translatesAutoresizingMaskIntoConstraints = NO; + [self.view addSubview:_nameField]; + + + [self.payButton setTitle:@"Pay with EPS" forState:UIControlStateNormal]; + [self.payButton sizeToFit]; + + [NSLayoutConstraint activateConstraints:@[ + [_nameField.centerXAnchor constraintEqualToAnchor:self.payButton.centerXAnchor], + [_nameField.bottomAnchor constraintEqualToAnchor:self.payButton.topAnchor constant:-12.f], + [_nameField.widthAnchor constraintEqualToConstant:240.f], + ]]; +} + +- (void)payButtonSelected { + [super payButtonSelected]; + [self updateUIForPaymentInProgress:YES]; + + [[MyAPIClient sharedClient] createPaymentIntentWithCompletion:^(MyAPIClientResult status, NSString *clientSecret, NSError *error) { + if (status == MyAPIClientResultFailure || clientSecret == nil) { + [self.delegate exampleViewController:self didFinishWithError:error]; + return; + } + + STPPaymentIntentParams *paymentIntentParams = [[STPPaymentIntentParams alloc] initWithClientSecret:clientSecret]; + + STPPaymentMethodBillingDetails *billingDetails = [[STPPaymentMethodBillingDetails alloc] init]; + billingDetails.name = self->_nameField.text; + + + STPPaymentMethodEPSParams *eps = [[STPPaymentMethodEPSParams alloc] init]; + + // EPS does not require additional parameters so we only need to pass the init-ed + // STPPaymentMethoEPSParams instance to STPPaymentMethodParams + paymentIntentParams.paymentMethodParams = [STPPaymentMethodParams paramsWithEPS:eps + billingDetails:billingDetails + metadata:nil]; + + paymentIntentParams.returnURL = @"payments-example://stripe-redirect"; + [[STPPaymentHandler sharedHandler] confirmPayment:paymentIntentParams + withAuthenticationContext:self.delegate + completion:^(STPPaymentHandlerActionStatus handlerStatus, STPPaymentIntent * handledIntent, NSError * _Nullable handlerError) { + switch (handlerStatus) { + case STPPaymentHandlerActionStatusFailed: + [self.delegate exampleViewController:self didFinishWithError:handlerError]; + break; + case STPPaymentHandlerActionStatusCanceled: + [self.delegate exampleViewController:self didFinishWithMessage:@"Canceled"]; + break; + case STPPaymentHandlerActionStatusSucceeded: + [self.delegate exampleViewController:self didFinishWithMessage:@"Payment successfully created"]; + break; + } + }]; + } additionalParameters:@"country=at"]; +} + + +@end + +NS_ASSUME_NONNULL_END diff --git a/Stripe.xcodeproj/project.pbxproj b/Stripe.xcodeproj/project.pbxproj index b66daf1033f..b556c28c3c2 100644 --- a/Stripe.xcodeproj/project.pbxproj +++ b/Stripe.xcodeproj/project.pbxproj @@ -754,9 +754,9 @@ 448895AC2452456800F7D0C2 /* STPPaymentMethodPrzelewy24Params.m in Sources */ = {isa = PBXBuildFile; fileRef = 448895A4245244FE00F7D0C2 /* STPPaymentMethodPrzelewy24Params.m */; }; 448895AF245255D800F7D0C2 /* STPPaymentMethodPrzelewy24ParamsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 448895AE245255D800F7D0C2 /* STPPaymentMethodPrzelewy24ParamsTests.m */; }; 448895B1245262E500F7D0C2 /* STPPaymentMethodPrzelewy24Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 448895B0245262E500F7D0C2 /* STPPaymentMethodPrzelewy24Tests.m */; }; - 69A6C2F8246D4A66005FF304 /* STPPaymentMethodEPS.h in Headers */ = {isa = PBXBuildFile; fileRef = 69A6C2F7246D4A66005FF304 /* STPPaymentMethodEPS.h */; }; + 69A6C2F8246D4A66005FF304 /* STPPaymentMethodEPS.h in Headers */ = {isa = PBXBuildFile; fileRef = 69A6C2F7246D4A66005FF304 /* STPPaymentMethodEPS.h */; settings = {ATTRIBUTES = (Public, ); }; }; 69A6C2FA246D4AA0005FF304 /* STPPaymentMethodEPS.m in Sources */ = {isa = PBXBuildFile; fileRef = 69A6C2F9246D4AA0005FF304 /* STPPaymentMethodEPS.m */; }; - 69A6C2FC246D7869005FF304 /* STPPaymentMethodEPSParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 69A6C2FB246D7869005FF304 /* STPPaymentMethodEPSParams.h */; }; + 69A6C2FC246D7869005FF304 /* STPPaymentMethodEPSParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 69A6C2FB246D7869005FF304 /* STPPaymentMethodEPSParams.h */; settings = {ATTRIBUTES = (Public, ); }; }; 69A6C2FE246D788D005FF304 /* STPPaymentMethodEPSParams.m in Sources */ = {isa = PBXBuildFile; fileRef = 69A6C2FD246D788D005FF304 /* STPPaymentMethodEPSParams.m */; }; 69A6C2FF246D8834005FF304 /* STPPaymentMethodEPS.m in Headers */ = {isa = PBXBuildFile; fileRef = 69A6C2F9246D4AA0005FF304 /* STPPaymentMethodEPS.m */; }; 69A6C300246D8834005FF304 /* STPPaymentMethodEPSParams.m in Headers */ = {isa = PBXBuildFile; fileRef = 69A6C2FD246D788D005FF304 /* STPPaymentMethodEPSParams.m */; }; diff --git a/Stripe/PublicHeaders/STPPaymentMethodParams.h b/Stripe/PublicHeaders/STPPaymentMethodParams.h index 8a2ec351a74..f3680fcc9a1 100644 --- a/Stripe/PublicHeaders/STPPaymentMethodParams.h +++ b/Stripe/PublicHeaders/STPPaymentMethodParams.h @@ -184,6 +184,17 @@ NS_ASSUME_NONNULL_BEGIN billingDetails:(STPPaymentMethodBillingDetails *)billingDetails metadata:(nullable NSDictionary *)metadata; +/** + Creates params for a giropay PaymentMethod; + + @param eps An object containing additional EPS details. + @param billingDetails An object containing the user's billing details. Note that `billingDetails.name` is required for giropay PaymentMethods. + @param metadata Additional information to attach to the PaymentMethod. + */ ++ (nullable STPPaymentMethodParams *)paramsWithEPS:(STPPaymentMethodEPSParams *)eps + billingDetails:(STPPaymentMethodBillingDetails *)billingDetails + metadata:(nullable NSDictionary *)metadata; + /** Creates params for a Przelewy24 PaymentMethod; @param przelewy24 An object containing additional Przelewy24 details. From 583407c49e491fcadb1bd781024a653481feb032 Mon Sep 17 00:00:00 2001 From: Shengwei Wu Date: Fri, 15 May 2020 18:39:06 +0800 Subject: [PATCH 3/6] Add and pass unit test for EPS --- Stripe.xcodeproj/project.pbxproj | 42 ++++++++------ Stripe/PublicHeaders/STPPaymentMethod.h | 2 +- Stripe/STPPaymentMethod.m | 6 +- Tests/Tests/STPPaymentIntentFunctionalTest.m | 54 +++++++++++++++++ Tests/Tests/STPPaymentMethodEPSParamsTests.m | 61 ++++++++++++++++++++ Tests/Tests/STPPaymentMethodEPSTests.m | 48 +++++++++++++++ Tests/Tests/STPPaymentMethodTest.m | 3 + 7 files changed, 195 insertions(+), 21 deletions(-) create mode 100644 Tests/Tests/STPPaymentMethodEPSParamsTests.m create mode 100644 Tests/Tests/STPPaymentMethodEPSTests.m diff --git a/Stripe.xcodeproj/project.pbxproj b/Stripe.xcodeproj/project.pbxproj index 172161287a2..f38c318b9f0 100644 --- a/Stripe.xcodeproj/project.pbxproj +++ b/Stripe.xcodeproj/project.pbxproj @@ -754,12 +754,6 @@ 448895AC2452456800F7D0C2 /* STPPaymentMethodPrzelewy24Params.m in Sources */ = {isa = PBXBuildFile; fileRef = 448895A4245244FE00F7D0C2 /* STPPaymentMethodPrzelewy24Params.m */; }; 448895AF245255D800F7D0C2 /* STPPaymentMethodPrzelewy24ParamsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 448895AE245255D800F7D0C2 /* STPPaymentMethodPrzelewy24ParamsTests.m */; }; 448895B1245262E500F7D0C2 /* STPPaymentMethodPrzelewy24Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 448895B0245262E500F7D0C2 /* STPPaymentMethodPrzelewy24Tests.m */; }; - 69A6C2F8246D4A66005FF304 /* STPPaymentMethodEPS.h in Headers */ = {isa = PBXBuildFile; fileRef = 69A6C2F7246D4A66005FF304 /* STPPaymentMethodEPS.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 69A6C2FA246D4AA0005FF304 /* STPPaymentMethodEPS.m in Sources */ = {isa = PBXBuildFile; fileRef = 69A6C2F9246D4AA0005FF304 /* STPPaymentMethodEPS.m */; }; - 69A6C2FC246D7869005FF304 /* STPPaymentMethodEPSParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 69A6C2FB246D7869005FF304 /* STPPaymentMethodEPSParams.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 69A6C2FE246D788D005FF304 /* STPPaymentMethodEPSParams.m in Sources */ = {isa = PBXBuildFile; fileRef = 69A6C2FD246D788D005FF304 /* STPPaymentMethodEPSParams.m */; }; - 69A6C2FF246D8834005FF304 /* STPPaymentMethodEPS.m in Headers */ = {isa = PBXBuildFile; fileRef = 69A6C2F9246D4AA0005FF304 /* STPPaymentMethodEPS.m */; }; - 69A6C300246D8834005FF304 /* STPPaymentMethodEPSParams.m in Headers */ = {isa = PBXBuildFile; fileRef = 69A6C2FD246D788D005FF304 /* STPPaymentMethodEPSParams.m */; }; 44BDCFD3245A278F007EE6D5 /* STPPaymentMethodBancontact.m in Sources */ = {isa = PBXBuildFile; fileRef = 44BDCFD1245A278F007EE6D5 /* STPPaymentMethodBancontact.m */; }; 44BDCFD5245A27C1007EE6D5 /* STPPaymentMethodBancontact.h in Headers */ = {isa = PBXBuildFile; fileRef = 44BDCFD4245A27C1007EE6D5 /* STPPaymentMethodBancontact.h */; settings = {ATTRIBUTES = (Public, ); }; }; 44BDCFD9245A2BFA007EE6D5 /* STPPaymentMethodBancontactParams.m in Sources */ = {isa = PBXBuildFile; fileRef = 44BDCFD7245A2BFA007EE6D5 /* STPPaymentMethodBancontactParams.m */; }; @@ -768,6 +762,14 @@ 44BDCFDD245A2C59007EE6D5 /* STPPaymentMethodBancontactParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 44BDCFDA245A2C38007EE6D5 /* STPPaymentMethodBancontactParams.h */; settings = {ATTRIBUTES = (Public, ); }; }; 44BDCFDF245A46CC007EE6D5 /* STPPaymentMethodBancontactParamsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 44BDCFDE245A46CC007EE6D5 /* STPPaymentMethodBancontactParamsTests.m */; }; 44BDCFE1245A4841007EE6D5 /* STPPaymentMethodBancontactTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 44BDCFE0245A4841007EE6D5 /* STPPaymentMethodBancontactTests.m */; }; + 69A6C2F8246D4A66005FF304 /* STPPaymentMethodEPS.h in Headers */ = {isa = PBXBuildFile; fileRef = 69A6C2F7246D4A66005FF304 /* STPPaymentMethodEPS.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 69A6C2FA246D4AA0005FF304 /* STPPaymentMethodEPS.m in Sources */ = {isa = PBXBuildFile; fileRef = 69A6C2F9246D4AA0005FF304 /* STPPaymentMethodEPS.m */; }; + 69A6C2FC246D7869005FF304 /* STPPaymentMethodEPSParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 69A6C2FB246D7869005FF304 /* STPPaymentMethodEPSParams.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 69A6C2FE246D788D005FF304 /* STPPaymentMethodEPSParams.m in Sources */ = {isa = PBXBuildFile; fileRef = 69A6C2FD246D788D005FF304 /* STPPaymentMethodEPSParams.m */; }; + 69A6C2FF246D8834005FF304 /* STPPaymentMethodEPS.m in Headers */ = {isa = PBXBuildFile; fileRef = 69A6C2F9246D4AA0005FF304 /* STPPaymentMethodEPS.m */; }; + 69A6C300246D8834005FF304 /* STPPaymentMethodEPSParams.m in Headers */ = {isa = PBXBuildFile; fileRef = 69A6C2FD246D788D005FF304 /* STPPaymentMethodEPSParams.m */; }; + 69A6C308246EA03E005FF304 /* STPPaymentMethodEPSTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 69A6C307246EA03E005FF304 /* STPPaymentMethodEPSTests.m */; }; + 69A6C30A246EA195005FF304 /* STPPaymentMethodEPSParamsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 69A6C309246EA195005FF304 /* STPPaymentMethodEPSParamsTests.m */; }; 8B013C891F1E784A00DD831B /* STPPaymentConfigurationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B013C881F1E784A00DD831B /* STPPaymentConfigurationTest.m */; }; 8B39128220E2F99600098401 /* EPSSource.json in Resources */ = {isa = PBXBuildFile; fileRef = 8B39128120E2F99600098401 /* EPSSource.json */; }; 8B39128320E2F9A100098401 /* BancontactSource.json in Resources */ = {isa = PBXBuildFile; fileRef = 8B39127F20E2F6A500098401 /* BancontactSource.json */; }; @@ -2025,6 +2027,8 @@ 69A6C2F9246D4AA0005FF304 /* STPPaymentMethodEPS.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STPPaymentMethodEPS.m; sourceTree = ""; }; 69A6C2FB246D7869005FF304 /* STPPaymentMethodEPSParams.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = STPPaymentMethodEPSParams.h; sourceTree = ""; }; 69A6C2FD246D788D005FF304 /* STPPaymentMethodEPSParams.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STPPaymentMethodEPSParams.m; sourceTree = ""; }; + 69A6C307246EA03E005FF304 /* STPPaymentMethodEPSTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STPPaymentMethodEPSTests.m; sourceTree = ""; }; + 69A6C309246EA195005FF304 /* STPPaymentMethodEPSParamsTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STPPaymentMethodEPSParamsTests.m; sourceTree = ""; }; 7E0B1132203572FB00271AD3 /* fi */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = fi; path = Localizations/fi.lproj/Localizable.strings; sourceTree = ""; }; 8B013C881F1E784A00DD831B /* STPPaymentConfigurationTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = STPPaymentConfigurationTest.m; sourceTree = ""; }; 8B39127F20E2F6A500098401 /* BancontactSource.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = BancontactSource.json; sourceTree = ""; }; @@ -3193,6 +3197,17 @@ name = Przelewy24; sourceTree = ""; }; + 44BDCFCF245A272D007EE6D5 /* Bancontact */ = { + isa = PBXGroup; + children = ( + 44BDCFD4245A27C1007EE6D5 /* STPPaymentMethodBancontact.h */, + 44BDCFD1245A278F007EE6D5 /* STPPaymentMethodBancontact.m */, + 44BDCFDA245A2C38007EE6D5 /* STPPaymentMethodBancontactParams.h */, + 44BDCFD7245A2BFA007EE6D5 /* STPPaymentMethodBancontactParams.m */, + ); + name = Bancontact; + sourceTree = ""; + }; 69A6C301246D8BD2005FF304 /* EPS */ = { isa = PBXGroup; children = ( @@ -3204,17 +3219,6 @@ name = EPS; sourceTree = ""; }; - 44BDCFCF245A272D007EE6D5 /* Bancontact */ = { - isa = PBXGroup; - children = ( - 44BDCFD4245A27C1007EE6D5 /* STPPaymentMethodBancontact.h */, - 44BDCFD1245A278F007EE6D5 /* STPPaymentMethodBancontact.m */, - 44BDCFDA245A2C38007EE6D5 /* STPPaymentMethodBancontactParams.h */, - 44BDCFD7245A2BFA007EE6D5 /* STPPaymentMethodBancontactParams.m */, - ); - name = Bancontact; - sourceTree = ""; - }; 8BD2133A1F0458B7007F6FD1 /* Source */ = { isa = PBXGroup; children = ( @@ -3380,6 +3384,8 @@ 448895AE245255D800F7D0C2 /* STPPaymentMethodPrzelewy24ParamsTests.m */, 448895B0245262E500F7D0C2 /* STPPaymentMethodPrzelewy24Tests.m */, 36B6CB56234BDC4400331C38 /* STPPaymentMethodSEPADebitTest.m */, + 69A6C307246EA03E005FF304 /* STPPaymentMethodEPSTests.m */, + 69A6C309246EA195005FF304 /* STPPaymentMethodEPSParamsTests.m */, B66B39B3223044A2006D1CAD /* STPPaymentMethodTest.m */, B66D5023222F5A27004A9210 /* STPPaymentMethodThreeDSecureUsageTest.m */, F1DE87FF1F8D410D00602F4C /* STPPaymentOptionsViewControllerTest.m */, @@ -5177,6 +5183,7 @@ 8B013C891F1E784A00DD831B /* STPPaymentConfigurationTest.m in Sources */, C1EEDCC81CA2172700A54582 /* NSString+StripeTest.m in Sources */, 36B8DDF7241C07AB00BB908E /* STPBECSDebitAccountNumberValidatorTests.m in Sources */, + 69A6C308246EA03E005FF304 /* STPPaymentMethodEPSTests.m in Sources */, 3626615223C8F89F00B13AE0 /* STPConfirmPaymentMethodOptions.m in Sources */, B68882E5240453E30057C5AD /* STPApplePayContextTest.m in Sources */, 366658B52410756100D00354 /* STPPaymentMethodAUBECSDebitParamsTests.m in Sources */, @@ -5190,6 +5197,7 @@ 8B6DC9751F0171D20025E811 /* STPSourceReceiverTest.m in Sources */, F1DE88011F8D410D00602F4C /* STPPaymentOptionsViewControllerTest.m in Sources */, 8B6DC9771F0172640025E811 /* STPSourceSEPADebitDetailsTest.m in Sources */, + 69A6C30A246EA195005FF304 /* STPPaymentMethodEPSParamsTests.m in Sources */, B656292523E10AB100458A8E /* STPPaymentMethodBacsDebitTest.m in Sources */, 04415C6C1A6605B5001225ED /* STPBankAccountTest.m in Sources */, B664D65322B813EC00E6354B /* STPThreeDSButtonCustomizationTest.m in Sources */, diff --git a/Stripe/PublicHeaders/STPPaymentMethod.h b/Stripe/PublicHeaders/STPPaymentMethod.h index f237b0cd096..4af49726c05 100644 --- a/Stripe/PublicHeaders/STPPaymentMethod.h +++ b/Stripe/PublicHeaders/STPPaymentMethod.h @@ -103,7 +103,7 @@ NS_ASSUME_NONNULL_BEGIN /** If this is an EPS PaymentMethod (i.e. `self.type == STPPaymentMethodTypeEPS`), this contains additional details. */ -@property (nonatomic, nullable, readonly) STPPaymentMethodEPS *EPS; +@property (nonatomic, nullable, readonly) STPPaymentMethodEPS *eps; /** If this is a Przelewy24 PaymentMethod (i.e. `self.type == STPPaymentMethodTypePrzelewy24`), this contains additional details. diff --git a/Stripe/STPPaymentMethod.m b/Stripe/STPPaymentMethod.m index f7f24ec6800..d835ecd7ae0 100644 --- a/Stripe/STPPaymentMethod.m +++ b/Stripe/STPPaymentMethod.m @@ -39,7 +39,7 @@ @interface STPPaymentMethod () @property (nonatomic, strong, nullable, readwrite) STPPaymentMethodSEPADebit *sepaDebit; @property (nonatomic, strong, nullable, readwrite) STPPaymentMethodAUBECSDebit *auBECSDebit; @property (nonatomic, strong, nullable, readwrite) STPPaymentMethodGiropay *giropay; -@property (nonatomic, strong, nullable, readwrite) STPPaymentMethodEPS *EPS; +@property (nonatomic, strong, nullable, readwrite) STPPaymentMethodEPS *eps; @property (nonatomic, strong, nullable, readwrite) STPPaymentMethodPrzelewy24 *przelewy24; @property (nonatomic, strong, nullable, readwrite) STPPaymentMethodBancontact *bancontact; @property (nonatomic, copy, nullable, readwrite) NSString *customerId; @@ -69,7 +69,7 @@ - (NSString *)description { [NSString stringWithFormat:@"created = %@", self.created], [NSString stringWithFormat:@"customerId = %@", self.customerId], [NSString stringWithFormat:@"ideal = %@", self.iDEAL], - [NSString stringWithFormat:@"eps = %@", self.EPS], + [NSString stringWithFormat:@"eps = %@", self.eps], [NSString stringWithFormat:@"fpx = %@", self.fpx], [NSString stringWithFormat:@"giropay = %@", self.giropay], [NSString stringWithFormat:@"przelewy24 = %@", self.przelewy24], @@ -151,7 +151,7 @@ + (nullable instancetype)decodedObjectFromAPIResponse:(nullable NSDictionary *)r paymentMethod.bacsDebit = [STPPaymentMethodBacsDebit decodedObjectFromAPIResponse:[dict stp_dictionaryForKey:@"bacs_debit"]]; paymentMethod.auBECSDebit = [STPPaymentMethodAUBECSDebit decodedObjectFromAPIResponse:[dict stp_dictionaryForKey:@"au_becs_debit"]]; paymentMethod.giropay = [STPPaymentMethodGiropay decodedObjectFromAPIResponse:[dict stp_dictionaryForKey:@"giropay"]]; - paymentMethod.EPS = [STPPaymentMethodEPS decodedObjectFromAPIResponse:[dict stp_dictionaryForKey:@"eps"]]; + paymentMethod.eps = [STPPaymentMethodEPS decodedObjectFromAPIResponse:[dict stp_dictionaryForKey:@"eps"]]; paymentMethod.przelewy24 = [STPPaymentMethodPrzelewy24 decodedObjectFromAPIResponse:[dict stp_dictionaryForKey:@"p24"]]; paymentMethod.bancontact = [STPPaymentMethodBancontact decodedObjectFromAPIResponse:[dict stp_dictionaryForKey:@"bancontact"]]; paymentMethod.customerId = [dict stp_stringForKey:@"customer"]; diff --git a/Tests/Tests/STPPaymentIntentFunctionalTest.m b/Tests/Tests/STPPaymentIntentFunctionalTest.m index b1d7104368e..e8d5ba578f8 100644 --- a/Tests/Tests/STPPaymentIntentFunctionalTest.m +++ b/Tests/Tests/STPPaymentIntentFunctionalTest.m @@ -516,6 +516,60 @@ - (void)testConfirmPaymentIntentWithBancontact { [self waitForExpectationsWithTimeout:STPTestingNetworkRequestTimeout handler:nil]; } +#pragma mark - EPS + +- (void)testConfirmPaymentIntentWithEPS { + __block NSString *clientSecret = nil; + XCTestExpectation *createExpectation = [self expectationWithDescription:@"Create PaymentIntent."]; + [[STPTestingAPIClient sharedClient] createPaymentIntentWithParams:@{ + @"payment_method_types": @[@"eps"], + @"currency": @"eur", + } + completion:^(NSString * _Nullable createdClientSecret, NSError * _Nullable creationError) { + XCTAssertNotNil(createdClientSecret); + XCTAssertNil(creationError); + [createExpectation fulfill]; + clientSecret = [createdClientSecret copy]; + }]; + [self waitForExpectationsWithTimeout:STPTestingNetworkRequestTimeout handler:nil]; + XCTAssertNotNil(clientSecret); + + STPAPIClient *client = [[STPAPIClient alloc] initWithPublishableKey:STPTestingDefaultPublishableKey]; + XCTestExpectation *expectation = [self expectationWithDescription:@"Payment Intent confirm"]; + + STPPaymentIntentParams *paymentIntentParams = [[STPPaymentIntentParams alloc] initWithClientSecret:clientSecret]; + STPPaymentMethodEPSParams *epsParams = [STPPaymentMethodEPSParams new]; + + STPPaymentMethodBillingDetails *billingDetails = [STPPaymentMethodBillingDetails new]; + billingDetails.name = @"Jenny Rosen"; + + paymentIntentParams.paymentMethodParams = [STPPaymentMethodParams paramsWithEPS:epsParams + billingDetails:billingDetails + metadata:@{@"test_key": @"test_value"}]; + paymentIntentParams.returnURL = @"example-app-scheme://authorized"; + + [client confirmPaymentIntentWithParams:paymentIntentParams + completion:^(STPPaymentIntent * _Nullable paymentIntent, NSError * _Nullable error) { + XCTAssertNil(error, @"With valid key + secret, should be able to confirm the intent"); + + XCTAssertNotNil(paymentIntent); + XCTAssertEqualObjects(paymentIntent.stripeId, paymentIntentParams.stripeId); + + XCTAssertFalse(paymentIntent.livemode); + XCTAssertNotNil(paymentIntent.paymentMethodId); + + // EPS requires a redirect + XCTAssertEqual(paymentIntent.status, STPPaymentIntentStatusRequiresAction); + XCTAssertNotNil(paymentIntent.nextAction.redirectToURL.returnURL); + XCTAssertEqualObjects(paymentIntent.nextAction.redirectToURL.returnURL, + [NSURL URLWithString:@"example-app-scheme://authorized"]); + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:STPTestingNetworkRequestTimeout handler:nil]; +} + #pragma mark - Helpers - (STPSourceParams *)cardSourceParams { diff --git a/Tests/Tests/STPPaymentMethodEPSParamsTests.m b/Tests/Tests/STPPaymentMethodEPSParamsTests.m new file mode 100644 index 00000000000..16e20556d10 --- /dev/null +++ b/Tests/Tests/STPPaymentMethodEPSParamsTests.m @@ -0,0 +1,61 @@ +// +// STPPaymentMethodEPSParamsTests.m +// StripeiOS Tests +// +// Created by Shengwei Wu on 5/15/20. +// Copyright © 2020 Stripe, Inc. All rights reserved. +// + +#import + + +#import "STPAPIClient.h" +#import "STPPaymentMethod.h" +#import "STPPaymentMethodBillingDetails.h" +#import "STPPaymentMethodEPS.h" +#import "STPPaymentMethodEPSParams.h" +#import "STPPaymentMethodParams.h" +#import "STPTestingAPIClient.h" + +@interface STPPaymentMethodEPSParamsTests : XCTestCase + +@end + +@implementation STPPaymentMethodEPSParamsTests + +- (void)testCreateEPSPaymentMethod { + STPAPIClient *client = [[STPAPIClient alloc] initWithPublishableKey:STPTestingDefaultPublishableKey]; + STPPaymentMethodEPSParams *epsParams = [STPPaymentMethodEPSParams new]; + + STPPaymentMethodBillingDetails *billingDetails = [STPPaymentMethodBillingDetails new]; + billingDetails.name = @"Jenny Rosen"; + + STPPaymentMethodParams *params = [STPPaymentMethodParams paramsWithEPS:epsParams + billingDetails:billingDetails + metadata:@{@"test_key": @"test_value"}]; + + XCTestExpectation *expectation = [self expectationWithDescription:@"Payment Method EPS create"]; + + [client createPaymentMethodWithParams:params + completion:^(STPPaymentMethod * _Nullable paymentMethod, NSError * _Nullable error) { + [expectation fulfill]; + + XCTAssertNil(error, @"Unexpected error creating EPS PaymentMethod: %@", error); + XCTAssertNotNil(paymentMethod, @"Failed to create EPS PaymentMethod"); + XCTAssertNotNil(paymentMethod.stripeId, @"Missing stripeId"); + XCTAssertNotNil(paymentMethod.created, @"Missing created"); + XCTAssertFalse(paymentMethod.liveMode, @"Incorrect livemode"); + XCTAssertEqual(paymentMethod.type, STPPaymentMethodTypeEPS, @"Incorrect PaymentMethod type"); + XCTAssertEqualObjects(paymentMethod.metadata, @{@"test_key": @"test_value"}, @"Incorrect metadata"); + + // Billing Details + XCTAssertEqualObjects(paymentMethod.billingDetails.name, @"Jenny Rosen", @"Incorrect name"); + + // EPS Details + XCTAssertNotNil(paymentMethod.eps, @"Missing eps"); + }]; + + [self waitForExpectationsWithTimeout:STPTestingNetworkRequestTimeout handler:nil]; +} + +@end diff --git a/Tests/Tests/STPPaymentMethodEPSTests.m b/Tests/Tests/STPPaymentMethodEPSTests.m new file mode 100644 index 00000000000..02db43457bf --- /dev/null +++ b/Tests/Tests/STPPaymentMethodEPSTests.m @@ -0,0 +1,48 @@ +// +// STPPaymentMethodEPSTest.m +// StripeiOS Tests +// +// Created by Shengwei Wu on 5/15/20. +// Copyright © 2020 Stripe, Inc. All rights reserved. +// + +#import + +#import "STPAPIClient+Private.h" +#import "STPPaymentIntent+Private.h" +#import "STPPaymentMethod.h" +#import "STPPaymentMethodEPS.h" +#import "STPTestingAPIClient.h" + +@interface STPPaymentMethodEPSTests : XCTestCase + +@property (nonatomic, readonly) NSDictionary *epsJSON; + +@end + +@implementation STPPaymentMethodEPSTests + +- (void)_retrieveEPSJSON:(void (^)(NSDictionary *))completion { + if (self.epsJSON) { + completion(self.epsJSON); + } else { + STPAPIClient *client = [[STPAPIClient alloc] initWithPublishableKey:STPTestingDefaultPublishableKey]; + [client retrievePaymentIntentWithClientSecret:@"pi_1Gj0rqFY0qyl6XeWrug30CPz_secret_tKyf8QOKtiIrE3NSEkWCkBbyy" + expand:@[@"payment_method"] completion:^(STPPaymentIntent * _Nullable paymentIntent, __unused NSError * _Nullable error) { + self->_epsJSON = paymentIntent.paymentMethod.eps.allResponseFields; + completion(self.epsJSON); + }]; + } +} + +- (void)testCorrectParsing { + XCTestExpectation *jsonExpectation = [[XCTestExpectation alloc] initWithDescription:@"Fetch EPS JSON"]; + [self _retrieveEPSJSON:^(NSDictionary *json) { + STPPaymentMethodEPS *eps = [STPPaymentMethodEPS decodedObjectFromAPIResponse:json]; + XCTAssertNotNil(eps, @"Failed to decode JSON"); + [jsonExpectation fulfill]; + }]; + [self waitForExpectations:@[jsonExpectation] timeout:STPTestingNetworkRequestTimeout]; +} + +@end diff --git a/Tests/Tests/STPPaymentMethodTest.m b/Tests/Tests/STPPaymentMethodTest.m index 5807b4fba54..b9f41b76bd5 100644 --- a/Tests/Tests/STPPaymentMethodTest.m +++ b/Tests/Tests/STPPaymentMethodTest.m @@ -92,6 +92,9 @@ - (void)testStringFromType { case STPPaymentMethodTypeBancontact: XCTAssertEqualObjects(string, @"bancontact"); break; + case STPPaymentMethodTypeEPS: + XCTAssertEqualObjects(string, @"eps"); + break; case STPPaymentMethodTypeUnknown: XCTAssertNil(string); break; From 89c874500500029d8ae6f78b01b40ef9bfa38f03 Mon Sep 17 00:00:00 2001 From: Cameron Sabol Date: Fri, 15 May 2020 11:14:22 -0700 Subject: [PATCH 4/6] CI Fixes --- Stripe.xcodeproj/project.pbxproj | 20 +++++++++++-------- .../{ => PublicHeaders}/STPPaymentMethodEPS.h | 0 .../STPPaymentMethodEPSParams.h | 0 .../en.lproj/Localizable.strings | 3 ++- 4 files changed, 14 insertions(+), 9 deletions(-) rename Stripe/{ => PublicHeaders}/STPPaymentMethodEPS.h (100%) rename Stripe/{ => PublicHeaders}/STPPaymentMethodEPSParams.h (100%) diff --git a/Stripe.xcodeproj/project.pbxproj b/Stripe.xcodeproj/project.pbxproj index f38c318b9f0..29dc5919311 100644 --- a/Stripe.xcodeproj/project.pbxproj +++ b/Stripe.xcodeproj/project.pbxproj @@ -642,6 +642,10 @@ 3650AA4D21C07E3D002B0893 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3650AA4B21C07E3D002B0893 /* LaunchScreen.storyboard */; }; 3650AA5021C07E3D002B0893 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 3650AA4F21C07E3D002B0893 /* main.m */; }; 3650AA5A21C07E3D002B0893 /* LocalizationTesterUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3650AA5921C07E3D002B0893 /* LocalizationTesterUITests.m */; }; + 3656EF2F246F135400DA11CF /* STPPaymentMethodEPSParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 3656EF2D246F135400DA11CF /* STPPaymentMethodEPSParams.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 3656EF30246F135400DA11CF /* STPPaymentMethodEPS.h in Headers */ = {isa = PBXBuildFile; fileRef = 3656EF2E246F135400DA11CF /* STPPaymentMethodEPS.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 3656EF31246F135C00DA11CF /* STPPaymentMethodEPS.h in Headers */ = {isa = PBXBuildFile; fileRef = 3656EF2E246F135400DA11CF /* STPPaymentMethodEPS.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 3656EF32246F136200DA11CF /* STPPaymentMethodEPSParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 3656EF2D246F135400DA11CF /* STPPaymentMethodEPSParams.h */; settings = {ATTRIBUTES = (Public, ); }; }; 365BE89E2285F6080068D824 /* STPPaymentHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 365BE89C2285F6080068D824 /* STPPaymentHandler.m */; }; 365BE8A2228CAB6A0068D824 /* STPIntentActionUseStripeSDK.h in Headers */ = {isa = PBXBuildFile; fileRef = 365BE8A0228CAB6A0068D824 /* STPIntentActionUseStripeSDK.h */; }; 365BE8A3228CAB6A0068D824 /* STPIntentActionUseStripeSDK.m in Sources */ = {isa = PBXBuildFile; fileRef = 365BE8A1228CAB6A0068D824 /* STPIntentActionUseStripeSDK.m */; }; @@ -762,9 +766,7 @@ 44BDCFDD245A2C59007EE6D5 /* STPPaymentMethodBancontactParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 44BDCFDA245A2C38007EE6D5 /* STPPaymentMethodBancontactParams.h */; settings = {ATTRIBUTES = (Public, ); }; }; 44BDCFDF245A46CC007EE6D5 /* STPPaymentMethodBancontactParamsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 44BDCFDE245A46CC007EE6D5 /* STPPaymentMethodBancontactParamsTests.m */; }; 44BDCFE1245A4841007EE6D5 /* STPPaymentMethodBancontactTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 44BDCFE0245A4841007EE6D5 /* STPPaymentMethodBancontactTests.m */; }; - 69A6C2F8246D4A66005FF304 /* STPPaymentMethodEPS.h in Headers */ = {isa = PBXBuildFile; fileRef = 69A6C2F7246D4A66005FF304 /* STPPaymentMethodEPS.h */; settings = {ATTRIBUTES = (Public, ); }; }; 69A6C2FA246D4AA0005FF304 /* STPPaymentMethodEPS.m in Sources */ = {isa = PBXBuildFile; fileRef = 69A6C2F9246D4AA0005FF304 /* STPPaymentMethodEPS.m */; }; - 69A6C2FC246D7869005FF304 /* STPPaymentMethodEPSParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 69A6C2FB246D7869005FF304 /* STPPaymentMethodEPSParams.h */; settings = {ATTRIBUTES = (Public, ); }; }; 69A6C2FE246D788D005FF304 /* STPPaymentMethodEPSParams.m in Sources */ = {isa = PBXBuildFile; fileRef = 69A6C2FD246D788D005FF304 /* STPPaymentMethodEPSParams.m */; }; 69A6C2FF246D8834005FF304 /* STPPaymentMethodEPS.m in Headers */ = {isa = PBXBuildFile; fileRef = 69A6C2F9246D4AA0005FF304 /* STPPaymentMethodEPS.m */; }; 69A6C300246D8834005FF304 /* STPPaymentMethodEPSParams.m in Headers */ = {isa = PBXBuildFile; fileRef = 69A6C2FD246D788D005FF304 /* STPPaymentMethodEPSParams.m */; }; @@ -1919,6 +1921,8 @@ 3650AA5521C07E3D002B0893 /* LocalizationTesterUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = LocalizationTesterUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 3650AA5921C07E3D002B0893 /* LocalizationTesterUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LocalizationTesterUITests.m; sourceTree = ""; }; 3650AA5B21C07E3D002B0893 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 3656EF2D246F135400DA11CF /* STPPaymentMethodEPSParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = STPPaymentMethodEPSParams.h; path = PublicHeaders/STPPaymentMethodEPSParams.h; sourceTree = ""; }; + 3656EF2E246F135400DA11CF /* STPPaymentMethodEPS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = STPPaymentMethodEPS.h; path = PublicHeaders/STPPaymentMethodEPS.h; sourceTree = ""; }; 365BE89C2285F6080068D824 /* STPPaymentHandler.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STPPaymentHandler.m; sourceTree = ""; }; 365BE8A0228CAB6A0068D824 /* STPIntentActionUseStripeSDK.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = STPIntentActionUseStripeSDK.h; sourceTree = ""; }; 365BE8A1228CAB6A0068D824 /* STPIntentActionUseStripeSDK.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STPIntentActionUseStripeSDK.m; sourceTree = ""; }; @@ -2023,9 +2027,7 @@ 44BDCFDE245A46CC007EE6D5 /* STPPaymentMethodBancontactParamsTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STPPaymentMethodBancontactParamsTests.m; sourceTree = ""; }; 44BDCFE0245A4841007EE6D5 /* STPPaymentMethodBancontactTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STPPaymentMethodBancontactTests.m; sourceTree = ""; }; 4A0D74F918F6106100966D7B /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; - 69A6C2F7246D4A66005FF304 /* STPPaymentMethodEPS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = STPPaymentMethodEPS.h; sourceTree = ""; }; 69A6C2F9246D4AA0005FF304 /* STPPaymentMethodEPS.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STPPaymentMethodEPS.m; sourceTree = ""; }; - 69A6C2FB246D7869005FF304 /* STPPaymentMethodEPSParams.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = STPPaymentMethodEPSParams.h; sourceTree = ""; }; 69A6C2FD246D788D005FF304 /* STPPaymentMethodEPSParams.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STPPaymentMethodEPSParams.m; sourceTree = ""; }; 69A6C307246EA03E005FF304 /* STPPaymentMethodEPSTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STPPaymentMethodEPSTests.m; sourceTree = ""; }; 69A6C309246EA195005FF304 /* STPPaymentMethodEPSParamsTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = STPPaymentMethodEPSParamsTests.m; sourceTree = ""; }; @@ -3211,9 +3213,9 @@ 69A6C301246D8BD2005FF304 /* EPS */ = { isa = PBXGroup; children = ( - 69A6C2F7246D4A66005FF304 /* STPPaymentMethodEPS.h */, + 3656EF2E246F135400DA11CF /* STPPaymentMethodEPS.h */, 69A6C2F9246D4AA0005FF304 /* STPPaymentMethodEPS.m */, - 69A6C2FB246D7869005FF304 /* STPPaymentMethodEPSParams.h */, + 3656EF2D246F135400DA11CF /* STPPaymentMethodEPSParams.h */, 69A6C2FD246D788D005FF304 /* STPPaymentMethodEPSParams.m */, ); name = EPS; @@ -4041,6 +4043,7 @@ 319A609622E9186B00AACF66 /* STDSRuntimeErrorEvent.h in Headers */, B690DDED222F01BF000B902D /* STPPaymentMethodBillingDetails.h in Headers */, 3626618123C908BA00B13AE0 /* STPConfirmPaymentMethodOptions.h in Headers */, + 3656EF31246F135C00DA11CF /* STPPaymentMethodEPS.h in Headers */, B6B41F76223481C90020BA7F /* STPPaymentMethodCardWallet+Private.h in Headers */, 049E84EB1A605EF0000B66CD /* STPToken.h in Headers */, C124A17D1CCAA0C2007D42EE /* NSMutableURLRequest+Stripe.h in Headers */, @@ -4118,6 +4121,7 @@ 8BD87B8E1EFB152B00269C2B /* STPSourceRedirect+Private.h in Headers */, 319A608F22E9186B00AACF66 /* STDSJSONDecodable.h in Headers */, C184107C1EC2539F00178149 /* STPEphemeralKeyProvider.h in Headers */, + 3656EF32246F136200DA11CF /* STPPaymentMethodEPSParams.h in Headers */, 04B31DDB1D09A4DC00EF1631 /* STPPaymentConfiguration+Private.h in Headers */, 045D710F1CEEE30500F6CD65 /* STPAspects.h in Headers */, 04F94DAF1D229F59004FC826 /* STPPaymentOptionsViewController+Private.h in Headers */, @@ -4235,7 +4239,6 @@ B640DB1722C69A8E003C8810 /* STPSetupIntent+Private.h in Headers */, 049A3F7A1CC18D5300F57DE7 /* UIView+Stripe_FirstResponder.h in Headers */, 04CDB50E1A5F30A700B854EE /* STPCard.h in Headers */, - 69A6C2F8246D4A66005FF304 /* STPPaymentMethodEPS.h in Headers */, C1BD9B391E39416700CEE925 /* STPSourceOwner.h in Headers */, C1080F491CBECF7B007B2D89 /* STPAddress.h in Headers */, B604CF2122C56E9B00A23CC4 /* STPIntentActionRedirectToURL.h in Headers */, @@ -4301,6 +4304,7 @@ B6F16090223350640088C970 /* STPPaymentIntentAction.h in Headers */, 0731328F2277A3F60019CE3F /* STPPinManagementService.h in Headers */, 3604007222C18C78004CF80B /* STPThreeDSUICustomization.h in Headers */, + 3656EF30246F135400DA11CF /* STPPaymentMethodEPS.h in Headers */, B32B175E20F6D2C4000D6EF8 /* STPGenericStripeObject.h in Headers */, 366658B1240F20AD00D00354 /* STPPaymentMethodAUBECSDebitParams.h in Headers */, 36B8DDED241B00F600BB908E /* STPFormTextFieldContainer.h in Headers */, @@ -4373,7 +4377,6 @@ 04E39F541CECF7A100AF3B96 /* STPPaymentOptionTuple.h in Headers */, 3604007422C18C78004CF80B /* STPThreeDSSelectionCustomization.h in Headers */, 3604007522C18C78004CF80B /* STPThreeDSTextFieldCustomization.h in Headers */, - 69A6C2FC246D7869005FF304 /* STPPaymentMethodEPSParams.h in Headers */, 36B6CB9C235A3CF300331C38 /* STPMandateCustomerAcceptanceParams.h in Headers */, F15232241EA9303800D65C67 /* STPURLCallbackHandler.h in Headers */, C18410761EC2529400178149 /* STPEphemeralKeyManager.h in Headers */, @@ -4441,6 +4444,7 @@ 314B6A592384ABF9001FE708 /* STPSourceKlarnaDetails.h in Headers */, B6794A4922F4B5CC00E3AB41 /* STPConnectAccountCompanyParams.h in Headers */, 04793F561D1D8DDD00B3C551 /* STPSourceProtocol.h in Headers */, + 3656EF2F246F135400DA11CF /* STPPaymentMethodEPSParams.h in Headers */, 0451CC441C49AE1C003B2CA6 /* STPPaymentResult.h in Headers */, B690DDF2222F0211000B902D /* STPPaymentMethodAddress.h in Headers */, B61D4B912457671F001AEBEF /* STPPaymentIntentShippingDetails.h in Headers */, diff --git a/Stripe/STPPaymentMethodEPS.h b/Stripe/PublicHeaders/STPPaymentMethodEPS.h similarity index 100% rename from Stripe/STPPaymentMethodEPS.h rename to Stripe/PublicHeaders/STPPaymentMethodEPS.h diff --git a/Stripe/STPPaymentMethodEPSParams.h b/Stripe/PublicHeaders/STPPaymentMethodEPSParams.h similarity index 100% rename from Stripe/STPPaymentMethodEPSParams.h rename to Stripe/PublicHeaders/STPPaymentMethodEPSParams.h diff --git a/Stripe/Resources/Localizations/en.lproj/Localizable.strings b/Stripe/Resources/Localizations/en.lproj/Localizable.strings index f9cec7dae90..0cb663d96ff 100644 --- a/Stripe/Resources/Localizations/en.lproj/Localizable.strings +++ b/Stripe/Resources/Localizations/en.lproj/Localizable.strings @@ -77,7 +77,8 @@ /* Label for Email field on form */ "Email" = "Email"; -/* Source type brand name */ +/* Payment Method type brand name. + Source type brand name */ "EPS" = "EPS"; /* Placeholder string for email entry field. */ From 2ca5e8c4f67df4cf7f1fdf20b470b805e2ac60a4 Mon Sep 17 00:00:00 2001 From: Cameron Sabol Date: Fri, 15 May 2020 17:08:21 -0700 Subject: [PATCH 5/6] Cleanup --- .../Non-Card Payment Examples/EPSExampleViewController.m | 2 +- Stripe/PublicHeaders/STPPaymentMethodParams.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Example/Non-Card Payment Examples/EPSExampleViewController.m b/Example/Non-Card Payment Examples/EPSExampleViewController.m index 370353bd235..c6d52accfec 100644 --- a/Example/Non-Card Payment Examples/EPSExampleViewController.m +++ b/Example/Non-Card Payment Examples/EPSExampleViewController.m @@ -64,7 +64,7 @@ - (void)payButtonSelected { STPPaymentMethodEPSParams *eps = [[STPPaymentMethodEPSParams alloc] init]; // EPS does not require additional parameters so we only need to pass the init-ed - // STPPaymentMethoEPSParams instance to STPPaymentMethodParams + // STPPaymentMethodEPSParams instance to STPPaymentMethodParams paymentIntentParams.paymentMethodParams = [STPPaymentMethodParams paramsWithEPS:eps billingDetails:billingDetails metadata:nil]; diff --git a/Stripe/PublicHeaders/STPPaymentMethodParams.h b/Stripe/PublicHeaders/STPPaymentMethodParams.h index ea069e09bf8..717e09fd190 100644 --- a/Stripe/PublicHeaders/STPPaymentMethodParams.h +++ b/Stripe/PublicHeaders/STPPaymentMethodParams.h @@ -191,15 +191,15 @@ NS_ASSUME_NONNULL_BEGIN metadata:(nullable NSDictionary *)metadata; /** - Creates params for a giropay PaymentMethod; + Creates params for an EPS PaymentMethod; @param eps An object containing additional EPS details. - @param billingDetails An object containing the user's billing details. Note that `billingDetails.name` is required for giropay PaymentMethods. + @param billingDetails An object containing the user's billing details. Note that `billingDetails.name` is required for EPS PaymentMethods. @param metadata Additional information to attach to the PaymentMethod. */ + (nullable STPPaymentMethodParams *)paramsWithEPS:(STPPaymentMethodEPSParams *)eps - billingDetails:(STPPaymentMethodBillingDetails *)billingDetails - metadata:(nullable NSDictionary *)metadata; + billingDetails:(STPPaymentMethodBillingDetails *)billingDetails + metadata:(nullable NSDictionary *)metadata; /** Creates params for a Przelewy24 PaymentMethod; From ab37bf1c8945d89ef82388694972819b3d9b151f Mon Sep 17 00:00:00 2001 From: Shengwei Wu Date: Tue, 19 May 2020 09:30:57 +0800 Subject: [PATCH 6/6] Mark paramsWithEPS returns nonnull --- Stripe/PublicHeaders/STPPaymentMethodParams.h | 2 +- Stripe/STPPaymentMethodParams.m | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Stripe/PublicHeaders/STPPaymentMethodParams.h b/Stripe/PublicHeaders/STPPaymentMethodParams.h index 717e09fd190..d3290474dae 100644 --- a/Stripe/PublicHeaders/STPPaymentMethodParams.h +++ b/Stripe/PublicHeaders/STPPaymentMethodParams.h @@ -197,7 +197,7 @@ NS_ASSUME_NONNULL_BEGIN @param billingDetails An object containing the user's billing details. Note that `billingDetails.name` is required for EPS PaymentMethods. @param metadata Additional information to attach to the PaymentMethod. */ -+ (nullable STPPaymentMethodParams *)paramsWithEPS:(STPPaymentMethodEPSParams *)eps ++ (nonnull STPPaymentMethodParams *)paramsWithEPS:(STPPaymentMethodEPSParams *)eps billingDetails:(STPPaymentMethodBillingDetails *)billingDetails metadata:(nullable NSDictionary *)metadata; diff --git a/Stripe/STPPaymentMethodParams.m b/Stripe/STPPaymentMethodParams.m index 18e0669ff9e..7232d822b71 100644 --- a/Stripe/STPPaymentMethodParams.m +++ b/Stripe/STPPaymentMethodParams.m @@ -100,7 +100,7 @@ + (nullable STPPaymentMethodParams *)paramsWithGiropay:(STPPaymentMethodGiropayP return params; } -+ (nullable STPPaymentMethodParams *)paramsWithEPS:(STPPaymentMethodEPSParams *)eps ++ (nonnull STPPaymentMethodParams *)paramsWithEPS:(STPPaymentMethodEPSParams *)eps billingDetails:(STPPaymentMethodBillingDetails *)billingDetails metadata:(nullable NSDictionary *)metadata { STPPaymentMethodParams *params = [self new];