Commit 5ee41564 by Dima Bart

Refactor error checking in callbacks to be consistent across client.

parent b952e5a3
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
{ {
NSURLComponents *components = [self URLComponentsForCustomers]; NSURLComponents *components = [self URLComponentsForCustomers];
return [self postRequestForURL:components.URL object:credentials.JSONRepresentation completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) { return [self postRequestForURL:components.URL object:credentials.JSONRepresentation completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) {
if (json && error == nil) { if (json && !error) {
[self createTokenForCustomerWithCredentials:credentials customerJSON:json callback:block]; [self createTokenForCustomerWithCredentials:credentials customerJSON:json callback:block];
} }
else { else {
...@@ -83,11 +83,11 @@ ...@@ -83,11 +83,11 @@
{ {
NSURLComponents *components = [self URLComponentsForCustomerLogin]; NSURLComponents *components = [self URLComponentsForCustomerLogin];
return [self postRequestForURL:components.URL object:credentials.JSONRepresentation completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) { return [self postRequestForURL:components.URL object:credentials.JSONRepresentation completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) {
if (json && error == nil) { if (json && !error) {
BUYAuthenticatedResponse *authenticatedResponse = [BUYAuthenticatedResponse responseFromJSON:json]; BUYAuthenticatedResponse *authenticatedResponse = [BUYAuthenticatedResponse responseFromJSON:json];
self.customerToken = authenticatedResponse.accessToken; self.customerToken = authenticatedResponse.accessToken;
if (customerJSON == nil) { if (!customerJSON) {
[self getCustomerWithID:authenticatedResponse.customerID callback:^(BUYCustomer *customer, NSError *error) { [self getCustomerWithID:authenticatedResponse.customerID callback:^(BUYCustomer *customer, NSError *error) {
block(customer, self.customerToken, error); block(customer, self.customerToken, error);
}]; }];
...@@ -114,7 +114,9 @@ ...@@ -114,7 +114,9 @@
return [self postRequestForURL:components.URL object:@{@"email": email} completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) { return [self postRequestForURL:components.URL object:@{@"email": email} completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) {
NSInteger statusCode = [(NSHTTPURLResponse *)response statusCode]; NSInteger statusCode = [(NSHTTPURLResponse *)response statusCode];
error = error ?: [self extractErrorFromResponse:response json:json]; if (!error) {
error = [self extractErrorFromResponse:response json:json];
}
block(statusCode, error); block(statusCode, error);
}]; }];
...@@ -128,12 +130,14 @@ ...@@ -128,12 +130,14 @@
return [self putRequestForURL:components.URL body:nil completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) { return [self putRequestForURL:components.URL body:nil completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) {
NSString *accessToken = nil; NSString *accessToken = nil;
if (json && error == nil) { if (json && !error) {
BUYAuthenticatedResponse *authenticatedResponse = [BUYAuthenticatedResponse responseFromJSON:json]; BUYAuthenticatedResponse *authenticatedResponse = [BUYAuthenticatedResponse responseFromJSON:json];
accessToken = authenticatedResponse.accessToken; accessToken = authenticatedResponse.accessToken;
} }
error = error ?: [self extractErrorFromResponse:response json:json]; if (!error) {
error = [self extractErrorFromResponse:response json:json];
}
block(accessToken, error); block(accessToken, error);
}]; }];
...@@ -150,7 +154,7 @@ ...@@ -150,7 +154,7 @@
NSData *data = [NSJSONSerialization dataWithJSONObject:credentials.JSONRepresentation options:0 error:nil]; NSData *data = [NSJSONSerialization dataWithJSONObject:credentials.JSONRepresentation options:0 error:nil];
return [self putRequestForURL:components.URL body:data completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) { return [self putRequestForURL:components.URL body:data completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) {
if (json && error == nil) { if (json && !error) {
BUYAccountCredentialItem *emailItem = [BUYAccountCredentialItem itemWithKey:@"email" value:json[@"customer"][@"email"]]; BUYAccountCredentialItem *emailItem = [BUYAccountCredentialItem itemWithKey:@"email" value:json[@"customer"][@"email"]];
credentials[@"email"] = emailItem; credentials[@"email"] = emailItem;
[self loginCustomerWithCredentials:credentials callback:block]; [self loginCustomerWithCredentials:credentials callback:block];
...@@ -167,7 +171,7 @@ ...@@ -167,7 +171,7 @@
NSData *data = [NSJSONSerialization dataWithJSONObject:credentials.JSONRepresentation options:0 error:nil]; NSData *data = [NSJSONSerialization dataWithJSONObject:credentials.JSONRepresentation options:0 error:nil];
return [self putRequestForURL:components.URL body:data completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) { return [self putRequestForURL:components.URL body:data completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) {
if (json && error == nil) { if (json && !error) {
BUYAccountCredentialItem *emailItem = [BUYAccountCredentialItem itemWithKey:@"email" value:json[@"customer"][@"email"]]; BUYAccountCredentialItem *emailItem = [BUYAccountCredentialItem itemWithKey:@"email" value:json[@"customer"][@"email"]];
credentials[@"email"] = emailItem; credentials[@"email"] = emailItem;
[self loginCustomerWithCredentials:credentials callback:block]; [self loginCustomerWithCredentials:credentials callback:block];
...@@ -183,7 +187,7 @@ ...@@ -183,7 +187,7 @@
NSURLComponents *components = [self URLComponentsForCustomerOrders]; NSURLComponents *components = [self URLComponentsForCustomerOrders];
return [self getRequestForURL:components.URL completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) { return [self getRequestForURL:components.URL completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) {
NSArray *ordersJSON = json[@"orders"]; NSArray *ordersJSON = json[@"orders"];
if (!error && ordersJSON) { if (ordersJSON && !error) {
NSMutableArray *container = [NSMutableArray new]; NSMutableArray *container = [NSMutableArray new];
for (NSDictionary *orderJSON in ordersJSON) { for (NSDictionary *orderJSON in ordersJSON) {
......
...@@ -127,7 +127,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token ...@@ -127,7 +127,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
return [self getRequestForURL:shopComponents.URL completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) { return [self getRequestForURL:shopComponents.URL completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) {
BUYShop *shop = nil; BUYShop *shop = nil;
if (json && error == nil) { if (json && !error) {
shop = [[BUYShop alloc] initWithDictionary:json]; shop = [[BUYShop alloc] initWithDictionary:json];
} }
block(shop, error); block(shop, error);
...@@ -143,7 +143,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token ...@@ -143,7 +143,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
return [self getRequestForURL:components.URL completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) { return [self getRequestForURL:components.URL completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) {
NSArray *products = nil; NSArray *products = nil;
if (json && error == nil) { if (json && !error) {
products = [BUYProduct convertJSONArray:json[kBUYClientPathProductPublications]]; products = [BUYProduct convertJSONArray:json[kBUYClientPathProductPublications]];
} }
block(products, page, [self hasReachedEndOfPage:products] || error, error); block(products, page, [self hasReachedEndOfPage:products] || error, error);
...@@ -153,10 +153,10 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token ...@@ -153,10 +153,10 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
- (NSURLSessionDataTask *)getProductById:(NSString *)productId completion:(BUYDataProductBlock)block; - (NSURLSessionDataTask *)getProductById:(NSString *)productId completion:(BUYDataProductBlock)block;
{ {
return [self getProductsByIds:@[productId] completion:^(NSArray *products, NSError *error) { return [self getProductsByIds:@[productId] completion:^(NSArray *products, NSError *error) {
if ([products count]) { if (products.count > 0) {
block(products[0], error); block(products[0], error);
} else { } else {
if (error == nil && [products count] == 0) { if (!error) {
error = [NSError errorWithDomain:kShopifyError code:BUYShopifyError_InvalidProductID userInfo:@{ NSLocalizedDescriptionKey : @"Product ID is not valid. Confirm the product ID on your shop's admin and also ensure that the visibility is on for the Mobile App channel." }]; error = [NSError errorWithDomain:kShopifyError code:BUYShopifyError_InvalidProductID userInfo:@{ NSLocalizedDescriptionKey : @"Product ID is not valid. Confirm the product ID on your shop's admin and also ensure that the visibility is on for the Mobile App channel." }];
} }
block(nil, error); block(nil, error);
...@@ -172,10 +172,10 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token ...@@ -172,10 +172,10 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
return [self getRequestForURL:components.URL completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) { return [self getRequestForURL:components.URL completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) {
NSArray *products = nil; NSArray *products = nil;
if (json && error == nil) { if (json && !error) {
products = [BUYProduct convertJSONArray:json[kBUYClientPathProductPublications]]; products = [BUYProduct convertJSONArray:json[kBUYClientPathProductPublications]];
} }
if (error == nil && [products count] == 0) { if (!error && products.count == 0) {
error = [NSError errorWithDomain:kShopifyError code:BUYShopifyError_InvalidProductID userInfo:@{ NSLocalizedDescriptionKey : @"Product IDs are not valid. Confirm the product IDs on your shop's admin and also ensure that the visibility is on for the Mobile App channel." }]; error = [NSError errorWithDomain:kShopifyError code:BUYShopifyError_InvalidProductID userInfo:@{ NSLocalizedDescriptionKey : @"Product IDs are not valid. Confirm the product IDs on your shop's admin and also ensure that the visibility is on for the Mobile App channel." }];
} }
block(products, error); block(products, error);
...@@ -197,7 +197,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token ...@@ -197,7 +197,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
return [self getRequestForURL:components.URL completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) { return [self getRequestForURL:components.URL completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) {
NSArray *collections = nil; NSArray *collections = nil;
if (json && error == nil) { if (json && !error) {
collections = [BUYCollection convertJSONArray:json[kBUYClientPathCollectionPublications]]; collections = [BUYCollection convertJSONArray:json[kBUYClientPathCollectionPublications]];
} }
block(collections, page, [self hasReachedEndOfPage:collections], error); block(collections, page, [self hasReachedEndOfPage:collections], error);
...@@ -222,7 +222,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token ...@@ -222,7 +222,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
task = [self getRequestForURL:components.URL completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) { task = [self getRequestForURL:components.URL completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) {
NSArray *products = nil; NSArray *products = nil;
if (json && error == nil) { if (json && !error) {
products = [BUYProduct convertJSONArray:json[kBUYClientPathProductPublications]]; products = [BUYProduct convertJSONArray:json[kBUYClientPathProductPublications]];
} }
block(products, page, [self hasReachedEndOfPage:products] || error, error); block(products, page, [self hasReachedEndOfPage:products] || error, error);
...@@ -294,7 +294,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token ...@@ -294,7 +294,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
- (void)handleCheckoutResponse:(NSDictionary *)json error:(NSError *)error block:(BUYDataCheckoutBlock)block - (void)handleCheckoutResponse:(NSDictionary *)json error:(NSError *)error block:(BUYDataCheckoutBlock)block
{ {
BUYCheckout *checkout = nil; BUYCheckout *checkout = nil;
if (error == nil) { if (!error) {
checkout = [[BUYCheckout alloc] initWithDictionary:json[@"checkout"]]; checkout = [[BUYCheckout alloc] initWithDictionary:json[@"checkout"]];
} }
block(checkout, error); block(checkout, error);
...@@ -334,7 +334,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token ...@@ -334,7 +334,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
NSError *error = nil; NSError *error = nil;
NSData *data = [NSJSONSerialization dataWithJSONObject:checkoutJSON options:0 error:&error]; NSData *data = [NSJSONSerialization dataWithJSONObject:checkoutJSON options:0 error:&error];
if (data && error == nil) { if (data && !error) {
NSURLComponents *components = [self URLComponentsForCheckoutsAppendingPath:nil checkoutToken:nil queryItems:nil]; NSURLComponents *components = [self URLComponentsForCheckoutsAppendingPath:nil checkoutToken:nil queryItems:nil];
task = [self postRequestForURL:components.URL body:data completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) { task = [self postRequestForURL:components.URL body:data completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) {
...@@ -360,7 +360,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token ...@@ -360,7 +360,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
task = [self postRequestForURL:components.URL task = [self postRequestForURL:components.URL
object:giftCard object:giftCard
completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) { completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) {
if (error == nil) { if (!error) {
[self updateCheckout:checkout withGiftCardDictionary:json[@"gift_card"] addingGiftCard:YES]; [self updateCheckout:checkout withGiftCardDictionary:json[@"gift_card"] addingGiftCard:YES];
} }
block(checkout, error); block(checkout, error);
...@@ -378,7 +378,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token ...@@ -378,7 +378,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
checkoutToken:checkout.token checkoutToken:checkout.token
queryItems:nil]; queryItems:nil];
task = [self deleteRequestForURL:components.URL completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) { task = [self deleteRequestForURL:components.URL completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) {
if (error == nil) { if (!error) {
[self updateCheckout:checkout withGiftCardDictionary:json[@"gift_card"] addingGiftCard:NO]; [self updateCheckout:checkout withGiftCardDictionary:json[@"gift_card"] addingGiftCard:NO];
} }
block(checkout, error); block(checkout, error);
...@@ -450,7 +450,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token ...@@ -450,7 +450,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
data = [NSJSONSerialization dataWithJSONObject:paymentJson options:0 error:&error]; data = [NSJSONSerialization dataWithJSONObject:paymentJson options:0 error:&error];
} }
if ((data && error == nil) || (checkout.paymentDue && checkout.paymentDue.floatValue == 0)) { if ((data && !error) || (checkout.paymentDue && checkout.paymentDue.floatValue == 0)) {
task = [self checkoutCompletionRequestWithCheckout:checkout body:data completion:block]; task = [self checkoutCompletionRequestWithCheckout:checkout body:data completion:block];
} }
} }
...@@ -470,7 +470,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token ...@@ -470,7 +470,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
if ([checkout hasToken] == NO) { if ([checkout hasToken] == NO) {
block(nil, [NSError errorWithDomain:kShopifyError code:BUYShopifyError_InvalidCheckoutObject userInfo:nil]); block(nil, [NSError errorWithDomain:kShopifyError code:BUYShopifyError_InvalidCheckoutObject userInfo:nil]);
} }
else if (token == nil) { else if (!token) {
block(nil, [NSError errorWithDomain:kShopifyError code:BUYShopifyError_NoApplePayTokenSpecified userInfo:nil]); block(nil, [NSError errorWithDomain:kShopifyError code:BUYShopifyError_NoApplePayTokenSpecified userInfo:nil]);
} }
else { else {
...@@ -478,7 +478,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token ...@@ -478,7 +478,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
NSDictionary *paymentJson = @{ @"payment_token" : @{ @"payment_data" : tokenString, @"type" : @"apple_pay" }}; NSDictionary *paymentJson = @{ @"payment_token" : @{ @"payment_data" : tokenString, @"type" : @"apple_pay" }};
NSError *error = nil; NSError *error = nil;
NSData *data = [NSJSONSerialization dataWithJSONObject:paymentJson options:0 error:&error]; NSData *data = [NSJSONSerialization dataWithJSONObject:paymentJson options:0 error:&error];
if (data && error == nil) { if (data && !error) {
task = [self checkoutCompletionRequestWithCheckout:checkout body:data completion:block]; task = [self checkoutCompletionRequestWithCheckout:checkout body:data completion:block];
} }
else { else {
...@@ -555,7 +555,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token ...@@ -555,7 +555,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
NSURLComponents *components = [self URLComponentsForCheckoutsAppendingPath:@"shipping_rates" checkoutToken:checkout.token queryItems:@{ @"checkout" : @"" }]; NSURLComponents *components = [self URLComponentsForCheckoutsAppendingPath:@"shipping_rates" checkoutToken:checkout.token queryItems:@{ @"checkout" : @"" }];
task = [self getRequestForURL:components.URL completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) { task = [self getRequestForURL:components.URL completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) {
NSArray *shippingRates = nil; NSArray *shippingRates = nil;
if (error == nil && json) { if (json && !error) {
shippingRates = [BUYShippingRate convertJSONArray:json[@"shipping_rates"]]; shippingRates = [BUYShippingRate convertJSONArray:json[@"shipping_rates"]];
} }
...@@ -578,7 +578,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token ...@@ -578,7 +578,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
if ([checkout hasToken] == NO) { if ([checkout hasToken] == NO) {
block(nil, nil, [NSError errorWithDomain:kShopifyError code:BUYShopifyError_InvalidCheckoutObject userInfo:nil]); block(nil, nil, [NSError errorWithDomain:kShopifyError code:BUYShopifyError_InvalidCheckoutObject userInfo:nil]);
} }
else if (creditCard == nil) { else if (!creditCard) {
block(nil, nil, [NSError errorWithDomain:kShopifyError code:BUYShopifyError_NoCreditCardSpecified userInfo:nil]); block(nil, nil, [NSError errorWithDomain:kShopifyError code:BUYShopifyError_NoCreditCardSpecified userInfo:nil]);
} }
else { else {
...@@ -591,7 +591,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token ...@@ -591,7 +591,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
NSError *error = nil; NSError *error = nil;
NSData *data = [NSJSONSerialization dataWithJSONObject:@{ @"checkout" : json } options:0 error:&error]; NSData *data = [NSJSONSerialization dataWithJSONObject:@{ @"checkout" : json } options:0 error:&error];
if (data && error == nil) { if (data && !error) {
task = [self postPaymentRequestWithCheckout:checkout body:data completion:block]; task = [self postPaymentRequestWithCheckout:checkout body:data completion:block];
} }
else { else {
...@@ -647,7 +647,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token ...@@ -647,7 +647,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
NSError *error = nil; NSError *error = nil;
NSData *data = [NSJSONSerialization dataWithJSONObject:json options:0 error:&error]; NSData *data = [NSJSONSerialization dataWithJSONObject:json options:0 error:&error];
NSURLSessionDataTask *task = nil; NSURLSessionDataTask *task = nil;
if (error == nil && data) { if (data && !error) {
task = [self requestForURL:url method:method body:data completionHandler:completionHandler]; task = [self requestForURL:url method:method body:data completionHandler:completionHandler];
} }
return task; return task;
...@@ -683,7 +683,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token ...@@ -683,7 +683,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
} }
else { else {
//2 is the minimum amount of data {} for a JSON Object. Just ignore anything less. //2 is the minimum amount of data {} for a JSON Object. Just ignore anything less.
if ((error == nil || failedValidation) && [data length] > 2) { if ((!error || failedValidation) && [data length] > 2) {
id jsonData = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error]; id jsonData = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
json = [jsonData isKindOfClass:[NSDictionary class]] ? jsonData : nil; json = [jsonData isKindOfClass:[NSDictionary class]] ? jsonData : nil;
} }
...@@ -704,7 +704,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token ...@@ -704,7 +704,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
{ {
return [self requestForURL:checkout.paymentURL method:kPOST body:body completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) { return [self requestForURL:checkout.paymentURL method:kPOST body:body completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) {
NSString *paymentSessionId = nil; NSString *paymentSessionId = nil;
if (error == nil) { if (!error) {
paymentSessionId = json[@"id"]; paymentSessionId = json[@"id"];
checkout.paymentSessionId = paymentSessionId; checkout.paymentSessionId = paymentSessionId;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment