Skip to content

Commit

Permalink
Merge pull request #66 from square/amber/add-disableKeyedIn-skipReceipt
Browse files Browse the repository at this point in the history
Add options to disable keyed-in cards and skipping receipt screen
  • Loading branch information
kgleong authored Oct 29, 2018
2 parents 681f789 + c8de5c3 commit fcb4414
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Sources/Categories/SCCAPIRequest+Serialization.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ extern NSString *__nonnull const SCCAPIRequestOptionsKey;
extern NSString *__nonnull const SCCAPIRequestOptionsClearDefaultFeesKey;
extern NSString *__nonnull const SCCAPIRequestOptionsSupportedTenderTypesKey;
extern NSString *__nonnull const SCCAPIRequestOptionsAutoReturnKey;
extern NSString *__nonnull const SCCAPIRequestOptionsDisableCNPKey;
extern NSString *__nonnull const SCCAPIRequestOptionsSkipReceiptKey;
extern NSString *__nonnull const SCCAPIRequestOptionsTenderTypeStringCard;
extern NSString *__nonnull const SCCAPIRequestOptionsTenderTypeStringCash;
extern NSString *__nonnull const SCCAPIRequestOptionsTenderTypeStringOther;
Expand Down
8 changes: 8 additions & 0 deletions Sources/SCCAPIRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ typedef NS_OPTIONS(NSUInteger, SCCAPIRequestTenderTypes) {
/// of the value of this parameter.
@property (nonatomic, assign, readonly) BOOL returnsAutomaticallyAfterPayment;

/// If YES, Point of Sale will not display the option to manually key-in a credit card number.
/// Defaults to NO.
@property (nonatomic, assign) BOOL disablesKeyedInCardEntry;

/// If YES, Point of Sale will skip the receipt screen of the payment flow for non-cash payments.
/// Defaults to NO.
@property (nonatomic, assign) BOOL skipsReceipt;

/**
@param request The request to compare the receiver to.
@return YES if the receiver and `request` are logically equivalent.
Expand Down
10 changes: 8 additions & 2 deletions Sources/SCCAPIRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
NSString *__nonnull const SCCAPIRequestOptionsSupportedTenderTypesKey = @"supported_tender_types";
NSString *__nonnull const SCCAPIRequestOptionsClearDefaultFeesKey = @"clear_default_fees";
NSString *__nonnull const SCCAPIRequestOptionsAutoReturnKey = @"auto_return";
NSString *__nonnull const SCCAPIRequestOptionsDisableCNPKey = @"disable_cnp";
NSString *__nonnull const SCCAPIRequestOptionsSkipReceiptKey = @"skip_receipt";
NSString *__nonnull const SCCAPIRequestOptionsTenderTypeStringCard = @"CREDIT_CARD";
NSString *__nonnull const SCCAPIRequestOptionsTenderTypeStringCash = @"CASH";
NSString *__nonnull const SCCAPIRequestOptionsTenderTypeStringOther = @"OTHER";
Expand Down Expand Up @@ -185,7 +187,7 @@ - (NSUInteger)hash;
{
NSUInteger const hashOfRequiredFields = self.clientID.hash ^ self.callbackURL.hash ^ self.amount.hash;
NSUInteger const hashOfOptionalFields = self.userInfoString.hash ^ self.locationID.hash ^ self.notes.hash ^ self.customerID.hash;
NSUInteger const hashOfScalarFields = (NSUInteger)self.supportedTenderTypes ^ (NSUInteger)self.clearsDefaultFees ^ (NSUInteger)self.returnsAutomaticallyAfterPayment;
NSUInteger const hashOfScalarFields = (NSUInteger)self.supportedTenderTypes ^ (NSUInteger)self.clearsDefaultFees ^ (NSUInteger)self.returnsAutomaticallyAfterPayment ^ (NSUInteger)self.disablesKeyedInCardEntry ^ (NSUInteger)self.skipsReceipt;

return hashOfRequiredFields ^ hashOfOptionalFields ^ hashOfScalarFields;
}
Expand Down Expand Up @@ -232,7 +234,9 @@ - (BOOL)isEqualToAPIRequest:(nullable SCCAPIRequest *)request;
// The following properties are scalar.
if (!(self.supportedTenderTypes == request.supportedTenderTypes) ||
!(self.clearsDefaultFees == request.clearsDefaultFees) ||
!(self.returnsAutomaticallyAfterPayment == request.returnsAutomaticallyAfterPayment)) {
!(self.returnsAutomaticallyAfterPayment == request.returnsAutomaticallyAfterPayment) ||
!(self.disablesKeyedInCardEntry == request.disablesKeyedInCardEntry) ||
!(self.skipsReceipt == request.skipsReceipt)) {
return NO;
}

Expand Down Expand Up @@ -273,6 +277,8 @@ - (nullable NSURL *)APIRequestURLWithError:(out NSError *__nullable *__nullable)
[options SCC_setSafeObject:supportedTenderTypes forKey:SCCAPIRequestOptionsSupportedTenderTypesKey];
[options SCC_setSafeObject:@(self.clearsDefaultFees) forKey:SCCAPIRequestOptionsClearDefaultFeesKey];
[options SCC_setSafeObject:@(self.returnsAutomaticallyAfterPayment) forKey:SCCAPIRequestOptionsAutoReturnKey];
[options SCC_setSafeObject:@(self.disablesKeyedInCardEntry) forKey:SCCAPIRequestOptionsDisableCNPKey];
[options SCC_setSafeObject:@(self.skipsReceipt) forKey:SCCAPIRequestOptionsSkipReceiptKey];
if (options.count) {
[data SCC_setSafeObject:options forKey:SCCAPIRequestOptionsKey];
}
Expand Down
2 changes: 1 addition & 1 deletion SquarePointOfSaleSDK.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'SquarePointOfSaleSDK'
s.version = '3.3.1'
s.version = '3.3.2'
s.summary = 'SDK for easier use of Square\'s Point of Sale app-switching API on iOS'
s.homepage = 'https://github.com/square/SquarePointOfSaleSDK-iOS/'
s.license = { :type => 'Apache License, Version 2.0', :text => #{ Date.today.year } Square, Inc." }
Expand Down

0 comments on commit fcb4414

Please sign in to comment.