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
3c67fdf4
Commit
3c67fdf4
authored
Dec 15, 2015
by
Rune Madsen
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #76 from Shopify/runmad.fix-apple-pay-setup-button
Fix Apple Pay "Setup" button logic
parents
e477f067
07e160ad
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
28 deletions
+56
-28
BUYProductViewController.h
...DK/Mobile Buy SDK/Product View/BUYProductViewController.h
+0
-7
BUYProductViewController.m
...DK/Mobile Buy SDK/Product View/BUYProductViewController.m
+1
-21
BUYViewController.h
...y SDK/Mobile Buy SDK/View Controllers/BUYViewController.h
+30
-0
BUYViewController.m
...y SDK/Mobile Buy SDK/View Controllers/BUYViewController.m
+25
-0
No files found.
Mobile Buy SDK/Mobile Buy SDK/Product View/BUYProductViewController.h
View file @
3c67fdf4
...
@@ -76,13 +76,6 @@
...
@@ -76,13 +76,6 @@
@property
(
nonatomic
,
assign
,
readonly
)
BOOL
isLoading
;
@property
(
nonatomic
,
assign
,
readonly
)
BOOL
isLoading
;
/**
/**
* If the merchantId is set and the device support Apple Pay but no credit card is present this allows the user to add a payment pass to the Wallet.
* The user is given the option to add a payment pass or continue with web checkout. Default is set to true. The Set Up Apple Pay button will, however
* still only show if [PKAddPaymentPassViewController canAddPaymentPass] returns true, merchantId is set and the app is running iOS 9.0 and above.
*/
@property
(
nonatomic
,
assign
)
BOOL
allowApplePaySetup
;
/**
* This is a convenience method as an alternative to presentViewController: which will force portrait orientation. This method is only
* This is a convenience method as an alternative to presentViewController: which will force portrait orientation. This method is only
* required when presenting from a landscape view controller.
* required when presenting from a landscape view controller.
*
*
...
...
Mobile Buy SDK/Mobile Buy SDK/Product View/BUYProductViewController.m
View file @
3c67fdf4
...
@@ -128,7 +128,7 @@ CGFloat const BUYMaxProductViewHeight = 640.0;
...
@@ -128,7 +128,7 @@ CGFloat const BUYMaxProductViewHeight = 640.0;
-
(
BUYProductView
*
)
productView
-
(
BUYProductView
*
)
productView
{
{
if
(
_productView
==
nil
&&
self
.
product
!=
nil
&&
self
.
shop
!=
nil
)
{
if
(
_productView
==
nil
&&
self
.
product
!=
nil
&&
self
.
shop
!=
nil
)
{
_productView
=
[[
BUYProductView
alloc
]
initWithFrame
:
CGRectMake
(
0
,
0
,
self
.
preferredContentSize
.
width
,
self
.
preferredContentSize
.
height
)
product
:
self
.
product
theme
:
self
.
theme
shouldShowApplePaySetup
:
self
.
all
owApplePaySetup
];
_productView
=
[[
BUYProductView
alloc
]
initWithFrame
:
CGRectMake
(
0
,
0
,
self
.
preferredContentSize
.
width
,
self
.
preferredContentSize
.
height
)
product
:
self
.
product
theme
:
self
.
theme
shouldShowApplePaySetup
:
self
.
shouldSh
owApplePaySetup
];
_productView
.
translatesAutoresizingMaskIntoConstraints
=
NO
;
_productView
.
translatesAutoresizingMaskIntoConstraints
=
NO
;
_productView
.
hidden
=
YES
;
_productView
.
hidden
=
YES
;
[
self
.
view
addSubview
:
_productView
];
[
self
.
view
addSubview
:
_productView
];
...
@@ -149,26 +149,6 @@ CGFloat const BUYMaxProductViewHeight = 640.0;
...
@@ -149,26 +149,6 @@ CGFloat const BUYMaxProductViewHeight = 640.0;
return
_productView
;
return
_productView
;
}
}
-
(
BOOL
)
canShowApplePaySetup
{
PKPassLibrary
*
passLibrary
=
[[
PKPassLibrary
alloc
]
init
];
if
(
self
.
allowApplePaySetup
==
YES
&&
// Check that it's running iOS 9.0 or above
[
passLibrary
respondsToSelector
:
@selector
(
canAddPaymentPassWithPrimaryAccountIdentifier
:)]
&&
// Check if the device can add a payment pass
[
PKPaymentAuthorizationViewController
canMakePayments
]
&&
// Check that Apple Pay is enabled for the merchant
[
self
.
merchantId
length
])
{
return
YES
;
}
else
{
return
NO
;
}
}
-
(
BOOL
)
shouldShowApplePayButton
{
return
self
.
isApplePayAvailable
?
self
.
isApplePayAvailable
:
[
self
canShowApplePaySetup
];
}
-
(
CGSize
)
preferredContentSize
-
(
CGSize
)
preferredContentSize
{
{
return
CGSizeMake
(
MIN
(
BUYMaxProductViewWidth
,
self
.
view
.
bounds
.
size
.
width
),
return
CGSizeMake
(
MIN
(
BUYMaxProductViewWidth
,
self
.
view
.
bounds
.
size
.
width
),
...
...
Mobile Buy SDK/Mobile Buy SDK/View Controllers/BUYViewController.h
View file @
3c67fdf4
...
@@ -171,6 +171,36 @@
...
@@ -171,6 +171,36 @@
@property
(
nonatomic
,
assign
,
readonly
)
BOOL
isApplePayAvailable
;
@property
(
nonatomic
,
assign
,
readonly
)
BOOL
isApplePayAvailable
;
/**
/**
* If the merchantId is set and the device support Apple Pay but no credit card is present this allows the user to add a payment pass to the Wallet.
* The user is given the option to add a payment pass or continue with web checkout. Default is set to true. The Set Up Apple Pay button will, however
* still only show if [PKAddPaymentPassViewController canAddPaymentPass] returns true, merchantId is set and the app is running iOS 9.0 and above.
*/
@property
(
nonatomic
,
assign
)
BOOL
allowApplePaySetup
;
/**
* Whether the device is setup to show the Apple Pay setup sheet.
* `allowApplePaySetup` must be set to YES, and the `merchantId` must also be set in addition to the
* device settings for this method to return YES.
*
* @return YES if the Setup Apple Pay button should be shown
*/
-
(
BOOL
)
canShowApplePaySetup
;
/**
* Returns whether the Apple Pay button should be shown
*
* @return YES if `isApplePayAvailable` or `canShowApplePaySetup` returns YES
*/
-
(
BOOL
)
shouldShowApplePayButton
;
/**
* Returns whether to show the Apple Pay setup button in place of the Apple Pay buy button
*
* @return YES if `isApplePayAvailable` returns NO and `canShowApplePaySetup` returns YES
*/
-
(
BOOL
)
shouldShowApplePaySetup
;
/**
* The current checkout object
* The current checkout object
*/
*/
@property
(
nonatomic
,
strong
,
readonly
)
BUYCheckout
*
checkout
;
@property
(
nonatomic
,
strong
,
readonly
)
BUYCheckout
*
checkout
;
...
...
Mobile Buy SDK/Mobile Buy SDK/View Controllers/BUYViewController.m
View file @
3c67fdf4
...
@@ -102,6 +102,22 @@ NSString * BUYURLKey = @"url";
...
@@ -102,6 +102,22 @@ NSString * BUYURLKey = @"url";
}];
}];
}
}
-
(
BOOL
)
canShowApplePaySetup
{
PKPassLibrary
*
passLibrary
=
[[
PKPassLibrary
alloc
]
init
];
if
(
self
.
allowApplePaySetup
==
YES
&&
// Check that it's running iOS 9.0 or above
[
passLibrary
respondsToSelector
:
@selector
(
canAddPaymentPassWithPrimaryAccountIdentifier
:)]
&&
// Check if the device can add a payment pass
[
PKPaymentAuthorizationViewController
canMakePayments
]
&&
// Check that Apple Pay is enabled for the merchant
[
self
.
merchantId
length
])
{
return
YES
;
}
else
{
return
NO
;
}
}
-
(
BOOL
)
isApplePayAvailable
-
(
BOOL
)
isApplePayAvailable
{
{
// checks if the client is setup to use Apple Pay
// checks if the client is setup to use Apple Pay
...
@@ -112,6 +128,15 @@ NSString * BUYURLKey = @"url";
...
@@ -112,6 +128,15 @@ NSString * BUYURLKey = @"url";
[
PKPaymentAuthorizationViewController
canMakePaymentsUsingNetworks
:
self
.
supportedNetworks
]);
[
PKPaymentAuthorizationViewController
canMakePaymentsUsingNetworks
:
self
.
supportedNetworks
]);
}
}
-
(
BOOL
)
shouldShowApplePayButton
{
return
self
.
isApplePayAvailable
||
[
self
canShowApplePaySetup
];
}
-
(
BOOL
)
shouldShowApplePaySetup
{
return
self
.
isApplePayAvailable
==
NO
&&
[
self
canShowApplePaySetup
];
}
#pragma mark - Checkout Flow Methods
#pragma mark - Checkout Flow Methods
#pragma mark - Step 1 - Creating or updating a Checkout
#pragma mark - Step 1 - Creating or updating a 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