From d16d779cf99b5a454cbb8d1b55474eee9efa1e8b Mon Sep 17 00:00:00 2001 From: Budnikov Vyacheslav Date: Mon, 19 Dec 2016 17:54:01 +0300 Subject: [PATCH 1/3] ASDK-350 --- .../Request/Init/ASDKInitRequest.h | 4 +- .../Request/Init/ASDKInitRequest.m | 4 +- ASDKCore/ASDKAcquiringSdk.h | 1 + ASDKCore/ASDKAcquiringSdk.m | 4 +- ASDKCore/Info.plist | 2 +- ASDKCore/RequestBuilder/ASDKRequestBuilder.m | 15 ++++-- .../Init/ASDKInitRequestBuilder.h | 3 +- .../Init/ASDKInitRequestBuilder.m | 52 +++++++++++++++++-- ASDKUI/Info.plist | 2 +- .../ASDKPaymentFormStarter.h | 2 + .../ASDKPaymentFormStarter.m | 5 +- .../ASDKPaymentFormViewController.h | 1 + .../ASDKPaymentFormViewController.m | 8 ++- .../DetailInfoTableViewController.m | 2 + .../ASDKSampleApp/Source/PayController.h | 2 + .../ASDKSampleApp/Source/PayController.m | 6 ++- .../ShopCart/ShopCartTableViewController.m | 1 + .../ASDKSampleApp/Supporting files/Info.plist | 4 +- 18 files changed, 99 insertions(+), 19 deletions(-) diff --git a/ASDKCore/API Objects/Request/Init/ASDKInitRequest.h b/ASDKCore/API Objects/Request/Init/ASDKInitRequest.h index 9fe89dc..e088ed9 100644 --- a/ASDKCore/API Objects/Request/Init/ASDKInitRequest.h +++ b/ASDKCore/API Objects/Request/Init/ASDKInitRequest.h @@ -29,6 +29,7 @@ @property (nonatomic, copy) NSString *requestDescription; @property (nonatomic, copy) NSString *payForm; @property (nonatomic) BOOL recurrent; +@property (nonatomic, strong) NSDictionary *additionalPaymentData; - (ASDKInitRequest *)initWithTerminalKey:(NSString *)terminalKey amount:(NSNumber *)amount @@ -38,6 +39,7 @@ payForm:(NSString *)payForm payType:(NSString *)payType customerKey:(NSString *)customerKey - recurrent:(BOOL)recurrent; + recurrent:(BOOL)recurrent + additionalPaymentData:(NSDictionary *)data; @end diff --git a/ASDKCore/API Objects/Request/Init/ASDKInitRequest.m b/ASDKCore/API Objects/Request/Init/ASDKInitRequest.m index 0b6a507..7634987 100644 --- a/ASDKCore/API Objects/Request/Init/ASDKInitRequest.m +++ b/ASDKCore/API Objects/Request/Init/ASDKInitRequest.m @@ -31,6 +31,7 @@ - (ASDKInitRequest *)initWithTerminalKey:(NSString *)terminalKey payType:(NSString *)payType customerKey:(NSString *)customerKey recurrent:(BOOL)recurrent + additionalPaymentData:(NSDictionary *)data { ASDKInitRequest *request = [[ASDKInitRequest alloc] init]; @@ -46,8 +47,9 @@ - (ASDKInitRequest *)initWithTerminalKey:(NSString *)terminalKey request.payType = payType; request.customerKey = customerKey; request.recurrent = recurrent; + request.additionalPaymentData = data; } - + return request; } diff --git a/ASDKCore/ASDKAcquiringSdk.h b/ASDKCore/ASDKAcquiringSdk.h index b345558..657e775 100644 --- a/ASDKCore/ASDKAcquiringSdk.h +++ b/ASDKCore/ASDKAcquiringSdk.h @@ -63,6 +63,7 @@ payForm:(NSString *)payForm customerKey:(NSString *)customerKey recurrent:(BOOL)recurrent + additionalPaymentData:(NSDictionary *)data success:(void (^)(ASDKInitResponse *response))success failure:(void (^)(ASDKAcquringSdkError *error))failure; diff --git a/ASDKCore/ASDKAcquiringSdk.m b/ASDKCore/ASDKAcquiringSdk.m index 5dfcef8..120da9b 100644 --- a/ASDKCore/ASDKAcquiringSdk.m +++ b/ASDKCore/ASDKAcquiringSdk.m @@ -99,6 +99,7 @@ - (void)initWithAmount:(NSNumber *)amount payForm:(NSString *)payForm customerKey:(NSString *)customerKey recurrent:(BOOL)recurrent + additionalPaymentData:(NSDictionary *)data success:(void (^)(ASDKInitResponse *response))success failure:(void (^)(ASDKAcquringSdkError *error))failure { @@ -112,7 +113,8 @@ - (void)initWithAmount:(NSNumber *)amount customerKey:customerKey recurrent:recurrent terminalKey:self.terminalKey - password:self.password]; + password:self.password + additionalPaymentData:data]; ASDKInitRequest *request = (ASDKInitRequest *)[builder buildError:&buildError]; diff --git a/ASDKCore/Info.plist b/ASDKCore/Info.plist index c6f194e..3034b22 100644 --- a/ASDKCore/Info.plist +++ b/ASDKCore/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.1.1 + 1.1.2 CFBundleSignature ???? CFBundleVersion diff --git a/ASDKCore/RequestBuilder/ASDKRequestBuilder.m b/ASDKCore/RequestBuilder/ASDKRequestBuilder.m index 398b755..f01d1ce 100644 --- a/ASDKCore/RequestBuilder/ASDKRequestBuilder.m +++ b/ASDKCore/RequestBuilder/ASDKRequestBuilder.m @@ -57,9 +57,18 @@ - (NSString *)makeTokenWithParameters:(NSDictionary *)parameters if (![parameterValue isKindOfClass:[NSString class]]) { - parameterValue = [parameterValue stringValue]; - } - + if ([parameterValue isKindOfClass:[NSDictionary class]] || [parameterValue isKindOfClass:[NSArray class]]) + { + parameterValue = @""; + //NSData *data = [NSKeyedArchiver archivedDataWithRootObject:parameterValue]; + //parameterValue = [NSString stringWithFormat:@"%@", data]; + } + else + { + parameterValue = [NSString stringWithFormat:@"%@", parameterValue]; + } + } + [tokenString appendString:parameterValue]; } diff --git a/ASDKCore/RequestBuilder/Init/ASDKInitRequestBuilder.h b/ASDKCore/RequestBuilder/Init/ASDKInitRequestBuilder.h index f98fd47..51eeb36 100644 --- a/ASDKCore/RequestBuilder/Init/ASDKInitRequestBuilder.h +++ b/ASDKCore/RequestBuilder/Init/ASDKInitRequestBuilder.h @@ -30,6 +30,7 @@ customerKey:(NSString *)customerKey recurrent:(BOOL)recurrent terminalKey:(NSString *)terminalKey - password:(NSString *)password; + password:(NSString *)password + additionalPaymentData:(NSDictionary *)data; @end diff --git a/ASDKCore/RequestBuilder/Init/ASDKInitRequestBuilder.m b/ASDKCore/RequestBuilder/Init/ASDKInitRequestBuilder.m index 0c4bbc5..9c988b6 100644 --- a/ASDKCore/RequestBuilder/Init/ASDKInitRequestBuilder.m +++ b/ASDKCore/RequestBuilder/Init/ASDKInitRequestBuilder.m @@ -27,6 +27,7 @@ @interface ASDKInitRequestBuilder () @property (nonatomic, copy) NSString *payForm; @property (nonatomic, copy) NSString *payType; @property (nonatomic) BOOL recurrent; +@property (nonatomic, strong) NSDictionary *additionalPaymentData; @end @@ -41,6 +42,7 @@ + (ASDKInitRequestBuilder *)builderWithAmount:(NSNumber *)amount recurrent:(BOOL)recurrent terminalKey:(NSString *)terminalKey password:(NSString *)password + additionalPaymentData:(NSDictionary *)data { ASDKInitRequestBuilder *builder = [[ASDKInitRequestBuilder alloc] init]; @@ -55,8 +57,9 @@ + (ASDKInitRequestBuilder *)builderWithAmount:(NSNumber *)amount builder.recurrent = recurrent; builder.terminalKey = terminalKey; builder.password = password; + builder.additionalPaymentData = data; } - + return builder; } @@ -83,8 +86,9 @@ - (ASDKAcquiringRequest *)buildError:(ASDKAcquringSdkError **)error payForm:self.payForm payType:self.payType customerKey:self.customerKey - recurrent:self.recurrent]; - + recurrent:self.recurrent + additionalPaymentData:self.additionalPaymentData]; + return request; } @@ -163,6 +167,41 @@ - (void)validateError:(ASDKAcquringSdkError **)error return; } + + if ([self.additionalPaymentData count] > 0) + { + if ([self.additionalPaymentData objectForKey:@"Email"] == nil) + { + validationError = [ASDKAcquringSdkError errorWithMessage:kASDKDATA details:@"Обязательным является наличие дополнительного параметра Email" code:0]; + + [(ASDKAcquringSdkError *)validationError setIsSdkError:NO]; + + *error = validationError; + + return; + } + + BOOL invalidAdditionalPaymentData = NO; + if ([[self.additionalPaymentData allKeys] count] > 20) + { + invalidAdditionalPaymentData = YES; + } + else for (NSString *key in [self.additionalPaymentData allKeys]) + { + if ([key length] > 20 || [[self.additionalPaymentData objectForKey:key] length] > 100) + { + invalidAdditionalPaymentData = YES; + break; + } + } + + if (invalidAdditionalPaymentData == YES) + { + validationError = [ASDKAcquringSdkError errorWithMessage:kASDKDATA details:@"Ключ – 20 знаков, Значение – 100 знаков. Максимальное количество пар «ключ-значение» не может превышать 20." code:0]; + [(ASDKAcquringSdkError *)validationError setIsSdkError:NO]; + *error = validationError; + } + } } - (NSDictionary *)parametersForToken @@ -201,7 +240,12 @@ - (NSDictionary *)parametersForToken { [parameters setObject:@"Y" forKey:kASDKRecurrent]; } - + + if ([self.additionalPaymentData count] > 0) + { + [parameters setObject:self.additionalPaymentData forKey:kASDKDATA]; + } + return parameters; } diff --git a/ASDKUI/Info.plist b/ASDKUI/Info.plist index 1471aa2..740d659 100644 --- a/ASDKUI/Info.plist +++ b/ASDKUI/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.1.1 + 1.1.2 CFBundleSignature ???? CFBundleVersion diff --git a/ASDKUI/Payment/PaymentFormStarter/ASDKPaymentFormStarter.h b/ASDKUI/Payment/PaymentFormStarter/ASDKPaymentFormStarter.h index 1e3141e..c0c537a 100644 --- a/ASDKUI/Payment/PaymentFormStarter/ASDKPaymentFormStarter.h +++ b/ASDKUI/Payment/PaymentFormStarter/ASDKPaymentFormStarter.h @@ -66,6 +66,7 @@ cardId:(NSString *)cardId email:(NSString *)email customerKey:(NSString *)customerKey + additionalPaymentData:(NSDictionary *)data success:(void (^)(NSString *paymentId))onSuccess cancelled:(void (^)())onCancelled error:(void (^)(ASDKAcquringSdkError *error))onError; @@ -83,6 +84,7 @@ appleMerchantId:(NSString *)appleMerchantId shippingMethods:(NSArray *)shippingMethods shippingContact:(PKContact *)shippingContact + additionalPaymentData:(NSDictionary *)data success:(void (^)(NSString *paymentId))onSuccess cancelled:(void (^)())onCancelled error:(void (^)(ASDKAcquringSdkError *error))onError; diff --git a/ASDKUI/Payment/PaymentFormStarter/ASDKPaymentFormStarter.m b/ASDKUI/Payment/PaymentFormStarter/ASDKPaymentFormStarter.m index 8a4df18..0210d11 100644 --- a/ASDKUI/Payment/PaymentFormStarter/ASDKPaymentFormStarter.m +++ b/ASDKUI/Payment/PaymentFormStarter/ASDKPaymentFormStarter.m @@ -115,6 +115,7 @@ - (void)presentPaymentFormFromViewController:(UIViewController *)presentingViewC cardId:(NSString *)cardId email:(NSString *)email customerKey:(NSString *)customerKey + additionalPaymentData:(NSDictionary *)data success:(void (^)(NSString *paymentId))onSuccess cancelled:(void (^)())onCancelled error:(void(^)(ASDKAcquringSdkError *error))onError @@ -128,6 +129,7 @@ - (void)presentPaymentFormFromViewController:(UIViewController *)presentingViewC cardId:cardId email:email customerKey:customerKey + additionalPaymentData:data success:^(NSString *paymentId) { [ASDKPaymentFormStarter resetSharedInstance]; @@ -259,6 +261,7 @@ - (void)payWithApplePayFromViewController:(UIViewController *)presentingViewCont appleMerchantId:(NSString *)appleMerchantId shippingMethods:(NSArray *)shippingMethods shippingContact:(PKContact *)shippingContact + additionalPaymentData:(NSDictionary *)data success:(void (^)(NSString *paymentId))onSuccess cancelled:(void (^)())onCancelled error:(void (^)(ASDKAcquringSdkError *error))onError @@ -268,7 +271,7 @@ - (void)payWithApplePayFromViewController:(UIViewController *)presentingViewCont self.onError = onError; self.onCancelled = onCancelled; - [self.acquiringSdk initWithAmount:[NSNumber numberWithDouble:100 * amount.doubleValue] orderId:orderId description:nil payForm:nil customerKey:customerKey recurrent:NO + [self.acquiringSdk initWithAmount:[NSNumber numberWithDouble:100 * amount.doubleValue] orderId:orderId description:nil payForm:nil customerKey:customerKey recurrent:NO additionalPaymentData:data success:^(ASDKInitResponse *response){ self.paymentIdForApplePay = response.paymentId; diff --git a/ASDKUI/Payment/PaymentViewController/ASDKPaymentFormViewController.h b/ASDKUI/Payment/PaymentViewController/ASDKPaymentFormViewController.h index 1e9f2e7..b932fa6 100644 --- a/ASDKUI/Payment/PaymentViewController/ASDKPaymentFormViewController.h +++ b/ASDKUI/Payment/PaymentViewController/ASDKPaymentFormViewController.h @@ -33,6 +33,7 @@ cardId:(NSString *)cardId email:(NSString *)email customerKey:(NSString *)customerKey + additionalPaymentData:(NSDictionary *)data success:(void (^)(NSString *paymentId))success cancelled:(void (^)())cancelled error:(void(^)(ASDKAcquringSdkError *error))error; diff --git a/ASDKUI/Payment/PaymentViewController/ASDKPaymentFormViewController.m b/ASDKUI/Payment/PaymentViewController/ASDKPaymentFormViewController.m index cecdc56..6ab6271 100644 --- a/ASDKUI/Payment/PaymentViewController/ASDKPaymentFormViewController.m +++ b/ASDKUI/Payment/PaymentViewController/ASDKPaymentFormViewController.m @@ -87,6 +87,7 @@ @interface ASDKPaymentFormViewController () *)shippingMethods shippingContact:(PKContact *)shippingContact + additionalPaymentData:(NSDictionary *)data fromViewController:(UIViewController *)viewController success:(void (^)(NSString *paymentId))onSuccess cancelled:(void (^)())onCancelled diff --git a/SampleProject/ASDKSampleApp/Source/PayController.m b/SampleProject/ASDKSampleApp/Source/PayController.m index 0251187..9ea3fe3 100644 --- a/SampleProject/ASDKSampleApp/Source/PayController.m +++ b/SampleProject/ASDKSampleApp/Source/PayController.m @@ -39,6 +39,7 @@ + (NSString *)customerKey + (void)buyItemWithName:(NSString *)name description:(NSString *)description amount:(NSNumber *)amount + additionalPaymentData:(NSDictionary *)data fromViewController:(UIViewController *)viewController success:(void (^)(NSString *paymentId))onSuccess cancelled:(void (^)())onCancelled @@ -63,8 +64,9 @@ + (void)buyItemWithName:(NSString *)name title:name description:description cardId:nil - email:nil + email:nil customerKey:[PayController customerKey] + additionalPaymentData:data success:^(NSString *paymentId) { @@ -129,6 +131,7 @@ + (void)buyWithApplePayAmount:(NSNumber *)amount appleMerchantId:(NSString *)appleMerchantId shippingMethods:(NSArray *)shippingMethods shippingContact:(PKContact *)shippingContact + additionalPaymentData:(NSDictionary *)data fromViewController:(UIViewController *)viewController success:(void (^)(NSString *paymentId))onSuccess cancelled:(void (^)())onCancelled @@ -145,6 +148,7 @@ + (void)buyWithApplePayAmount:(NSNumber *)amount appleMerchantId:appleMerchantId shippingMethods:shippingMethods shippingContact:shippingContact + additionalPaymentData:data success:^(NSString *paymentId) { PaymentSuccessViewController *vc = [[PaymentSuccessViewController alloc] init]; vc.amount = amount; diff --git a/SampleProject/ASDKSampleApp/Source/ShopCart/ShopCartTableViewController.m b/SampleProject/ASDKSampleApp/Source/ShopCart/ShopCartTableViewController.m index 4a9b824..ccd474d 100644 --- a/SampleProject/ASDKSampleApp/Source/ShopCart/ShopCartTableViewController.m +++ b/SampleProject/ASDKSampleApp/Source/ShopCart/ShopCartTableViewController.m @@ -193,6 +193,7 @@ - (IBAction)buyAction:(id)sender [PayController buyItemWithName:NSLocalizedString(@"Books", @"Книги") description:NSLocalizedString(@"ALotOfBooks", @"Много книг") amount:[NSNumber numberWithDouble:_total] + additionalPaymentData:nil fromViewController:self success:^(NSString *paymentId) { diff --git a/SampleProject/ASDKSampleApp/Supporting files/Info.plist b/SampleProject/ASDKSampleApp/Supporting files/Info.plist index f691e80..b511008 100644 --- a/SampleProject/ASDKSampleApp/Supporting files/Info.plist +++ b/SampleProject/ASDKSampleApp/Supporting files/Info.plist @@ -15,11 +15,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.1.1 + 1.1.2 CFBundleSignature ???? CFBundleVersion - 28 + 29 LSRequiresIPhoneOS NSAppTransportSecurity From d6211370ac2e664108b59df9bec3503d5a42f0b1 Mon Sep 17 00:00:00 2001 From: Budnikov Vyacheslav Date: Mon, 19 Dec 2016 17:54:11 +0300 Subject: [PATCH 2/3] ASDK-350 --- .../Request/Init/ASDKInitRequest.h | 4 +- .../Request/Init/ASDKInitRequest.m | 2 +- ASDKCore/ASDKAcquiringApi.m | 7 ++- .../Init/ASDKInitRequestBuilder.m | 49 +++++++++++++++---- 4 files changed, 49 insertions(+), 13 deletions(-) diff --git a/ASDKCore/API Objects/Request/Init/ASDKInitRequest.h b/ASDKCore/API Objects/Request/Init/ASDKInitRequest.h index e088ed9..377f41f 100644 --- a/ASDKCore/API Objects/Request/Init/ASDKInitRequest.h +++ b/ASDKCore/API Objects/Request/Init/ASDKInitRequest.h @@ -29,7 +29,7 @@ @property (nonatomic, copy) NSString *requestDescription; @property (nonatomic, copy) NSString *payForm; @property (nonatomic) BOOL recurrent; -@property (nonatomic, strong) NSDictionary *additionalPaymentData; +@property (nonatomic, strong) NSString *additionalPaymentData; - (ASDKInitRequest *)initWithTerminalKey:(NSString *)terminalKey amount:(NSNumber *)amount @@ -40,6 +40,6 @@ payType:(NSString *)payType customerKey:(NSString *)customerKey recurrent:(BOOL)recurrent - additionalPaymentData:(NSDictionary *)data; + additionalPaymentData:(NSString *)data; @end diff --git a/ASDKCore/API Objects/Request/Init/ASDKInitRequest.m b/ASDKCore/API Objects/Request/Init/ASDKInitRequest.m index 7634987..9a0fb4c 100644 --- a/ASDKCore/API Objects/Request/Init/ASDKInitRequest.m +++ b/ASDKCore/API Objects/Request/Init/ASDKInitRequest.m @@ -31,7 +31,7 @@ - (ASDKInitRequest *)initWithTerminalKey:(NSString *)terminalKey payType:(NSString *)payType customerKey:(NSString *)customerKey recurrent:(BOOL)recurrent - additionalPaymentData:(NSDictionary *)data + additionalPaymentData:(NSString *)data { ASDKInitRequest *request = [[ASDKInitRequest alloc] init]; diff --git a/ASDKCore/ASDKAcquiringApi.m b/ASDKCore/ASDKAcquiringApi.m index 4d10b4e..6a85941 100644 --- a/ASDKCore/ASDKAcquiringApi.m +++ b/ASDKCore/ASDKAcquiringApi.m @@ -217,7 +217,12 @@ - (void)initWithRequest:(ASDKInitRequest *)request { [parameters setObject:@"Y" forKey:kASDKRecurrent]; } - + + if (request.additionalPaymentData) + { + [parameters setObject:request.additionalPaymentData forKey:kASDKDATA]; + } + [self path:kASDKAPIPathInit parameters:parameters success:^(NSDictionary *responseDictionary, NSURLResponse *response) diff --git a/ASDKCore/RequestBuilder/Init/ASDKInitRequestBuilder.m b/ASDKCore/RequestBuilder/Init/ASDKInitRequestBuilder.m index 9c988b6..2783fa0 100644 --- a/ASDKCore/RequestBuilder/Init/ASDKInitRequestBuilder.m +++ b/ASDKCore/RequestBuilder/Init/ASDKInitRequestBuilder.m @@ -27,7 +27,9 @@ @interface ASDKInitRequestBuilder () @property (nonatomic, copy) NSString *payForm; @property (nonatomic, copy) NSString *payType; @property (nonatomic) BOOL recurrent; -@property (nonatomic, strong) NSDictionary *additionalPaymentData; +@property (nonatomic, strong) NSString *additionalPaymentData; +@property (nonatomic, strong) NSDictionary *additionalPaymentData_; + @end @@ -57,7 +59,8 @@ + (ASDKInitRequestBuilder *)builderWithAmount:(NSNumber *)amount builder.recurrent = recurrent; builder.terminalKey = terminalKey; builder.password = password; - builder.additionalPaymentData = data; + builder.additionalPaymentData_ = data; + builder.additionalPaymentData = nil; } return builder; @@ -168,9 +171,9 @@ - (void)validateError:(ASDKAcquringSdkError **)error return; } - if ([self.additionalPaymentData count] > 0) + if ([self.additionalPaymentData_ count] > 0) { - if ([self.additionalPaymentData objectForKey:@"Email"] == nil) + if ([self.additionalPaymentData_ objectForKey:@"Email"] == nil) { validationError = [ASDKAcquringSdkError errorWithMessage:kASDKDATA details:@"Обязательным является наличие дополнительного параметра Email" code:0]; @@ -182,13 +185,13 @@ - (void)validateError:(ASDKAcquringSdkError **)error } BOOL invalidAdditionalPaymentData = NO; - if ([[self.additionalPaymentData allKeys] count] > 20) + if ([[self.additionalPaymentData_ allKeys] count] > 20) { invalidAdditionalPaymentData = YES; } - else for (NSString *key in [self.additionalPaymentData allKeys]) + else for (NSString *key in [self.additionalPaymentData_ allKeys]) { - if ([key length] > 20 || [[self.additionalPaymentData objectForKey:key] length] > 100) + if ([key length] > 20 || [[self.additionalPaymentData_ objectForKey:key] length] > 100) { invalidAdditionalPaymentData = YES; break; @@ -241,12 +244,40 @@ - (NSDictionary *)parametersForToken [parameters setObject:@"Y" forKey:kASDKRecurrent]; } - if ([self.additionalPaymentData count] > 0) + if ([self.additionalPaymentData_ count] > 0) { - [parameters setObject:self.additionalPaymentData forKey:kASDKDATA]; + + NSUInteger i = 0; + NSUInteger count = [[self.additionalPaymentData_ allKeys] count] - 1; + NSMutableString *strPostBody = [[NSMutableString alloc] init]; + for (NSString *key in [self.additionalPaymentData_ allKeys]) + { + NSString *data = [NSString stringWithFormat:@"%@=%@%@", [self encodeURL:key], [self encodeURL:[[self.additionalPaymentData_ objectForKey:key] description]], (i < count ? @"|" : @"")]; + [strPostBody appendString:data]; + i++; + } + + self.additionalPaymentData = strPostBody; + + [parameters setObject:strPostBody forKey:kASDKDATA]; } return parameters; } +- (NSString *)encodeURL:(NSString *)string +{ + NSString *newString = (__bridge_transfer NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, + (__bridge CFStringRef)string, + NULL, + (CFStringRef)@":/?#[]@!$ &'()*+,;=\"<>%{}|\\^~`", + CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding)); + if (newString) + { + return newString; + } + + return @""; +} + @end From f480e2dedf2321084d65e417c1727b000339f966 Mon Sep 17 00:00:00 2001 From: Budnikov Vyacheslav Date: Mon, 19 Dec 2016 18:50:39 +0300 Subject: [PATCH 3/3] ASDK-350 --- .../Init/ASDKInitRequestBuilder.m | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/ASDKCore/RequestBuilder/Init/ASDKInitRequestBuilder.m b/ASDKCore/RequestBuilder/Init/ASDKInitRequestBuilder.m index 2783fa0..965c4c4 100644 --- a/ASDKCore/RequestBuilder/Init/ASDKInitRequestBuilder.m +++ b/ASDKCore/RequestBuilder/Init/ASDKInitRequestBuilder.m @@ -267,11 +267,18 @@ - (NSDictionary *)parametersForToken - (NSString *)encodeURL:(NSString *)string { - NSString *newString = (__bridge_transfer NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, - (__bridge CFStringRef)string, - NULL, - (CFStringRef)@":/?#[]@!$ &'()*+,;=\"<>%{}|\\^~`", - CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding)); +// NSMutableCharacterSet * characterSet = [NSMutableCharacterSet URLQueryAllowedCharacterSet]; +// NSString *newString = [string stringByAddingPercentEncodingWithAllowedCharacters:characterSet]; + + NSMutableCharacterSet * characterSet = [NSMutableCharacterSet characterSetWithCharactersInString:@":/?#[]@!$ &'()*+,;=\"<>%{}|\\^~`"]; + [characterSet invert]; + NSString *newString = [string stringByAddingPercentEncodingWithAllowedCharacters:characterSet]; + +// NSString *newString = (__bridge_transfer NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, +// (__bridge CFStringRef)string, +// NULL, +// (CFStringRef)@":/?#[]@!$ &'()*+,;=\"<>%{}|\\^~`", +// CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding)); if (newString) { return newString;