Commit 5a5ff89b by Dima Bart

Refactor post checkout to assert instead of return error.

parent 3b7520ca
......@@ -336,19 +336,14 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
- (NSURLSessionDataTask *)postCheckout:(NSDictionary *)checkoutJSON completion:(BUYDataCheckoutBlock)block
{
NSURLSessionDataTask *task = nil;
NSError *error = nil;
NSData *data = [NSJSONSerialization dataWithJSONObject:checkoutJSON options:0 error:&error];
NSData *data = [NSJSONSerialization dataWithJSONObject:checkoutJSON options:0 error:nil];
NSAssert(data, @"Failed to post checkout. Could not serialize JSON payload. Possibly invalid checkout object.");
if (data && !error) {
NSURLComponents *components = [self URLComponentsForCheckoutsAppendingPath:nil checkoutToken:nil queryItems:nil];
task = [self postRequestForURL:components.URL body:data completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) {
return [self postRequestForURL:components.URL body:data completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) {
[self handleCheckoutResponse:json error:error block:block];
}];
}
return task;
}
- (NSURLSessionDataTask *)applyGiftCardWithCode:(NSString *)giftCardCode toCheckout:(BUYCheckout *)checkout completion:(BUYDataCheckoutBlock)block
......
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