Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
shopify_iossdk
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cemarose
shopify_iossdk
Commits
75bf8f17
Commit
75bf8f17
authored
Jun 01, 2016
by
Brent Gulanowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update to the new convenience checkout completion support.
parent
8bae5f42
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
38 deletions
+17
-38
CheckoutViewController.m
...d/Mobile Buy SDK Advanced Sample/CheckoutViewController.m
+5
-27
ProductListViewController.m
...obile Buy SDK Advanced Sample/ProductListViewController.m
+9
-9
project.pbxproj
Mobile Buy SDK/Mobile Buy SDK.xcodeproj/project.pbxproj
+2
-2
Buy.h
Mobile Buy SDK/Mobile Buy SDK/Buy.h
+1
-0
No files found.
Mobile Buy SDK Sample Apps/Sample App Advanced/Mobile Buy SDK Advanced Sample/CheckoutViewController.m
View file @
75bf8f17
...
@@ -24,7 +24,8 @@
...
@@ -24,7 +24,8 @@
// THE SOFTWARE.
// THE SOFTWARE.
//
//
#import <Buy/Buy.h>
@import
Buy
;
#import "CheckoutViewController.h"
#import "CheckoutViewController.h"
#import "SummaryItemsTableViewCell.h"
#import "SummaryItemsTableViewCell.h"
#import "UIButton+PaymentButton.h"
#import "UIButton+PaymentButton.h"
...
@@ -138,14 +139,8 @@ NSString * const MerchantId = @"";
...
@@ -138,14 +139,8 @@ NSString * const MerchantId = @"";
-
(
void
)
addCreditCardToCheckout
:
(
void
(
^
)(
BOOL
success
,
id
<
BUYPaymentToken
>
token
))
callback
-
(
void
)
addCreditCardToCheckout
:
(
void
(
^
)(
BOOL
success
,
id
<
BUYPaymentToken
>
token
))
callback
{
{
[[
UIApplication
sharedApplication
]
setNetworkActivityIndicatorVisible
:
YES
];
[
self
.
client
storeCreditCard
:[
self
creditCard
]
checkout
:
self
.
checkout
completion
:^
(
id
<
BUYPaymentToken
>
token
,
NSError
*
error
)
{
[
self
.
client
storeCreditCard
:[
self
creditCard
]
checkout
:
self
.
checkout
completion
:^
(
id
<
BUYPaymentToken
>
token
,
NSError
*
error
)
{
[[
UIApplication
sharedApplication
]
setNetworkActivityIndicatorVisible
:
NO
];
if
(
error
==
nil
&&
token
)
{
if
(
error
==
nil
&&
token
)
{
NSLog
(
@"Successfully added credit card to checkout"
);
NSLog
(
@"Successfully added credit card to checkout"
);
}
}
else
{
else
{
...
@@ -201,40 +196,23 @@ NSString * const MerchantId = @"";
...
@@ -201,40 +196,23 @@ NSString * const MerchantId = @"";
}];
}];
}
}
#pragma mark Native Checkout
#pragma mark
-
Native Checkout
-
(
void
)
checkoutWithCreditCard
-
(
void
)
checkoutWithCreditCard
{
{
[[
UIApplication
sharedApplication
]
setNetworkActivityIndicatorVisible
:
YES
];
__weak
CheckoutViewController
*
welf
=
self
;
__weak
CheckoutViewController
*
welf
=
self
;
// First, the credit card must be stored on the checkout
// First, the credit card must be stored on the checkout
[
self
addCreditCardToCheckout
:
^
(
BOOL
success
,
id
<
BUYPaymentToken
>
token
)
{
[
self
addCreditCardToCheckout
:
^
(
BOOL
success
,
id
<
BUYPaymentToken
>
token
)
{
if
(
success
)
{
if
(
success
)
{
[[
UIApplication
sharedApplication
]
setNetworkActivityIndicatorVisible
:
YES
];
// Upon successfully adding the credit card to the checkout, complete checkout must be called immediately
[
welf
.
client
completeCheckout
:
welf
.
checkout
paymentToken
:
token
completion
:^
(
BUYCheckout
*
checkout
,
NSError
*
error
)
{
[
welf
.
client
completeCheckout
:
welf
.
checkout
paymentToken
:
token
completion
:^
(
BUYCheckout
*
checkout
,
NSError
*
error
)
{
if
(
error
==
nil
&&
checkout
)
{
if
(
error
==
nil
&&
checkout
)
{
NSLog
(
@"Successfully completed checkout"
);
NSLog
(
@"Successfully completed checkout"
);
welf
.
checkout
=
checkout
;
welf
.
checkout
=
checkout
;
NSOperation
*
completionOperation
=
[
welf
.
client
getCompletionStatusOfCheckout
:
checkout
completion
:
^
(
BUYStatus
status
,
NSError
*
_Nullable
error
)
{
[[
UIApplication
sharedApplication
]
setNetworkActivityIndicatorVisible
:
NO
];
if
(
error
)
{
NSLog
(
@"Error getting completion status: %@"
,
error
);
}
else
{
NSLog
(
@"Successfully got completion status: %lu"
,
(
unsigned
long
)
status
);
[
welf
getCompletedCheckout
:
NULL
];
}
}];
[[
UIApplication
sharedApplication
]
setNetworkActivityIndicatorVisible
:
YES
];
[[
NSOperationQueue
mainQueue
]
addOperation
:
completionOperation
];
}
}
else
{
else
{
[[
UIApplication
sharedApplication
]
setNetworkActivityIndicatorVisible
:
NO
];
[[
UIApplication
sharedApplication
]
setNetworkActivityIndicatorVisible
:
NO
];
...
...
Mobile Buy SDK Sample Apps/Sample App Advanced/Mobile Buy SDK Advanced Sample/ProductListViewController.m
View file @
75bf8f17
...
@@ -43,8 +43,8 @@
...
@@ -43,8 +43,8 @@
@property
(
nonatomic
,
strong
)
BUYClient
*
client
;
@property
(
nonatomic
,
strong
)
BUYClient
*
client
;
@property
(
nonatomic
,
strong
)
BUYCollection
*
collection
;
@property
(
nonatomic
,
strong
)
BUYCollection
*
collection
;
@property
(
nonatomic
,
strong
)
NSArray
*
products
;
@property
(
nonatomic
,
strong
)
NSArray
*
products
;
@property
(
nonatomic
,
strong
)
NS
URLSessionDataTask
*
collectionTask
;
@property
(
nonatomic
,
strong
)
NS
Operation
*
collectionOperation
;
@property
(
nonatomic
,
strong
)
NS
URLSessionDataTask
*
checkoutCreationTask
;
@property
(
nonatomic
,
strong
)
NS
Operation
*
checkoutCreationOperation
;
@property
(
nonatomic
,
assign
)
BOOL
demoProductViewController
;
@property
(
nonatomic
,
assign
)
BOOL
demoProductViewController
;
@property
(
nonatomic
,
assign
)
ThemeStyle
themeStyle
;
@property
(
nonatomic
,
assign
)
ThemeStyle
themeStyle
;
...
@@ -112,8 +112,8 @@
...
@@ -112,8 +112,8 @@
-
(
void
)
dealloc
-
(
void
)
dealloc
{
{
[
self
.
checkoutCreation
Task
cancel
];
[
self
.
checkoutCreation
Operation
cancel
];
[
self
.
collection
Task
cancel
];
[
self
.
collection
Operation
cancel
];
}
}
-
(
void
)
presentCollectionSortOptions
:
(
id
)
sender
-
(
void
)
presentCollectionSortOptions
:
(
id
)
sender
...
@@ -160,9 +160,9 @@
...
@@ -160,9 +160,9 @@
-
(
void
)
getCollectionWithSortOrder
:
(
BUYCollectionSort
)
collectionSort
-
(
void
)
getCollectionWithSortOrder
:
(
BUYCollectionSort
)
collectionSort
{
{
[
self
.
collection
Task
cancel
];
[
self
.
collection
Operation
cancel
];
[[
UIApplication
sharedApplication
]
setNetworkActivityIndicatorVisible
:
YES
];
[[
UIApplication
sharedApplication
]
setNetworkActivityIndicatorVisible
:
YES
];
self
.
collection
Task
=
[
self
.
client
getProductsPage
:
1
inCollection
:
self
.
collection
.
collectionId
sortOrder
:
collectionSort
completion
:^
(
NSArray
*
products
,
NSUInteger
page
,
BOOL
reachedEnd
,
NSError
*
error
)
{
self
.
collection
Operation
=
[
self
.
client
getProductsPage
:
1
inCollection
:
self
.
collection
.
collectionId
sortOrder
:
collectionSort
completion
:^
(
NSArray
*
products
,
NSUInteger
page
,
BOOL
reachedEnd
,
NSError
*
error
)
{
[[
UIApplication
sharedApplication
]
setNetworkActivityIndicatorVisible
:
NO
];
[[
UIApplication
sharedApplication
]
setNetworkActivityIndicatorVisible
:
NO
];
if
(
error
==
nil
&&
products
)
{
if
(
error
==
nil
&&
products
)
{
...
@@ -279,8 +279,8 @@
...
@@ -279,8 +279,8 @@
-
(
void
)
demoNativeFlowWithProduct
:
(
BUYProduct
*
)
product
-
(
void
)
demoNativeFlowWithProduct
:
(
BUYProduct
*
)
product
{
{
if
(
self
.
checkoutCreation
Task
.
state
==
NSURLSessionTaskStateRunn
ing
)
{
if
(
self
.
checkoutCreation
Operation
.
execut
ing
)
{
[
self
.
checkoutCreation
Task
cancel
];
[
self
.
checkoutCreation
Operation
cancel
];
}
}
BUYCart
*
cart
=
[
self
.
client
.
modelManager
insertCartWithJSONDictionary
:
nil
];
BUYCart
*
cart
=
[
self
.
client
.
modelManager
insertCartWithJSONDictionary
:
nil
];
...
@@ -296,7 +296,7 @@
...
@@ -296,7 +296,7 @@
self
.
client
.
urlScheme
=
@"advancedsample://"
;
self
.
client
.
urlScheme
=
@"advancedsample://"
;
[[
UIApplication
sharedApplication
]
setNetworkActivityIndicatorVisible
:
YES
];
[[
UIApplication
sharedApplication
]
setNetworkActivityIndicatorVisible
:
YES
];
self
.
checkoutCreation
Task
=
[
self
.
client
createCheckout
:
checkout
completion
:
^
(
BUYCheckout
*
checkout
,
NSError
*
error
)
{
self
.
checkoutCreation
Operation
=
[
self
.
client
createCheckout
:
checkout
completion
:
^
(
BUYCheckout
*
checkout
,
NSError
*
error
)
{
[[
UIApplication
sharedApplication
]
setNetworkActivityIndicatorVisible
:
NO
];
[[
UIApplication
sharedApplication
]
setNetworkActivityIndicatorVisible
:
NO
];
if
(
error
==
nil
&&
checkout
)
{
if
(
error
==
nil
&&
checkout
)
{
...
...
Mobile Buy SDK/Mobile Buy SDK.xcodeproj/project.pbxproj
View file @
75bf8f17
...
@@ -351,8 +351,8 @@
...
@@ -351,8 +351,8 @@
9A0B0C831CEB981C0037D68F
/* BUYClient+RoutingTests.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A0B0C821CEB981C0037D68F
/* BUYClient+RoutingTests.m */
;
};
9A0B0C831CEB981C0037D68F
/* BUYClient+RoutingTests.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A0B0C821CEB981C0037D68F
/* BUYClient+RoutingTests.m */
;
};
9A0B0CA21CECC1BC0037D68F
/* BUYClient+Checkout.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A0B0C711CEB52B90037D68F
/* BUYClient+Checkout.m */
;
};
9A0B0CA21CECC1BC0037D68F
/* BUYClient+Checkout.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A0B0C711CEB52B90037D68F
/* BUYClient+Checkout.m */
;
};
9A0B0CA31CECC1BD0037D68F
/* BUYClient+Checkout.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A0B0C711CEB52B90037D68F
/* BUYClient+Checkout.m */
;
};
9A0B0CA31CECC1BD0037D68F
/* BUYClient+Checkout.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A0B0C711CEB52B90037D68F
/* BUYClient+Checkout.m */
;
};
9A0B0CA71CED0A860037D68F
/* BUYCheckoutOperation.h in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A0B0CA51CED0A860037D68F
/* BUYCheckoutOperation.h */
;
};
9A0B0CA71CED0A860037D68F
/* BUYCheckoutOperation.h in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A0B0CA51CED0A860037D68F
/* BUYCheckoutOperation.h */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
9A0B0CA81CED0A860037D68F
/* BUYCheckoutOperation.h in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A0B0CA51CED0A860037D68F
/* BUYCheckoutOperation.h */
;
};
9A0B0CA81CED0A860037D68F
/* BUYCheckoutOperation.h in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A0B0CA51CED0A860037D68F
/* BUYCheckoutOperation.h */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
9A0B0CA91CED0A860037D68F
/* BUYCheckoutOperation.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A0B0CA61CED0A860037D68F
/* BUYCheckoutOperation.m */
;
};
9A0B0CA91CED0A860037D68F
/* BUYCheckoutOperation.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A0B0CA61CED0A860037D68F
/* BUYCheckoutOperation.m */
;
};
9A0B0CAA1CED0A860037D68F
/* BUYCheckoutOperation.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A0B0CA61CED0A860037D68F
/* BUYCheckoutOperation.m */
;
};
9A0B0CAA1CED0A860037D68F
/* BUYCheckoutOperation.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A0B0CA61CED0A860037D68F
/* BUYCheckoutOperation.m */
;
};
9A102D1B1CDD1F960026CC43
/* BUYErrorTests.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A102D1A1CDD1F960026CC43
/* BUYErrorTests.m */
;
};
9A102D1B1CDD1F960026CC43
/* BUYErrorTests.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A102D1A1CDD1F960026CC43
/* BUYErrorTests.m */
;
};
...
...
Mobile Buy SDK/Mobile Buy SDK/Buy.h
View file @
75bf8f17
...
@@ -62,6 +62,7 @@ FOUNDATION_EXPORT const unsigned char BuyVersionString[];
...
@@ -62,6 +62,7 @@ FOUNDATION_EXPORT const unsigned char BuyVersionString[];
#import <Buy/BUYPaymentProvider.h>
#import <Buy/BUYPaymentProvider.h>
#import <Buy/BUYWebCheckoutPaymentProvider.h>
#import <Buy/BUYWebCheckoutPaymentProvider.h>
#import <Buy/BUYCheckoutOperation.h>
#import <Buy/BUYClient.h>
#import <Buy/BUYClient.h>
#import <Buy/BUYClient+Address.h>
#import <Buy/BUYClient+Address.h>
#import <Buy/BUYClient+Customers.h>
#import <Buy/BUYClient+Customers.h>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment