Commit 35761806 by Brent Gulanowski

Remove Web Sample app.

parent 4b800153
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:Shopify Checkout.xcodeproj">
</FileRef>
</Workspace>
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "BEDC7A261AE03BA800C4B4FE"
BuildableName = "Mobile Buy SDK Web Sample.app"
BlueprintName = "Mobile Buy SDK Web Sample"
ReferencedContainer = "container:Mobile Buy SDK Web Sample.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "BEDC7A261AE03BA800C4B4FE"
BuildableName = "Mobile Buy SDK Web Sample.app"
BlueprintName = "Mobile Buy SDK Web Sample"
ReferencedContainer = "container:Mobile Buy SDK Web Sample.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "BEDC7A261AE03BA800C4B4FE"
BuildableName = "Mobile Buy SDK Web Sample.app"
BlueprintName = "Mobile Buy SDK Web Sample"
ReferencedContainer = "container:Mobile Buy SDK Web Sample.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "BEDC7A261AE03BA800C4B4FE"
BuildableName = "Mobile Buy SDK Web Sample.app"
BlueprintName = "Mobile Buy SDK Web Sample"
ReferencedContainer = "container:Mobile Buy SDK Web Sample.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
//
// AppDelegate.h
// Mobile Buy SDK
//
// Created by Shopify.
// Copyright (c) 2015 Shopify Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
@import UIKit;
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
//
// AppDelegate.m
// Mobile Buy SDK
//
// Created by Shopify.
// Copyright (c) 2015 Shopify Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#import "AppDelegate.h"
#import "ViewController.h"
@import Buy;
#warning - Enter your shop domain and API Key
#define SHOP_DOMAIN @""
#define API_KEY @""
#define CHANNEL_ID @""
#warning Optionally, to support Apple Pay, enter your merchant ID
#define MERCHANT_ID @""
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Initialize the Buy SDK
BUYClient *client = [[BUYClient alloc] initWithShopDomain:SHOP_DOMAIN
apiKey:API_KEY
channelId:CHANNEL_ID];
// Setup the views
ViewController *storeController = [[ViewController alloc] initWithClient:client];
storeController.merchantId = MERCHANT_ID;
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:storeController];
navController.toolbarHidden = NO;
navController.navigationBarHidden = NO;
navController.navigationBar.barStyle = UIStatusBarStyleLightContent;
self.window.rootViewController = navController;
[self.window makeKeyAndVisible];
return YES;
}
@end
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB">
<rect key="frame" x="0.0" y="0.0" width="480" height="480"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" Copyright (c) 2015 Shopify. All rights reserved." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="8ie-xW-0ye">
<rect key="frame" x="20" y="439" width="441" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Mobile Buy SDK Web Sample" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
<rect key="frame" x="20" y="140" width="441" height="43"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="kId-c2-rCX" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="bottom" multiplier="1/3" constant="1" id="5cJ-9S-tgC"/>
<constraint firstAttribute="centerX" secondItem="kId-c2-rCX" secondAttribute="centerX" id="Koa-jz-hwk"/>
<constraint firstAttribute="bottom" secondItem="8ie-xW-0ye" secondAttribute="bottom" constant="20" id="Kzo-t9-V3l"/>
<constraint firstItem="8ie-xW-0ye" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="MfP-vx-nX0"/>
<constraint firstAttribute="centerX" secondItem="8ie-xW-0ye" secondAttribute="centerX" id="ZEH-qu-HZ9"/>
<constraint firstItem="kId-c2-rCX" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="fvb-Df-36g"/>
</constraints>
<nil key="simulatedStatusBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<point key="canvasLocation" x="548" y="455"/>
</view>
</objects>
</document>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6211" systemVersion="14A298i" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6204"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
</scene>
</scenes>
</document>
//
// CheckoutSelectionController.h
// Checkout
//
// Created by Shopify.
// Copyright (c) 2015 Shopify. All rights reserved.
//
@import UIKit;
@class CheckoutSelectionController;
typedef NS_ENUM(NSUInteger, CheckoutType) {
CheckoutTypeNormal,
CheckoutTypeApplePay
};
@protocol CheckoutSelectionControllerDelegate <NSObject>
- (void)checkoutSelectionControllerCancelled:(CheckoutSelectionController *)controller;
- (void)checkoutSelectionController:(CheckoutSelectionController *)controller selectedCheckoutType:(CheckoutType)checkoutType;
@end
@interface CheckoutSelectionController : UIViewController
@property (nonatomic, strong) NSURLRequest *checkoutRequest;
@property (nonatomic, weak) id <CheckoutSelectionControllerDelegate> delegate;
@end
//
// CheckoutSelectionController.m
// Checkout
//
// Created by Shopify.
// Copyright (c) 2015 Shopify. All rights reserved.
//
#import "CheckoutSelectionController.h"
#import "CheckoutSelectionView.h"
#define kCheckoutAnimationTime 0.3f
@interface CheckoutSelectionController () <UIViewControllerTransitioningDelegate, UIViewControllerAnimatedTransitioning>
@end
@implementation CheckoutSelectionController {
CheckoutSelectionView *_selectionView;
}
- (instancetype)init
{
self = [super init];
if (self) {
self.modalPresentationStyle = UIModalPresentationCustom;
self.transitioningDelegate = self;
}
return self;
}
- (void)loadView
{
UIView *background = [[UIView alloc] init];
background.backgroundColor = [UIColor clearColor];
self.view = background;
PAYButton *applePayButton = [PAYButton buttonWithType:UIButtonTypeCustom];
applePayButton.paymentImageView.image = [UIImage imageNamed:@"ApplePayMark"];
applePayButton.paymentLabel.text = @"Complete with Apple Pay";
PAYButton *checkoutButton = [PAYButton buttonWithType:UIButtonTypeCustom];
checkoutButton.paymentImageView.image = [UIImage imageNamed:@"credit"];
checkoutButton.paymentLabel.text = @"Continue Checkout";
PAYButton *cancelButton = [PAYButton buttonWithType:UIButtonTypeCustom];
cancelButton.paymentImageView.image = [UIImage imageNamed:@"cancel"];
cancelButton.paymentLabel.text = @"Cancel";
_selectionView = [[CheckoutSelectionView alloc] initWithFrame:self.view.bounds buttons:@[applePayButton, checkoutButton, cancelButton]];
_selectionView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.view addSubview:_selectionView];
[applePayButton addTarget:self action:@selector(applePayPressed:) forControlEvents:UIControlEventTouchUpInside];
[checkoutButton addTarget:self action:@selector(checkoutPressed:) forControlEvents:UIControlEventTouchUpInside];
[cancelButton addTarget:self action:@selector(cancelPressed:) forControlEvents:UIControlEventTouchUpInside];
}
#pragma mark - Button Presses
- (void)applePayPressed:(id)sender
{
[_delegate checkoutSelectionController:self selectedCheckoutType:CheckoutTypeApplePay];
}
- (void)checkoutPressed:(id)sender
{
[_delegate checkoutSelectionController:self selectedCheckoutType:CheckoutTypeNormal];
}
- (void)cancelPressed:(id)sender
{
[_delegate checkoutSelectionControllerCancelled:self];
}
#pragma mark - Transitioning Delegate Methods
- (id <UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source
{
return self;
}
- (id <UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed
{
return self;
}
#pragma mark - Animated Transitioning Methods
- (NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext
{
return kCheckoutAnimationTime;
}
- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext
{
BOOL appearing = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey] == self;
BOOL animated = [transitionContext isAnimated];
UIView *containerView = [transitionContext containerView];
self.view.frame = [containerView bounds];
self.view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
if (appearing) {
[containerView addSubview:self.view];
[_selectionView showButtons:animated ? kCheckoutAnimationTime : 0.0f completion:^(BOOL complete) {
[transitionContext completeTransition:YES];
}];
}
else {
[_selectionView hideButtons:animated ? kCheckoutAnimationTime : 0.0f completion:^(BOOL complete) {
[self.view removeFromSuperview];
[transitionContext completeTransition:YES];
}];
}
}
@end
//
// CheckoutSelectionView.h
// Checkout
//
// Created by Shopify.
// Copyright (c) 2015 Shopify. All rights reserved.
//
@import UIKit;
#import "PAYButton.h"
@interface CheckoutSelectionView : UIView
- (instancetype)initWithFrame:(CGRect)frame buttons:(NSArray *)buttons;
- (void)showButtons:(CGFloat)animationDuration completion:(void (^)(BOOL complete))completion;
- (void)hideButtons:(CGFloat)animationDuration completion:(void (^)(BOOL complete))completion;
@end
//
// CheckoutSelectionView.m
// Checkout
//
// Created by Shopify.
// Copyright (c) 2015 Shopify. All rights reserved.
//
#import "CheckoutSelectionView.h"
//Views
#import "PAYButton.h"
#define kSidePadding 15.0f
#define kButtonIconPadding 8.0f
#define kPaymentButtonHeight 70.0f
#define kAnimationOffset 80.0f
#define kDelay 0.10f
@implementation CheckoutSelectionView {
UIView *_background;
NSArray *_buttons;
}
- (instancetype)initWithFrame:(CGRect)frame buttons:(NSArray *)buttons
{
self = [super initWithFrame:frame];
if (self) {
_background = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]];
_background.alpha = 0.0f;
_background.frame = self.bounds;
_background.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
[self addSubview:_background];
_buttons = buttons;
for (UIButton *button in _buttons) {
[_background addSubview:button];
button.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
}
}
return self;
}
- (CGSize)sizeThatFits:(CGSize)size
{
NSUInteger buttonCount = [_buttons count];
return CGSizeMake(size.width, kPaymentButtonHeight * buttonCount + kSidePadding * (buttonCount + 1));
}
- (void)layoutButtonsAsHidden
{
CGRect bounds = _background.bounds;
CGFloat offsetX = bounds.origin.x + roundf(bounds.size.width / 2) + kSidePadding;
CGFloat offsetY = bounds.origin.y + bounds.size.height - [_buttons count] * (kPaymentButtonHeight + kSidePadding);
CGFloat width = bounds.size.width - 2 * kSidePadding;
for (UIButton *button in _buttons) {
button.frame = CGRectMake(offsetX, offsetY, width, kPaymentButtonHeight);
button.alpha = 0.0f;
offsetY += kPaymentButtonHeight + kSidePadding;
}
}
- (void)showButtons:(CGFloat)animationDuration completion:(void (^)(BOOL complete))completion
{
[self layoutButtonsAsHidden];
[UIView animateWithDuration:animationDuration delay:0.0f options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionAllowUserInteraction animations:^{
_background.alpha = 1.0f;
} completion:nil];
[self animateButtonsToOffset:0.0f duration:animationDuration alpha:1.0f completion:completion];
}
- (void)hideButtons:(CGFloat)animationDuration completion:(void (^)(BOOL complete))completion
{
[UIView animateWithDuration:animationDuration delay:0.0f options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionAllowUserInteraction animations:^{
_background.alpha = 0.0f;
} completion:nil];
[self animateButtonsToOffset:kAnimationOffset duration:animationDuration alpha:0.0f completion:completion];
}
- (void)animateButtonsToOffset:(CGFloat)offset duration:(CGFloat)duration alpha:(CGFloat)alpha completion:(void (^)(BOOL complete))completion
{
CGRect bounds = self.bounds;
CGSize size = [self sizeThatFits:bounds.size];
CGFloat offsetY = bounds.origin.y + bounds.size.height - size.height;
CGFloat offsetX = bounds.origin.x + kSidePadding + offset;
CGFloat delay = 0.0f;
for (UIButton *button in _buttons) {
//Animate each button independently and call the completion handler when the last button has finished animating
[UIView animateWithDuration:duration delay:delay usingSpringWithDamping:0.8f initialSpringVelocity:0.2f options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionAllowUserInteraction animations:^{
button.frame = CGRectMake(offsetX, offsetY, button.frame.size.width, button.frame.size.height);
button.alpha = alpha;
} completion:button == [_buttons lastObject] ? completion : nil];
offsetY += kPaymentButtonHeight + kSidePadding;
delay += kDelay;
}
}
@end
{
"images" : [
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-Small@2x.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-Small@3x.png",
"scale" : "3x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Icon-Small-40@2x.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Icon-Small-40@3x.png",
"scale" : "3x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-60@2x.png",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-60@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "Apple_Pay_mark_normal_@2x.png"
},
{
"idiom" : "universal",
"scale" : "3x",
"filename" : "Apple_Pay_mark_normal_@3x.png"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "back@2x.png"
},
{
"idiom" : "universal",
"scale" : "3x",
"filename" : "back@3x.png"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "forward@2x.png"
},
{
"idiom" : "universal",
"scale" : "3x",
"filename" : "forward@3x.png"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "shop.png"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "shop@2x.png"
},
{
"idiom" : "universal",
"scale" : "3x",
"filename" : "shop@3x.png"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>Web Sample</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.2.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleLightContent</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.in-app-payments</key>
<array/>
</dict>
</plist>
//
// PAYButton.h
// Checkout
//
// Created by Shopify.
// Copyright (c) 2015 Shopify. All rights reserved.
//
@import UIKit;
@interface PAYButton : UIButton
@property (nonatomic, strong, readonly) UIImageView *paymentImageView;
@property (nonatomic, strong, readonly) UILabel *paymentLabel;
@end
//
// PAYButton.m
// Checkout
//
// Created by Shopify.
// Copyright (c) 2015 Shopify. All rights reserved.
//
#import "PAYButton.h"
#define kButtonMargin 11.0f
#define kButtonSelectionInset 3.0f
@implementation PAYButton {
UIView *_highlightView;
UIView *_imageBackgroundView;
BOOL _animating;
}
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
_imageBackgroundView = [[UIView alloc] init];
_imageBackgroundView.backgroundColor = [UIColor whiteColor];
_imageBackgroundView.userInteractionEnabled = NO;
[self addSubview:_imageBackgroundView];
_paymentImageView = [[UIImageView alloc] initWithFrame:_imageBackgroundView.bounds];
_paymentImageView.contentMode = UIViewContentModeCenter;
_paymentImageView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
[_imageBackgroundView addSubview:_paymentImageView];
_paymentLabel = [[UILabel alloc] init];
[_paymentLabel setFont:[UIFont fontWithName:@"HelveticaNeue-Light" size:20.0f]];
[_paymentLabel setTextColor:[UIColor whiteColor]];
[self addSubview:_paymentLabel];
_highlightView = [[UIView alloc] initWithFrame:frame];
_highlightView.alpha = 0.0f;
_highlightView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
_highlightView.backgroundColor = [UIColor colorWithWhite:0.0f alpha:0.2f];
_highlightView.userInteractionEnabled = NO;
[self addSubview:_highlightView];
}
return self;
}
- (CGRect)rectForHighlightedBackground
{
CGRect bounds = self.bounds;
return CGRectMake(bounds.origin.x + kButtonSelectionInset, bounds.origin.y + kButtonSelectionInset, bounds.size.height - kButtonSelectionInset * 2.0f, bounds.size.height - kButtonSelectionInset * 2.0f);
}
- (CGRect)rectForNormalBackground
{
CGRect bounds = self.bounds;
return CGRectMake(bounds.origin.x, bounds.origin.y, bounds.size.height, bounds.size.height);
}
- (void)setButtonFrame:(CGRect)frame
{
_imageBackgroundView.frame = frame;
_highlightView.frame = _imageBackgroundView.frame;
_imageBackgroundView.layer.cornerRadius = floorf(frame.size.height / 2);
_highlightView.layer.cornerRadius = _imageBackgroundView.layer.cornerRadius;
}
- (void)setHighlighted:(BOOL)highlighted
{
if (highlighted != self.isHighlighted) {
[super setHighlighted:highlighted];
CGRect rect = highlighted ? [self rectForHighlightedBackground] : [self rectForNormalBackground];
_animating = YES;
[UIView animateWithDuration:0.1f delay:0.0f options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionAllowUserInteraction animations:^{
_highlightView.alpha = highlighted ? 1.0f : 0.0f;
_paymentLabel.textColor = highlighted ? [UIColor lightGrayColor] : [UIColor whiteColor];
[self setButtonFrame:rect];
} completion:^(BOOL finished) {
_animating = NO;
}];
}
}
- (void)layoutSubviews
{
[super layoutSubviews];
CGRect bounds = self.bounds;
if (_animating == NO) {
[self setButtonFrame:[self rectForNormalBackground]];
}
CGFloat textHeight = ceilf([[_paymentLabel attributedText] size].height);
CGFloat backgroundMaxX = CGRectGetMaxX([self rectForNormalBackground]) + kButtonMargin;
_paymentLabel.frame = CGRectMake(backgroundMaxX, bounds.origin.y + roundf((bounds.size.height - textHeight) * 0.5f), bounds.size.width - backgroundMaxX - kButtonMargin, textHeight);
}
@end
//
// ViewController.h
// Mobile Buy SDK
//
// Created by Shopify.
// Copyright (c) 2015 Shopify Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
@import UIKit;
#import <Buy/Buy.h>
@interface ViewController : BUYStoreViewController
@end
//
// ViewController.m
// Mobile Buy SDK
//
// Created by Shopify.
// Copyright (c) 2015 Shopify Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#import "ViewController.h"
#import "CheckoutSelectionController.h"
@interface ViewController () <BUYStoreViewControllerDelegate, CheckoutSelectionControllerDelegate>
@property (nonatomic, copy) BUYCheckoutTypeBlock callback;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.delegate = self;
// Add a home button to the navigation bar
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.tintColor = [UIColor whiteColor];
UIImage *buttonImage = [UIImage imageNamed:@"shop"];
[button setImage:[buttonImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal];
[button setFrame:CGRectMake(0, 0, 53, 31)];
[button addTarget:self action:@selector(goHome)forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithCustomView:button];
self.navigationItem.rightBarButtonItem = rightButton;
[self loadShopWithCallback:^(BOOL success, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
if (success) {
self.title = self.shop.name;
}
else {
NSLog(@"Error fetching shop: %@", error.localizedDescription);
}
});
}];
}
- (void)goHome
{
[self reloadHomePage];
}
#pragma mark - BUYStoreViewController delegate methods
- (void)controller:(BUYStoreViewController *)controller shouldProceedWithCheckoutType:(BUYCheckoutTypeBlock)completionHandler
{
// If ApplePay is not setup, proceed to normal checkout
if (self.isApplePayAvailable)
{
CheckoutSelectionController *selectionController = [[CheckoutSelectionController alloc] init];
selectionController.delegate = self;
self.callback = completionHandler;
[self presentViewController:selectionController animated:YES completion:nil];
}
else {
completionHandler(BUYCheckoutTypeNormal);
}
}
- (void)controller:(BUYViewController *)controller failedToCreateCheckout:(NSError *)error
{
NSLog(@"Failed to create checkout: %@", error);
}
- (void)controllerFailedToStartApplePayProcess:(BUYViewController *)controller
{
NSLog(@"Failed to start the Apple Pay process. We weren't given an error :(");
}
- (void)controller:(BUYViewController *)controller failedToUpdateCheckout:(BUYCheckout *)checkout withError:(NSError *)error
{
NSLog(@"Failed to update checkout: %@, error: %@", checkout.token, error);
}
- (void)controller:(BUYViewController *)controller failedToGetShippingRates:(BUYCheckout *)checkout withError:(NSError *)error
{
NSLog(@"Failed to get shipping rates: %@, error: %@", checkout.token, error);
}
- (void)controller:(BUYViewController *)controller failedToCompleteCheckout:(BUYCheckout *)checkout withError:(NSError *)error
{
NSLog(@"Failed to complete checkout: %@, error: %@", checkout.token, error);
}
- (void)controller:(BUYViewController *)controller didCompleteCheckout:(BUYCheckout *)checkout status:(BUYStatus)status
{
NSLog(@"Did complete checkout: %@, status: %ld", checkout.token, (unsigned long)status);
}
#pragma mark - PAYSelectionController delegate
- (void)checkoutSelectionControllerCancelled:(CheckoutSelectionController *)controller
{
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)checkoutSelectionController:(CheckoutSelectionController *)controller selectedCheckoutType:(CheckoutType)checkoutType
{
self.callback(checkoutType == CheckoutTypeApplePay ? BUYCheckoutTypeApplePay : BUYCheckoutTypeNormal);
[self dismissViewControllerAnimated:YES completion:nil];
}
@end
//
// main.m
// Mobile Buy SDK
//
// Created by Shopify.
// Copyright (c) 2015 Shopify Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
@import UIKit;
#import "AppDelegate.h"
int main(int argc, char * argv[]) {
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
# Mobile Buy SDK Sample Web App
The web sample app demonstrates how you can load your shop's website in a webview, and support Apple Pay.
### Getting started
First, add your shop domain, API key and Channel ID to the `AppDelegate.h` macros.
```objc
#define SHOP_DOMAIN @"<shop_domain>"
#define API_KEY @"<api_key>"
#define CHANNEL_ID @"<channel_id>"
```
To support Apple Pay, add your Merchant ID as well.
```objc
#define MERCHANT_ID @"<merchant_id>"
```
### Overview
The sample app instantiates a view controller which is a subclass of `BUYStoreViewController`. This displays a webview with your shop, but intercepts the checkout to support Apple Pay.
The sample app also demonstrates how to use the `BUYClient` to obtain shop details by calling `getShop:`
```objc
[self.provider getShop:^(BUYShop *shop, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
if (error == nil && shop) {
self.title = shop.name;
}
else {
NSLog(@"Error fetching shop: %@", error.localizedDescription);
}
});
}];
```
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