Commit 3fe05c4f by Dima Bart

Convert getCompletionStatus to use token.

parent 28bce436
...@@ -138,15 +138,15 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError * ...@@ -138,15 +138,15 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError *
- (BUYOperation *)completeCheckout:(BUYCheckout *)checkout paymentToken:(_Nullable id<BUYPaymentToken>)paymentToken completion:(BUYDataCheckoutBlock)block; - (BUYOperation *)completeCheckout:(BUYCheckout *)checkout paymentToken:(_Nullable id<BUYPaymentToken>)paymentToken completion:(BUYDataCheckoutBlock)block;
/** /**
* Retrieve the status of a BUYCheckout. This checks the status of the current payment processing job for the provided checkout. * Retrieve the status of a checkout with token. This checks the status of the current payment processing job for the provided checkout.
* Once the job is complete (status == BUYStatusComplete), you can retrieve the completed order by calling `getCheckout:completion` * Once the job is complete (status == BUYStatusComplete), you can retrieve the completed order by calling `getCheckout:completion`
* *
* @param checkout The BUYCheckout to retrieve completion status for * @param checkoutToken The checkout token for which to retrieve completion status
* @param block (^BUYDataStatusBlock)(BUYCheckout *checkout, BUYStatus status, NSError *error); * @param block (^BUYDataStatusBlock)(BUYCheckout *checkout, BUYStatus status, NSError *error);
* *
* @return The associated BUYRequestOperation * @return The associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)getCompletionStatusOfCheckout:(BUYCheckout *)checkout completion:(BUYDataStatusBlock)block; - (BUYRequestOperation *)getCompletionStatusOfCheckoutWithToken:(NSString *)checkoutToken completion:(BUYDataStatusBlock)block;
/** /**
* Retrieve the status of a checkout given a URL obtained in the UIApplicationDelegate method `application:sourceApplication:annotation` * Retrieve the status of a checkout given a URL obtained in the UIApplicationDelegate method `application:sourceApplication:annotation`
......
...@@ -98,11 +98,10 @@ ...@@ -98,11 +98,10 @@
return operation; return operation;
} }
- (BUYRequestOperation *)getCompletionStatusOfCheckout:(BUYCheckout *)checkout completion:(BUYDataStatusBlock)block - (BUYRequestOperation *)getCompletionStatusOfCheckoutWithToken:(NSString *)checkoutToken completion:(BUYDataStatusBlock)block
{ {
BUYAssertCheckout(checkout); BUYAssertToken(checkoutToken);
return [self getCompletionStatusOfCheckoutWithToken:checkoutToken start:YES completion:block];
return [self getCompletionStatusOfCheckoutToken:checkout.token start:YES completion:block];
} }
- (BUYRequestOperation *)getCompletionStatusOfCheckoutURL:(NSURL *)url completion:(BUYDataStatusBlock)block - (BUYRequestOperation *)getCompletionStatusOfCheckoutURL:(NSURL *)url completion:(BUYDataStatusBlock)block
...@@ -119,7 +118,7 @@ ...@@ -119,7 +118,7 @@
BUYAssert(token, @"Failed to get completion status of checkout. Checkout URL must have a valid token associated with it."); BUYAssert(token, @"Failed to get completion status of checkout. Checkout URL must have a valid token associated with it.");
return [self getCompletionStatusOfCheckoutToken:token start:YES completion:block]; return [self getCompletionStatusOfCheckoutWithToken:token start:YES completion:block];
} }
#pragma mark - Checkout Helpers - #pragma mark - Checkout Helpers -
...@@ -138,7 +137,7 @@ ...@@ -138,7 +137,7 @@
}]; }];
} }
- (BUYRequestOperation *)getCompletionStatusOfCheckoutToken:(NSString *)token start:(BOOL)start completion:(BUYDataStatusBlock)block - (BUYRequestOperation *)getCompletionStatusOfCheckoutWithToken:(NSString *)token start:(BOOL)start completion:(BUYDataStatusBlock)block
{ {
NSURL *url = [self urlForCheckoutsProcessingWithToken:token]; NSURL *url = [self urlForCheckoutsProcessingWithToken:token];
return [self getRequestForURL:url start:start completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) { return [self getRequestForURL:url start:start completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) {
......
...@@ -63,7 +63,7 @@ typedef void (^BUYClientRequestJSONCompletion)(NSDictionary *json, NSHTTPURLResp ...@@ -63,7 +63,7 @@ typedef void (^BUYClientRequestJSONCompletion)(NSDictionary *json, NSHTTPURLResp
@interface BUYClient (PrivateCheckout) @interface BUYClient (PrivateCheckout)
- (BUYRequestOperation *)beginCheckout:(BUYCheckout *)checkout paymentToken:(id<BUYPaymentToken>)paymentToken completion:(BUYDataCheckoutBlock)block; - (BUYRequestOperation *)beginCheckout:(BUYCheckout *)checkout paymentToken:(id<BUYPaymentToken>)paymentToken completion:(BUYDataCheckoutBlock)block;
- (BUYRequestOperation *)getCompletionStatusOfCheckoutToken:(NSString *)token start:(BOOL)start completion:(BUYDataStatusBlock)block; - (BUYRequestOperation *)getCompletionStatusOfCheckoutWithToken:(NSString *)token start:(BOOL)start completion:(BUYDataStatusBlock)block;
- (BUYRequestOperation *)getCheckout:(BUYCheckout *)checkout start:(BOOL)start completion:(BUYDataCheckoutBlock)block; - (BUYRequestOperation *)getCheckout:(BUYCheckout *)checkout start:(BOOL)start completion:(BUYDataCheckoutBlock)block;
@end @end
...@@ -147,7 +147,7 @@ ...@@ -147,7 +147,7 @@
- (BUYRequestOperation *)createPollOperation - (BUYRequestOperation *)createPollOperation
{ {
BUYRequestOperation *operation =[self.client getCompletionStatusOfCheckoutToken:self.checkout.token start:NO completion:^(BUYStatus status, NSError *error) { BUYRequestOperation *operation =[self.client getCompletionStatusOfCheckoutWithToken:self.checkout.token start:NO completion:^(BUYStatus status, NSError *error) {
if (status != BUYStatusComplete) { if (status != BUYStatusComplete) {
[self finishWithError:error]; [self finishWithError:error];
} }
......
...@@ -295,7 +295,7 @@ const NSTimeInterval PollDelay = 0.5; ...@@ -295,7 +295,7 @@ const NSTimeInterval PollDelay = 0.5;
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
while (checkout.token && checkoutStatus != BUYStatusFailed && checkoutStatus != BUYStatusComplete) { while (checkout.token && checkoutStatus != BUYStatusFailed && checkoutStatus != BUYStatusComplete) {
[self.client getCompletionStatusOfCheckout:self.checkout completion:^(BUYStatus status, NSError *error) { [self.client getCompletionStatusOfCheckoutWithToken:self.checkout.token completion:^(BUYStatus status, NSError *error) {
checkoutStatus = status; checkoutStatus = status;
self.lastError = error; self.lastError = error;
dispatch_semaphore_signal(semaphore); dispatch_semaphore_signal(semaphore);
......
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