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
67665b95
Commit
67665b95
authored
May 11, 2016
by
Dima Bart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename to BUYPaymentToken protocol and associated classes.
parent
cce5f56f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
30 additions
and
41 deletions
+30
-41
project.pbxproj
Mobile Buy SDK/Mobile Buy SDK.xcodeproj/project.pbxproj
+0
-0
BUYClient.h
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient.h
+9
-8
BUYClient.m
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient.m
+6
-7
BUYApplePayToken.h
Mobile Buy SDK/Mobile Buy SDK/Models/BUYApplePayToken.h
+2
-2
BUYApplePayToken.m
Mobile Buy SDK/Mobile Buy SDK/Models/BUYApplePayToken.m
+3
-8
BUYCreditCardToken.h
Mobile Buy SDK/Mobile Buy SDK/Models/BUYCreditCardToken.h
+2
-2
BUYCreditCardToken.m
Mobile Buy SDK/Mobile Buy SDK/Models/BUYCreditCardToken.m
+3
-8
BUYPaymentSessionProvider.h
...Buy SDK/Mobile Buy SDK/Models/BUYPaymentSessionProvider.h
+2
-3
BUYApplePayHelpers.m
Mobile Buy SDK/Mobile Buy SDK/Utils/BUYApplePayHelpers.m
+3
-3
No files found.
Mobile Buy SDK/Mobile Buy SDK.xcodeproj/project.pbxproj
View file @
67665b95
This diff is collapsed.
Click to expand it.
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient.h
View file @
67665b95
...
...
@@ -40,7 +40,7 @@
@class
BUYOrder
;
@class
BUYModelManager
;
@protocol
BUYPayment
SessionProvider
;
@protocol
BUYPayment
Token
;
/**
* The sort order for products in a collection
...
...
@@ -118,11 +118,11 @@ typedef NS_ENUM(NSUInteger, BUYStatus) {
/**
* Return block containing a BUYCheckout, id<BUYPaymentSessionProvider> and/or an NSError
*
* @param checkout
The returned BUYCheckout
* @param
sessionProvider An opaque session provider
type that wraps necessary credentials for payment
* @param error
Optional NSError
* @param checkout The returned BUYCheckout
* @param
paymentToken An opaque payment token
type that wraps necessary credentials for payment
* @param error Optional NSError
*/
typedef
void
(
^
BUYDataCreditCardBlock
)(
BUYCheckout
*
checkout
,
id
<
BUYPayment
SessionProvider
>
sessionProvider
,
NSError
*
error
);
typedef
void
(
^
BUYDataCreditCardBlock
)(
BUYCheckout
*
checkout
,
id
<
BUYPayment
Token
>
paymentToken
,
NSError
*
error
);
/**
* Return block containing a BUYCheckout and/or an NSError
...
...
@@ -453,12 +453,13 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard *giftCard, NSError *error);
* Note: There's no guarantee that the BUYCheckout returned will be the same as the one that is passed in.
* We recommended using the BUYCheckout returned in the block.
*
* @param checkout The BUYCheckout to complete
* @param block (^BUYDataCheckoutBlock)(BUYCheckout *checkout, NSError *error);
* @param checkout The BUYCheckout to complete
* @param paymentToken Opaque payment token object
* @param block (^BUYDataCheckoutBlock)(BUYCheckout *checkout, NSError *error);
*
* @return The associated NSURLSessionDataTask
*/
-
(
NSURLSessionDataTask
*
)
completeCheckout
:(
BUYCheckout
*
)
checkout
sessionProvider
:(
id
<
BUYPaymentSessionProvider
>
)
sessionProvider
completion
:(
BUYDataCheckoutBlock
)
block
;
-
(
NSURLSessionDataTask
*
)
completeCheckout
:(
BUYCheckout
*
)
checkout
paymentToken
:(
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.
...
...
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient.m
View file @
67665b95
...
...
@@ -30,7 +30,7 @@
#import "BUYCart.h"
#import "BUYCheckout.h"
#import "BUYCreditCard.h"
#import "BUYCreditCard
SessionProvider
.h"
#import "BUYCreditCard
Token
.h"
#import "BUYCollection.h"
#import "BUYError.h"
#import "BUYGiftCard.h"
...
...
@@ -441,10 +441,9 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
return
task
;
}
-
(
NSURLSessionDataTask
*
)
completeCheckout
:
(
BUYCheckout
*
)
checkout
sessionProvider
:
(
id
<
BUYPaymentSessionProvider
>
)
sessionProvider
completion
:
(
BUYDataCheckoutBlock
)
block
-
(
NSURLSessionDataTask
*
)
completeCheckout
:
(
BUYCheckout
*
)
checkout
paymentToken
:
(
id
<
BUYPaymentToken
>
)
paymentToken
completion
:
(
BUYDataCheckoutBlock
)
block
{
NSAssert
(
sessionProvider
,
@"Failed to complete checkout. BUYPaymentSessionProvider must not be nil."
);
NSAssert
(
checkout
,
@"Failed to complete checkout. BUYCheckout must not be nil"
);
NSAssert
(
checkout
,
@"Failed to complete checkout. Checkout must not be nil"
);
NSURLSessionDataTask
*
task
=
nil
;
...
...
@@ -453,8 +452,8 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
BOOL
isFree
=
(
checkout
.
paymentDue
&&
checkout
.
paymentDue
.
floatValue
==
0
);
NSData
*
data
=
nil
;
if
(
[
sessionProvider
hasPaymentSessionID
]
)
{
data
=
[
NSJSONSerialization
dataWithJSONObject
:[
sessionProvider
jsonRepresentation
]
options
:
0
error
:
nil
];
if
(
paymentToken
)
{
data
=
[
NSJSONSerialization
dataWithJSONObject
:[
paymentToken
jsonRepresentation
]
options
:
0
error
:
nil
];
}
if
(
data
||
isFree
)
{
...
...
@@ -563,7 +562,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
NSData
*
data
=
[
NSJSONSerialization
dataWithJSONObject
:@{
@"checkout"
:
json
}
options
:
0
error
:
nil
];
if
(
data
)
{
return
[
self
postPaymentRequestWithCheckout
:
checkout
body
:
data
completion
:^
(
BUYCheckout
*
checkout
,
NSString
*
paymentSessionId
,
NSError
*
error
)
{
id
<
BUYPayment
SessionProvider
>
provider
=
[[
BUYCreditCardSessionProvider
alloc
]
initWithPaymentSessionID
:
paymentSessionId
];
id
<
BUYPayment
Token
>
provider
=
[[
BUYCreditCardToken
alloc
]
initWithPaymentSessionID
:
paymentSessionId
];
completion
(
checkout
,
provider
,
error
);
}];
...
...
Mobile Buy SDK/Mobile Buy SDK/Models/BUYApplePay
SessionProvider
.h
→
Mobile Buy SDK/Mobile Buy SDK/Models/BUYApplePay
Token
.h
View file @
67665b95
//
// BUYApplePay
SessionProvider
.h
// BUYApplePay
Token
.h
// Mobile Buy SDK
//
// Created by Shopify.
...
...
@@ -29,7 +29,7 @@
@class
PKPaymentToken
;
@interface
BUYApplePay
SessionProvider
:
NSObject
<
BUYPaymentSessionProvider
>
@interface
BUYApplePay
Token
:
NSObject
<
BUYPaymentToken
>
@property
(
nonatomic
,
strong
,
readonly
)
PKPaymentToken
*
paymentToken
;
...
...
Mobile Buy SDK/Mobile Buy SDK/Models/BUYApplePay
SessionProvider
.m
→
Mobile Buy SDK/Mobile Buy SDK/Models/BUYApplePay
Token
.m
View file @
67665b95
//
// BUYApplePay
SessionProvider
.m
// BUYApplePay
Token
.m
// Mobile Buy SDK
//
// Created by Shopify.
...
...
@@ -28,9 +28,9 @@
#import <PassKit/PassKit.h>
#endif
#import "BUYApplePay
SessionProvider
.h"
#import "BUYApplePay
Token
.h"
@implementation
BUYApplePay
SessionProvider
@implementation
BUYApplePay
Token
#pragma mark - Init -
...
...
@@ -49,11 +49,6 @@
#pragma mark - BUYPaymentSessionProvider -
-
(
BOOL
)
hasPaymentSessionID
{
return
self
.
paymentToken
.
paymentData
.
length
>
0
;
}
-
(
NSDictionary
*
)
jsonRepresentation
{
return
@{
...
...
Mobile Buy SDK/Mobile Buy SDK/Models/BUYCreditCard
SessionProvider
.h
→
Mobile Buy SDK/Mobile Buy SDK/Models/BUYCreditCard
Token
.h
View file @
67665b95
//
// BUYCreditCard
SessionProvider
.h
// BUYCreditCard
Token
.h
// Mobile Buy SDK
//
// Created by Shopify.
...
...
@@ -27,7 +27,7 @@
#import <Foundation/Foundation.h>
#import "BUYPaymentSessionProvider.h"
@interface
BUYCreditCard
SessionProvider
:
NSObject
<
BUYPaymentSessionProvider
>
@interface
BUYCreditCard
Token
:
NSObject
<
BUYPaymentToken
>
@property
(
nonatomic
,
strong
,
readonly
)
NSString
*
paymentSessionID
;
...
...
Mobile Buy SDK/Mobile Buy SDK/Models/BUYCreditCard
SessionProvider
.m
→
Mobile Buy SDK/Mobile Buy SDK/Models/BUYCreditCard
Token
.m
View file @
67665b95
//
// BUYCreditCard
SessionProvider
.m
// BUYCreditCard
Token
.m
// Mobile Buy SDK
//
// Created by Shopify.
...
...
@@ -24,9 +24,9 @@
// THE SOFTWARE.
//
#import "BUYCreditCard
SessionProvider
.h"
#import "BUYCreditCard
Token
.h"
@implementation
BUYCreditCard
SessionProvider
@implementation
BUYCreditCard
Token
#pragma mark - Init -
...
...
@@ -41,11 +41,6 @@
#pragma mark - BUYPaymentSessionProvider -
-
(
BOOL
)
hasPaymentSessionID
{
return
self
.
paymentSessionID
.
length
>
0
;
}
-
(
NSDictionary
*
)
jsonRepresentation
{
return
@{
...
...
Mobile Buy SDK/Mobile Buy SDK/Models/BUYPaymentSessionProvider.h
View file @
67665b95
//
// BUYPayment
SessionProvider
.h
// BUYPayment
Token
.h
// Mobile Buy SDK
//
// Created by Shopify.
...
...
@@ -24,9 +24,8 @@
// THE SOFTWARE.
//
@protocol
BUYPayment
SessionProvider
<
NSObject
>
@protocol
BUYPayment
Token
<
NSObject
>
-
(
BOOL
)
hasPaymentSessionID
;
-
(
NSDictionary
*
)
jsonRepresentation
;
@end
Mobile Buy SDK/Mobile Buy SDK/Utils/BUYApplePayHelpers.m
View file @
67665b95
...
...
@@ -33,7 +33,7 @@
#import "BUYModelManager.h"
#import "BUYShop.h"
#import "BUYShopifyErrorCodes.h"
#import "BUYApplePay
SessionProvider
.h"
#import "BUYApplePay
Token
.h"
const
NSTimeInterval
PollDelay
=
0
.
5
;
...
...
@@ -114,10 +114,10 @@ const NSTimeInterval PollDelay = 0.5;
if
(
checkout
&&
error
==
nil
)
{
self
.
checkout
=
checkout
;
id
<
BUYPayment
SessionProvider
>
provider
=
[[
BUYApplePaySessionProvider
alloc
]
initWithPaymentToken
:
payment
.
token
];
id
<
BUYPayment
Token
>
token
=
[[
BUYApplePayToken
alloc
]
initWithPaymentToken
:
payment
.
token
];
//Now that the checkout is up to date, call complete.
[
self
.
client
completeCheckout
:
checkout
sessionProvider
:
provider
completion
:^
(
BUYCheckout
*
checkout
,
NSError
*
error
)
{
[
self
.
client
completeCheckout
:
checkout
paymentToken
:
token
completion
:^
(
BUYCheckout
*
checkout
,
NSError
*
error
)
{
if
(
checkout
&&
error
==
nil
)
{
self
.
checkout
=
checkout
;
...
...
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