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
246200b8
Commit
246200b8
authored
May 11, 2016
by
Dima Bart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Require a valid checkout token to complete payment, otherwise throw.
parent
67665b95
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
18 deletions
+9
-18
BUYClient.m
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient.m
+9
-18
No files found.
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient.m
View file @
246200b8
...
...
@@ -444,27 +444,18 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
-
(
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/"
);
NSURLSessionDataTask
*
task
=
nil
;
if
([
checkout
hasToken
])
{
BOOL
isFree
=
(
checkout
.
paymentDue
&&
checkout
.
paymentDue
.
floatValue
==
0
);
NSData
*
data
=
nil
;
if
(
paymentToken
)
{
data
=
[
NSJSONSerialization
dataWithJSONObject
:[
paymentToken
jsonRepresentation
]
options
:
0
error
:
nil
];
}
if
(
data
||
isFree
)
{
task
=
[
self
checkoutCompletionRequestWithCheckout
:
checkout
body
:
data
completion
:
block
];
}
}
else
{
block
(
nil
,
[
NSError
errorWithDomain
:
kShopifyError
code
:
BUYShopifyError_InvalidCheckoutObject
userInfo
:
nil
]);
NSData
*
data
=
nil
;
if
(
paymentToken
)
{
data
=
[
NSJSONSerialization
dataWithJSONObject
:[
paymentToken
jsonRepresentation
]
options
:
0
error
:
nil
];
}
return
task
;
BOOL
isFree
=
(
checkout
.
paymentDue
&&
checkout
.
paymentDue
.
floatValue
==
0
);
NSAssert
(
data
||
isFree
,
@"Failed to complete checkout. Checkout must have a payment token or have a payment value equal to $0.00"
);
return
[
self
checkoutCompletionRequestWithCheckout
:
checkout
body
:
data
completion
:
block
];
}
-
(
NSURLSessionDataTask
*
)
checkoutCompletionRequestWithCheckout
:
(
BUYCheckout
*
)
checkout
body
:
(
NSData
*
)
body
completion
:
(
BUYDataCheckoutBlock
)
block
...
...
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