Commit 2ebce1d6 by HouWeiBin

1,第二次尝试修改订单 使dictionary能拿到(第一次修改的结果导致配送费无法正常使用)

parent 461a6636
...@@ -49,7 +49,7 @@ typedef void (^BUYDataCreditCardBlock)(id<BUYPaymentToken> _Nullable paymentToke ...@@ -49,7 +49,7 @@ typedef void (^BUYDataCreditCardBlock)(id<BUYPaymentToken> _Nullable paymentToke
* @param checkout The returned BUYCheckout * @param checkout The returned BUYCheckout
* @param error Optional NSError * @param error Optional NSError
*/ */
typedef void (^BUYDataCheckoutBlock)(BUYCheckout * _Nullable checkout, NSError * _Nullable error); typedef void (^BUYDataCheckoutBlock)(NSDictionary *_Nullable dictionary,BUYCheckout * _Nullable checkout, NSError * _Nullable error);
/** /**
* Return block containing BUYShippingRate objects, a BUYStatus and/or an NSError * Return block containing BUYShippingRate objects, a BUYStatus and/or an NSError
......
...@@ -182,11 +182,12 @@ ...@@ -182,11 +182,12 @@
- (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;
NSDictionary *dictionary = nil;
if (json && !error) { if (json && !error) {
checkout = [self.modelManager insertCheckoutWithJSONDictionary:json[@"checkout"]]; checkout = [self.modelManager insertCheckoutWithJSONDictionary:json[@"checkout"]];
checkout.JSONDictionary = json[@"checkout"]; dictionary = json[@"checkout"];
} }
block(checkout, error); block(dictionary, checkout, error);
} }
#pragma mark - Shipping Rates - #pragma mark - Shipping Rates -
...@@ -248,6 +249,9 @@ ...@@ -248,6 +249,9 @@
NSURL *route = [self urlForCheckoutsUsingGiftCardWithToken:checkout.token]; NSURL *route = [self urlForCheckoutsUsingGiftCardWithToken:checkout.token];
return [self postRequestForURL:route object:giftCard completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) { return [self postRequestForURL:route object:giftCard completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) {
NSDictionary *dictionary = nil;
if (json && !error) { if (json && !error) {
NSDictionary *giftCardJSON = json[@"gift_card"]; NSDictionary *giftCardJSON = json[@"gift_card"];
...@@ -259,10 +263,12 @@ ...@@ -259,10 +263,12 @@
* 'paymentDue' value and the gift * 'paymentDue' value and the gift
* card. * card.
*/ */
dictionary = giftCardJSON[@"checkout"];
checkout.JSONDictionary = giftCardJSON[@"checkout"]; checkout.JSONDictionary = giftCardJSON[@"checkout"];
[checkout addGiftCard:giftCard]; [checkout addGiftCard:giftCard];
} }
block(checkout, error); block(dictionary, checkout, error);
}]; }];
} }
...@@ -273,6 +279,9 @@ ...@@ -273,6 +279,9 @@
NSURL *route = [self urlForCheckoutsUsingGiftCard:giftCard.identifier token:checkout.token]; NSURL *route = [self urlForCheckoutsUsingGiftCard:giftCard.identifier token:checkout.token];
return [self deleteRequestForURL:route completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) { return [self deleteRequestForURL:route completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) {
NSDictionary *dictionary = nil;
if (json && !error) { if (json && !error) {
NSDictionary *giftCardJSON = json[@"gift_card"]; NSDictionary *giftCardJSON = json[@"gift_card"];
...@@ -284,10 +293,11 @@ ...@@ -284,10 +293,11 @@
* 'paymentDue' value and the gift * 'paymentDue' value and the gift
* card. * card.
*/ */
dictionary = giftCardJSON[@"checkout"];
checkout.JSONDictionary = giftCardJSON[@"checkout"]; checkout.JSONDictionary = giftCardJSON[@"checkout"];
[checkout removeGiftCardWithIdentifier:giftCardID]; [checkout removeGiftCardWithIdentifier:giftCardID];
} }
block(checkout, error); block(dictionary, checkout, error);
}]; }];
} }
......
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