Commit a8a9b788 by Dima Bart

Move BUYPaymentButton into sample app.

parent dc38dcf4
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
90B2623E1BB0A47B006D888F /* ProductViewControllerThemeStyleTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 90B2623D1BB0A47B006D888F /* ProductViewControllerThemeStyleTableViewCell.m */; }; 90B2623E1BB0A47B006D888F /* ProductViewControllerThemeStyleTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 90B2623D1BB0A47B006D888F /* ProductViewControllerThemeStyleTableViewCell.m */; };
90B262411BB0A726006D888F /* ProductViewControllerToggleTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 90B262401BB0A726006D888F /* ProductViewControllerToggleTableViewCell.m */; }; 90B262411BB0A726006D888F /* ProductViewControllerToggleTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 90B262401BB0A726006D888F /* ProductViewControllerToggleTableViewCell.m */; };
90B262441BB18B10006D888F /* ProductViewControllerThemeTintColorTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 90B262431BB18B10006D888F /* ProductViewControllerThemeTintColorTableViewCell.m */; }; 90B262441BB18B10006D888F /* ProductViewControllerThemeTintColorTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 90B262431BB18B10006D888F /* ProductViewControllerThemeTintColorTableViewCell.m */; };
9A0B0C871CEC8F370037D68F /* BUYPaymentButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A0B0C861CEC8F370037D68F /* BUYPaymentButton.m */; };
BE3437A21BC5C19D00C71330 /* Buy.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BE34379F1BC5C18400C71330 /* Buy.framework */; }; BE3437A21BC5C19D00C71330 /* Buy.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BE34379F1BC5C18400C71330 /* Buy.framework */; };
BE3437A31BC5C19D00C71330 /* Buy.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = BE34379F1BC5C18400C71330 /* Buy.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; BE3437A31BC5C19D00C71330 /* Buy.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = BE34379F1BC5C18400C71330 /* Buy.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
BE8B82511B8CF49D00E3F871 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = BE8B82501B8CF49D00E3F871 /* main.m */; }; BE8B82511B8CF49D00E3F871 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = BE8B82501B8CF49D00E3F871 /* main.m */; };
...@@ -205,6 +206,8 @@ ...@@ -205,6 +206,8 @@
90B262401BB0A726006D888F /* ProductViewControllerToggleTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProductViewControllerToggleTableViewCell.m; sourceTree = "<group>"; }; 90B262401BB0A726006D888F /* ProductViewControllerToggleTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProductViewControllerToggleTableViewCell.m; sourceTree = "<group>"; };
90B262421BB18B10006D888F /* ProductViewControllerThemeTintColorTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProductViewControllerThemeTintColorTableViewCell.h; sourceTree = "<group>"; }; 90B262421BB18B10006D888F /* ProductViewControllerThemeTintColorTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProductViewControllerThemeTintColorTableViewCell.h; sourceTree = "<group>"; };
90B262431BB18B10006D888F /* ProductViewControllerThemeTintColorTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProductViewControllerThemeTintColorTableViewCell.m; sourceTree = "<group>"; }; 90B262431BB18B10006D888F /* ProductViewControllerThemeTintColorTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProductViewControllerThemeTintColorTableViewCell.m; sourceTree = "<group>"; };
9A0B0C851CEC8F370037D68F /* BUYPaymentButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BUYPaymentButton.h; sourceTree = "<group>"; };
9A0B0C861CEC8F370037D68F /* BUYPaymentButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BUYPaymentButton.m; sourceTree = "<group>"; };
BE34378F1BC5C18400C71330 /* Mobile Buy SDK.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "Mobile Buy SDK.xcodeproj"; path = "../../Mobile Buy SDK/Mobile Buy SDK.xcodeproj"; sourceTree = "<group>"; }; BE34378F1BC5C18400C71330 /* Mobile Buy SDK.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "Mobile Buy SDK.xcodeproj"; path = "../../Mobile Buy SDK/Mobile Buy SDK.xcodeproj"; sourceTree = "<group>"; };
BE5E28451B94F5C300D2ECB5 /* Mobile Buy SDK Advanced Sample.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = "Mobile Buy SDK Advanced Sample.entitlements"; sourceTree = "<group>"; }; BE5E28451B94F5C300D2ECB5 /* Mobile Buy SDK Advanced Sample.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = "Mobile Buy SDK Advanced Sample.entitlements"; sourceTree = "<group>"; };
BE8B824B1B8CF49D00E3F871 /* Mobile Buy SDK Advanced Sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Mobile Buy SDK Advanced Sample.app"; sourceTree = BUILT_PRODUCTS_DIR; }; BE8B824B1B8CF49D00E3F871 /* Mobile Buy SDK Advanced Sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Mobile Buy SDK Advanced Sample.app"; sourceTree = BUILT_PRODUCTS_DIR; };
...@@ -334,6 +337,8 @@ ...@@ -334,6 +337,8 @@
8476128F1CAB059100AB17AA /* PaymentButton */ = { 8476128F1CAB059100AB17AA /* PaymentButton */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
9A0B0C851CEC8F370037D68F /* BUYPaymentButton.h */,
9A0B0C861CEC8F370037D68F /* BUYPaymentButton.m */,
847612901CAB059100AB17AA /* ImageKit.h */, 847612901CAB059100AB17AA /* ImageKit.h */,
847612911CAB059100AB17AA /* ImageKit.m */, 847612911CAB059100AB17AA /* ImageKit.m */,
847612921CAB059100AB17AA /* UIButton+PaymentButton.h */, 847612921CAB059100AB17AA /* UIButton+PaymentButton.h */,
...@@ -377,9 +382,9 @@ ...@@ -377,9 +382,9 @@
BE3437901BC5C18400C71330 /* Products */ = { BE3437901BC5C18400C71330 /* Products */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
BE34379F1BC5C18400C71330 /* Buy.framework */,
BE34379D1BC5C18400C71330 /* Buy.framework */,
BE34379B1BC5C18400C71330 /* Mobile Buy SDK Tests.xctest */, BE34379B1BC5C18400C71330 /* Mobile Buy SDK Tests.xctest */,
BE34379D1BC5C18400C71330 /* Buy.framework */,
BE34379F1BC5C18400C71330 /* Buy.framework */,
); );
name = Products; name = Products;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -577,6 +582,7 @@ ...@@ -577,6 +582,7 @@
8476127B1CAB047600AB17AA /* HeaderBackgroundView.m in Sources */, 8476127B1CAB047600AB17AA /* HeaderBackgroundView.m in Sources */,
BE8B82951B8E65D700E3F871 /* PreCheckoutViewController.m in Sources */, BE8B82951B8E65D700E3F871 /* PreCheckoutViewController.m in Sources */,
8476127F1CAB047600AB17AA /* OptionSelectionViewController.m in Sources */, 8476127F1CAB047600AB17AA /* OptionSelectionViewController.m in Sources */,
9A0B0C871CEC8F370037D68F /* BUYPaymentButton.m in Sources */,
8476127C1CAB047600AB17AA /* HeaderOverlayView.m in Sources */, 8476127C1CAB047600AB17AA /* HeaderOverlayView.m in Sources */,
8476127A1CAB047600AB17AA /* ProductViewHeader.m in Sources */, 8476127A1CAB047600AB17AA /* ProductViewHeader.m in Sources */,
847612841CAB047600AB17AA /* VariantSelectionViewController.m in Sources */, 847612841CAB047600AB17AA /* VariantSelectionViewController.m in Sources */,
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
// THE SOFTWARE. // THE SOFTWARE.
// //
#import <Buy/Buy.h>
#import "CheckoutViewController.h" #import "CheckoutViewController.h"
#import "GetCompletionStatusOperation.h" #import "GetCompletionStatusOperation.h"
#import "SummaryItemsTableViewCell.h" #import "SummaryItemsTableViewCell.h"
...@@ -136,11 +137,11 @@ NSString * const MerchantId = @""; ...@@ -136,11 +137,11 @@ NSString * const MerchantId = @"";
return cell; return cell;
} }
- (void)addCreditCardToCheckout:(void (^)(BOOL success))callback - (void)addCreditCardToCheckout:(void (^)(BOOL success, id<BUYPaymentToken> token))callback
{ {
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES]; [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
[self.client storeCreditCard:[self creditCard] checkout:self.checkout completion:^(BUYCheckout *checkout, NSString *paymentSessionId, NSError *error) { [self.client storeCreditCard:[self creditCard] checkout:self.checkout completion:^(BUYCheckout *checkout, id<BUYPaymentToken> token, NSError *error) {
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO]; [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
...@@ -153,7 +154,7 @@ NSString * const MerchantId = @""; ...@@ -153,7 +154,7 @@ NSString * const MerchantId = @"";
NSLog(@"Error applying credit card: %@", error); NSLog(@"Error applying credit card: %@", error);
} }
callback(error == nil && checkout); callback(error == nil && checkout, token);
}]; }];
} }
...@@ -209,14 +210,14 @@ NSString * const MerchantId = @""; ...@@ -209,14 +210,14 @@ NSString * const MerchantId = @"";
__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) { [self addCreditCardToCheckout:^(BOOL success, id<BUYPaymentToken> token) {
if (success) { if (success) {
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES]; [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
// Upon successfully adding the credit card to the checkout, complete checkout must be called immediately // Upon successfully adding the credit card to the checkout, complete checkout must be called immediately
[welf.client completeCheckout:welf.checkout 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) {
......
//
// BUYPaymentButton.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.
//
typedef NS_ENUM(NSInteger, BUYPaymentButtonStyle) {
BUYPaymentButtonStyleWhite = 0,
BUYPaymentButtonStyleWhiteOutline,
BUYPaymentButtonStyleBlack
};
typedef NS_ENUM(NSInteger, BUYPaymentButtonType) {
BUYPaymentButtonTypePlain = 0,
BUYPaymentButtonTypeBuy,
BUYPaymentButtonTypeSetup NS_ENUM_AVAILABLE_IOS(9_0)
};
@interface BUYPaymentButton : UIButton
+ (instancetype)buttonWithType:(BUYPaymentButtonType)buttonType style:(BUYPaymentButtonStyle)buttonStyle;
@end
...@@ -75,7 +75,6 @@ FOUNDATION_EXPORT const unsigned char BuyVersionString[]; ...@@ -75,7 +75,6 @@ FOUNDATION_EXPORT const unsigned char BuyVersionString[];
#import <Buy/BUYShopifyErrorCodes.h> #import <Buy/BUYShopifyErrorCodes.h>
#import <Buy/BUYPaymentToken.h> #import <Buy/BUYPaymentToken.h>
#import <Buy/BUYPaymentButton.h>
#import <Buy/NSArray+BUYAdditions.h> #import <Buy/NSArray+BUYAdditions.h>
#import <Buy/NSDate+BUYAdditions.h> #import <Buy/NSDate+BUYAdditions.h>
......
...@@ -72,7 +72,6 @@ ...@@ -72,7 +72,6 @@
#import "BUYShopifyErrorCodes.h" #import "BUYShopifyErrorCodes.h"
#import "BUYPaymentToken.h" #import "BUYPaymentToken.h"
#import "BUYPaymentButton.h"
#import "NSArray+BUYAdditions.h" #import "NSArray+BUYAdditions.h"
#import "NSDateFormatter+BUYAdditions.h" #import "NSDateFormatter+BUYAdditions.h"
......
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