Commit 1fc243ad by Dima Bart

Remove paymentSessionID from BUYCheckout.

parent c0f2fbeb
...@@ -420,8 +420,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token ...@@ -420,8 +420,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
- (NSURLSessionDataTask *)updateCheckout:(BUYCheckout *)checkout completion:(BUYDataCheckoutBlock)block - (NSURLSessionDataTask *)updateCheckout:(BUYCheckout *)checkout completion:(BUYDataCheckoutBlock)block
{ {
NSAssert(checkout, @"Failed to update checkout. Checkout must not be nil"); NSAssert([checkout hasToken], @"Failed to update checkout. Checkout must have a valid token associated with it.");
NSAssert([checkout hasToken], @"Failed to update checkout. Checkout must have a valid token associated with it/");
NSDictionary *json = [checkout jsonDictionaryForCheckout]; NSDictionary *json = [checkout jsonDictionaryForCheckout];
NSData *data = [NSJSONSerialization dataWithJSONObject:json options:0 error:nil]; NSData *data = [NSJSONSerialization dataWithJSONObject:json options:0 error:nil];
...@@ -436,8 +435,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token ...@@ -436,8 +435,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
- (NSURLSessionDataTask*)completeCheckout:(BUYCheckout *)checkout paymentToken:(id<BUYPaymentToken>)paymentToken completion:(BUYDataCheckoutBlock)block - (NSURLSessionDataTask*)completeCheckout:(BUYCheckout *)checkout paymentToken:(id<BUYPaymentToken>)paymentToken completion:(BUYDataCheckoutBlock)block
{ {
NSAssert(checkout, @"Failed to complete checkout. Checkout must not be nil"); NSAssert([checkout hasToken], @"Failed to complete checkout. Checkout must have a valid token associated with it.");
NSAssert([checkout hasToken], @"Failed to complete checkout. Checkout must have a valid token associated with it/");
NSData *data = nil; NSData *data = nil;
if (paymentToken) { if (paymentToken) {
...@@ -463,8 +461,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token ...@@ -463,8 +461,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
- (NSURLSessionDataTask *)getCompletionStatusOfCheckout:(BUYCheckout *)checkout completion:(BUYDataCheckoutStatusBlock)block - (NSURLSessionDataTask *)getCompletionStatusOfCheckout:(BUYCheckout *)checkout completion:(BUYDataCheckoutStatusBlock)block
{ {
NSAssert(checkout, @"Failed to get completetion status of checkout. Checkout must not be nil"); NSAssert([checkout hasToken], @"Failed to get complete status of checkout. Checkout must have a valid token associated with it.");
NSAssert([checkout hasToken], @"Failed to get complete status of checkout. Checkout must have a valid token associated with it/");
return [self getCompletionStatusOfCheckoutToken:checkout.token completion:block]; return [self getCompletionStatusOfCheckoutToken:checkout.token completion:block];
} }
...@@ -541,10 +538,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token ...@@ -541,10 +538,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
NSData *data = [NSJSONSerialization dataWithJSONObject:@{ @"checkout" : json } options:0 error:nil]; NSData *data = [NSJSONSerialization dataWithJSONObject:@{ @"checkout" : json } options:0 error:nil];
if (data) { if (data) {
return [self postPaymentRequestWithCheckout:checkout body:data completion:^(BUYCheckout *checkout, NSString *paymentSessionId, NSError *error) { return [self postPaymentRequestWithCheckout:checkout body:data completion:completion];
id<BUYPaymentToken> provider = [[BUYCreditCardToken alloc] initWithPaymentSessionID:paymentSessionId];
completion(checkout, provider, error);
}];
} else { } else {
completion(nil, nil, [NSError errorWithDomain:kShopifyError code:BUYShopifyError_InvalidCheckoutObject userInfo:nil]); completion(nil, nil, [NSError errorWithDomain:kShopifyError code:BUYShopifyError_InvalidCheckoutObject userInfo:nil]);
...@@ -651,15 +645,14 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token ...@@ -651,15 +645,14 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
return task; return task;
} }
- (NSURLSessionDataTask *)postPaymentRequestWithCheckout:(BUYCheckout *)checkout body:(NSData *)body completion:(void (^)(BUYCheckout *checkout, NSString *paymentSessionId, NSError *error))block - (NSURLSessionDataTask *)postPaymentRequestWithCheckout:(BUYCheckout *)checkout body:(NSData *)body completion:(BUYDataCreditCardBlock)block
{ {
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; id<BUYPaymentToken> token = nil;
if (!error) { if (!error) {
paymentSessionId = json[@"id"]; token = [[BUYCreditCardToken alloc] initWithPaymentSessionID:json[@"id"]];
checkout.paymentSessionId = paymentSessionId;
} }
block(checkout, paymentSessionId, error); block(checkout, token, error);
}]; }];
} }
......
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
{ {
self = [super init]; self = [super init];
if (self) { if (self) {
NSAssert(paymentSessionID, @"Failed to initialize BUYCreditCardToken. Invalid or nil payment session ID.");
_paymentSessionID = paymentSessionID; _paymentSessionID = paymentSessionID;
} }
return self; return self;
......
...@@ -157,11 +157,6 @@ ...@@ -157,11 +157,6 @@
<entry key="documentation" value="Amount of payment due on the checkout."/> <entry key="documentation" value="Amount of payment due on the checkout."/>
</userInfo> </userInfo>
</attribute> </attribute>
<attribute name="paymentSessionId" optional="YES" attributeType="String" syncable="YES">
<userInfo>
<entry key="documentation" value="The Payment Session ID associated with a credit card transaction."/>
</userInfo>
</attribute>
<attribute name="paymentURL" optional="YES" attributeType="Transformable" valueTransformerName="" syncable="YES"> <attribute name="paymentURL" optional="YES" attributeType="Transformable" valueTransformerName="" syncable="YES">
<userInfo> <userInfo>
<entry key="attributeValueClassName" value="NSURL"/> <entry key="attributeValueClassName" value="NSURL"/>
...@@ -992,7 +987,7 @@ ...@@ -992,7 +987,7 @@
<element name="Address" positionX="126" positionY="521" width="128" height="240"/> <element name="Address" positionX="126" positionY="521" width="128" height="240"/>
<element name="Cart" positionX="-576" positionY="558" width="128" height="60"/> <element name="Cart" positionX="-576" positionY="558" width="128" height="60"/>
<element name="CartLineItem" positionX="-380" positionY="558" width="128" height="90"/> <element name="CartLineItem" positionX="-380" positionY="558" width="128" height="90"/>
<element name="Checkout" positionX="333" positionY="442" width="128" height="645"/> <element name="Checkout" positionX="333" positionY="442" width="128" height="630"/>
<element name="CheckoutAttribute" positionX="-954" positionY="594" width="128" height="90"/> <element name="CheckoutAttribute" positionX="-954" positionY="594" width="128" height="90"/>
<element name="Collection" positionX="-963" positionY="772" width="128" height="210"/> <element name="Collection" positionX="-963" positionY="772" width="128" height="210"/>
<element name="Customer" positionX="106" positionY="1263" width="128" height="330"/> <element name="Customer" positionX="106" positionY="1263" width="128" height="330"/>
......
...@@ -42,7 +42,6 @@ extern const struct BUYCheckoutAttributes { ...@@ -42,7 +42,6 @@ extern const struct BUYCheckoutAttributes {
__unsafe_unretained NSString *note; __unsafe_unretained NSString *note;
__unsafe_unretained NSString *partialAddresses; __unsafe_unretained NSString *partialAddresses;
__unsafe_unretained NSString *paymentDue; __unsafe_unretained NSString *paymentDue;
__unsafe_unretained NSString *paymentSessionId;
__unsafe_unretained NSString *paymentURL; __unsafe_unretained NSString *paymentURL;
__unsafe_unretained NSString *privacyPolicyURL; __unsafe_unretained NSString *privacyPolicyURL;
__unsafe_unretained NSString *refundPolicyURL; __unsafe_unretained NSString *refundPolicyURL;
...@@ -194,11 +193,6 @@ extern const struct BUYCheckoutUserInfo { ...@@ -194,11 +193,6 @@ extern const struct BUYCheckoutUserInfo {
@property (nonatomic, strong) NSDecimalNumber* paymentDue; @property (nonatomic, strong) NSDecimalNumber* paymentDue;
/** /**
* The Payment Session ID associated with a credit card transaction.
*/
@property (nonatomic, strong) NSString* paymentSessionId;
/**
* URL to the payment gateway. * URL to the payment gateway.
*/ */
@property (nonatomic, strong) NSURL* paymentURL; @property (nonatomic, strong) NSURL* paymentURL;
......
...@@ -40,7 +40,6 @@ const struct BUYCheckoutAttributes BUYCheckoutAttributes = { ...@@ -40,7 +40,6 @@ const struct BUYCheckoutAttributes BUYCheckoutAttributes = {
.note = @"note", .note = @"note",
.partialAddresses = @"partialAddresses", .partialAddresses = @"partialAddresses",
.paymentDue = @"paymentDue", .paymentDue = @"paymentDue",
.paymentSessionId = @"paymentSessionId",
.paymentURL = @"paymentURL", .paymentURL = @"paymentURL",
.privacyPolicyURL = @"privacyPolicyURL", .privacyPolicyURL = @"privacyPolicyURL",
.refundPolicyURL = @"refundPolicyURL", .refundPolicyURL = @"refundPolicyURL",
......
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