Skip to content

Commit

Permalink
Released version 5.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
y2chaits committed Mar 31, 2016
1 parent 2cba814 commit 78fb2e0
Show file tree
Hide file tree
Showing 22 changed files with 82 additions and 57 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2016-03-30
* Released version 5.0.0
* Fixed issue where card reader was allowing chip cards to be swiped
* Changed data type of amount in WPCardReaderDelegate.authorizeAmountWithCompletion: from double to NSDecimalNumber
* Amounts having more than two places after the decimal will result in an WPErrorInvalidAuthInfo error

2016-02-22
* Released version 4.0.0
* Added kWPPaymentMethodDip
Expand Down
2 changes: 1 addition & 1 deletion SwiftExample/SwiftApp/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.0.2</string>
<string>5.0.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
6 changes: 3 additions & 3 deletions SwiftExample/SwiftApp/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let SETTINGS_CLIENT_ID_KEY = "settingClientId"
let SETTINGS_ENVIRONMENT_KEY = "settingEnvironment"
let SETTINGS_ACCOUNT_ID_KEY = "settingAccountId"

let EMV_AMOUNT_DOUBLE = 22.61 // Magic success amount
let EMV_AMOUNT_STRING = "22.61" // Magic success amount
let EMV_READER_SHOULD_RESET = false
let EMV_SELECT_APP_INDEX = 0

Expand Down Expand Up @@ -280,8 +280,8 @@ class ViewController: UIViewController, WPAuthorizationDelegate, WPCardReaderDel
completion(EMV_READER_SHOULD_RESET)
}

func authorizeAmountWithCompletion(completion: ((Double, String!, Int) -> Void)!) {
let amount: Double = EMV_AMOUNT_DOUBLE
func authorizeAmountWithCompletion(completion: ((NSDecimalNumber!, String!, Int) -> Void)!) {
let amount: NSDecimalNumber = NSDecimalNumber(string: EMV_AMOUNT_STRING)
let currencyCode: String = kWPCurrencyCodeUSD

// Change status label
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0.0
5.0.0
2 changes: 1 addition & 1 deletion WePay.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "WePay"
s.version = "4.0.0"
s.version = "5.0.0"
s.summary = "WePay binary for both simulator and iOS devices"
s.description = "A library that helps WePay partners develop their own iOS apps aimed at merchants and/or consumers for collection of payments via various payment methods"
s.homepage = "http://github.com/wepay/wepay-ios"
Expand Down
2 changes: 1 addition & 1 deletion WePay/Internal/WPClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

@implementation WPClient

static NSString * const SDK_VERSION = @"v4.0.0";
static NSString * const SDK_VERSION = @"v5.0.0";
static NSString * const WEPAY_API_VERSION = @"2015-11-18";

#pragma mark config class property
Expand Down
2 changes: 1 addition & 1 deletion WePay/Internal/WPDipTransactionHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/**
* Starts the transaction on the card reader
*/
- (void) performEMVTransactionStartCommandWithAmount:(double)amount
- (void) performEMVTransactionStartCommandWithAmount:(NSDecimalNumber *)amount
currencyCode:(NSString *)currencyCode
accountid:(long)accountId
roamDeviceManager:(id<RUADeviceManager>) roamDeviceManager
Expand Down
15 changes: 7 additions & 8 deletions WePay/Internal/WPDipTransactionHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ @interface WPDipTransactionHelper ()
#define AUTH_RESPONSE_CODE_ONLINE_APPROVE @"00" // any other code is decline
#define MAGIC_TC @"0123456789ABCDEF"

@property (nonatomic, assign) double amount;
@property (nonatomic, strong) NSDecimalNumber *amount;
@property (nonatomic, assign) long accountId;
@property (nonatomic, strong) NSString *currencyCode;

Expand Down Expand Up @@ -112,7 +112,7 @@ - (NSDictionary *)getEMVStartTransactionParameters {
return transactionParameters;
}

- (void) performEMVTransactionStartCommandWithAmount:(double)amount
- (void) performEMVTransactionStartCommandWithAmount:(NSDecimalNumber *)amount
currencyCode:(NSString *)currencyCode
accountid:(long)accountId
roamDeviceManager:(id<RUADeviceManager>) roamDeviceManager
Expand All @@ -121,7 +121,7 @@ - (void) performEMVTransactionStartCommandWithAmount:(double)amount

{
NSLog(@"performEMVTransactionStartCommand");

// save transaction info
self.amount = amount;
self.currencyCode = currencyCode;
Expand Down Expand Up @@ -202,8 +202,7 @@ - (void) startTransaction
[responseData setObject:@(self.isFallbackSwipe) forKey:@"Fallback"];
[responseData setObject:@(self.accountId) forKey:@"AccountId"];
[responseData setObject:self.currencyCode forKey:@"CurrencyCode"];
[responseData setObject:@(self.amount) forKey:@"Amount"];

[responseData setObject:self.amount forKey:@"Amount"];

[self.managerDelegate handleSwipeResponse:responseData];

Expand Down Expand Up @@ -442,7 +441,7 @@ - (void) handleEMVTransactionDataResponse:(RUAResponse *) ruaResponse

- (BOOL) shouldExecuteMagicNumbers
{
BOOL isMagicSuccessAmount = [@[@(21.61), @(121.61), @(22.61), @(122.61), @(24.61), @(124.61), @(25.61), @(125.61)] containsObject:@(self.amount)];
BOOL isMagicSuccessAmount = [@[@(21.61), @(121.61), @(22.61), @(122.61), @(24.61), @(124.61), @(25.61), @(125.61)] containsObject:self.amount];

// YES, if not in production and amount is magic amount
return (![kWPEnvironmentProduction isEqualToString:self.wepayEnvironment] && isMagicSuccessAmount);
Expand Down Expand Up @@ -719,9 +718,9 @@ - (void) reactToError:(NSError *)error forPaymentMethod:(NSString *)paymentMetho
}
}

- (NSString *) convertToEMVAmount:(double) amount
- (NSString *) convertToEMVAmount:(NSDecimalNumber *)amount
{
int intAmount = (int) (amount*100);
int intAmount = [[amount decimalNumberByMultiplyingByPowerOf10:2] intValue];
return [NSString stringWithFormat:@"%012d", intAmount];
}

Expand Down
4 changes: 2 additions & 2 deletions WePay/Internal/WPExternalCardReaderHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ - (void) informExternalCardReaderResetCompletion:(void (^)(BOOL shouldReset))com
});
}

- (void) informExternalCardReaderAmountCompletion:(void (^)(BOOL implemented, double amount, NSString *currencyCode, long accountId))innerCompletion
- (void) informExternalCardReaderAmountCompletion:(void (^)(BOOL implemented, NSDecimalNumber *amount, NSString *currencyCode, long accountId))innerCompletion
{
dispatch_queue_t queue = self.config.callDelegateMethodsOnMainThread ? dispatch_get_main_queue() : dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(queue, ^{
// If the external delegate is listening for auth info request, ask for it
if (self.externalCardReaderDelegate && [self.externalCardReaderDelegate respondsToSelector:@selector(authorizeAmountWithCompletion:)]) {
[self.externalCardReaderDelegate authorizeAmountWithCompletion:^(double amount, NSString *currencyCode, long accountId) {
[self.externalCardReaderDelegate authorizeAmountWithCompletion:^(NSDecimalNumber *amount, NSString *currencyCode, long accountId) {
innerCompletion(YES, amount, currencyCode, accountId);
}];
} else {
Expand Down
4 changes: 2 additions & 2 deletions WePay/Internal/WPG5XManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ - (void) waitForSwipe
}

// fetch Tx info from delegate
[self.managerDelegate fetchAuthInfo:^(BOOL implemented, double amount, NSString *currencyCode, long accountId) {
[self.managerDelegate fetchAuthInfo:^(BOOL implemented, NSDecimalNumber *amount, NSString *currencyCode, long accountId) {
NSError *error = [self.managerDelegate validateAuthInfoImplemented:implemented amount:amount currencyCode:currencyCode accountId:accountId];
if (error != nil) {
// we found an error, return it
Expand All @@ -162,7 +162,7 @@ - (void) waitForSwipe
[responseData setObject:@(NO) forKey:@"Fallback"];
[responseData setObject:@(accountId) forKey:@"AccountId"];
[responseData setObject:currencyCode forKey:@"CurrencyCode"];
[responseData setObject:@(amount) forKey:@"Amount"];
[responseData setObject:amount forKey:@"Amount"];

[self.managerDelegate handleSwipeResponse:responseData];
}
Expand Down
21 changes: 19 additions & 2 deletions WePay/Internal/WPRP350XManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ - (void) stopWaitingForCard
- (void) fetchAuthInfoForTransaction
{
// fetch Tx info from delegate
[processor.managerDelegate fetchAuthInfo:^(BOOL implemented, double amount, NSString *currencyCode, long accountId) {
[processor.managerDelegate fetchAuthInfo:^(BOOL implemented, NSDecimalNumber *amount, NSString *currencyCode, long accountId) {
NSError *error = [self.managerDelegate validateAuthInfoImplemented:implemented amount:amount currencyCode:currencyCode accountId:accountId];
if (error != nil) {
// we found an error, return it
Expand Down Expand Up @@ -291,12 +291,29 @@ - (void)setupTransactionDOLs
} response:^(RUAResponse *response) {
NSLog(@"RUAResponseMessage: %@",[WPRoamHelper RUAResponse_toDictionary:response]);

[processor setupExpectedDOLs];
[processor setUserInterfaceOptions];
}];
}];
}];
}

- (void) setUserInterfaceOptions
{
id <RUAConfigurationManager> cmgr = [self.roamDeviceManager getConfigurationManager];

[cmgr setUserInterfaceOptions:30
withDefaultLanguageCode:RUALanguageCodeENGLISH
withPinPadOptions:0x00
withBackLightControl:0x00
progress: ^(RUAProgressMessage messageType, NSString* additionalMessage) {
NSLog(@"RUAProgressMessage: %@",[WPRoamHelper RUAProgressMessage_toString:messageType]);
}
response: ^(RUAResponse *response) {
NSLog(@"RUAResponseMessage: %@",[WPRoamHelper RUAResponse_toDictionary:response]);
[processor setupExpectedDOLs];
}];
}

- (void)setupExpectedDOLs
{
id <RUAConfigurationManager> cmgr = [self.roamDeviceManager getConfigurationManager];
Expand Down
6 changes: 3 additions & 3 deletions WePay/Internal/WePay_CardReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ extern NSString *const kRP350XModelName;
- (void) issueReversalForCreditCardId:(NSNumber *)creditCardId
accountId:(NSNumber *)accountId
roamResponse:(NSDictionary *)cardInfo;
- (void) fetchAuthInfo:(void (^)(BOOL implemented, double amount, NSString *currencyCode, long accountId))completion;
- (void) fetchAuthInfo:(void (^)(BOOL implemented, NSDecimalNumber *amount, NSString *currencyCode, long accountId))completion;
- (void) handleDeviceStatusError:(NSString *)message;
- (void) connectedDevice:(NSString *)deviceType;
- (void) disconnectedDevice;

- (NSError *) validateAuthInfoImplemented:(BOOL)implemented
amount:(double)amount
amount:(NSDecimalNumber *)amount
currencyCode:(NSString *)currencyCode
accountId:(long)accountId;
- (NSError *) validatePaymentInfoForTokenization:(WPPaymentInfo *)paymentInfo;
Expand All @@ -58,7 +58,7 @@ extern NSString *const kRP350XModelName;
- (void) informExternalCardReaderSuccess:(WPPaymentInfo *)paymentInfo;
- (void) informExternalCardReaderFailure:(NSError *)error;
- (void) informExternalCardReaderResetCompletion:(void (^)(BOOL shouldReset))completion;
- (void) informExternalCardReaderAmountCompletion:(void (^)(BOOL implemented, double amount, NSString *currencyCode, long accountId))completion;
- (void) informExternalCardReaderAmountCompletion:(void (^)(BOOL implemented, NSDecimalNumber *amount, NSString *currencyCode, long accountId))completion;

- (void) informExternalTokenizerSuccess:(WPPaymentToken *)token forPaymentInfo:(WPPaymentInfo *)paymentInfo;
- (void) informExternalTokenizerFailure:(NSError *)error forPaymentInfo:(WPPaymentInfo *)paymentInfo;
Expand Down
11 changes: 7 additions & 4 deletions WePay/Internal/WePay_CardReader.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
NSString *const kRP350XModelName = @"RP350X";
NSString *const kG5XModelName = @"G5X";

#define READ_AMOUNT 10.0
#define READ_AMOUNT [NSDecimalNumber one]
#define READ_CURRENCY @"USD"
#define READ_ACCOUNT_ID 12345

Expand Down Expand Up @@ -256,7 +256,7 @@ - (void) issueReversalForCreditCardId:(NSNumber *)creditCardId
}];
}

- (void) fetchAuthInfo:(void (^)(BOOL implemented, double amount, NSString *currencyCode, long accountId))completion
- (void) fetchAuthInfo:(void (^)(BOOL implemented, NSDecimalNumber *amount, NSString *currencyCode, long accountId))completion
{
if (self.swiperShouldTokenize) {
// ask external for auth info
Expand All @@ -268,15 +268,18 @@ - (void) fetchAuthInfo:(void (^)(BOOL implemented, double amount, NSString *curr
}

- (NSError *) validateAuthInfoImplemented:(BOOL)implemented
amount:(double)amount
amount:(NSDecimalNumber *)amount
currencyCode:(NSString *)currencyCode
accountId:(long)accountId
{
NSArray *allowedCurrencyCodes = @[kWPCurrencyCodeUSD];

if (!implemented) {
return [WPError errorAuthInfoNotProvided];
} else if (((int) (amount*100)) <= 0) {
} else if (amount == nil
|| [amount isEqual:[NSNull null]]
|| [[amount decimalNumberByMultiplyingByPowerOf10:2] intValue] < 99 // amount is less than 0.99
|| ([currencyCode isEqualToString:kWPCurrencyCodeUSD] && amount.decimalValue._exponent < -2)) { // USD amount has more than 2 places after decimal point
return [WPError errorInvalidAuthInfo];
} else if (![allowedCurrencyCodes containsObject:currencyCode]) {
return [WPError errorInvalidAuthInfo];
Expand Down
8 changes: 4 additions & 4 deletions WePay/Models/WPAuthorizationInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@
/**
* The amount that was authorized.
*/
@property (nonatomic, readonly) double amount;
@property (nonatomic, strong, readonly) NSDecimalNumber *amount;

/**
* The currency code that the amount is specified in.
*/
@property (nonatomic, strong, readonly) NSString* currencyCode;
@property (nonatomic, strong, readonly) NSString *currencyCode;

/**
* The transaction token that certifies the transaction.
*/
@property (nonatomic, strong, readonly) NSString* transactionToken;
@property (nonatomic, strong, readonly) NSString *transactionToken;

/**
* Initializes a \ref WPAuthorizationInfo with the info provided.
Expand All @@ -38,7 +38,7 @@
*
* @return A \ref WPAuthorizationInfo object initialized with the info provided.
*/
- (instancetype) initWithAmount:(double) amount
- (instancetype) initWithAmount:(NSDecimalNumber *)amount
currencyCode:(NSString *)currencyCode
transactionToken:(NSString *)transactionToken
tokenId:(NSString* )tokenId;
Expand Down
10 changes: 5 additions & 5 deletions WePay/Models/WPAuthorizationInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@

@interface WPAuthorizationInfo()

@property (nonatomic, readwrite) double amount;
@property (nonatomic, strong, readwrite) NSString* currencyCode;
@property (nonatomic, strong, readwrite) NSString* transactionToken;
@property (nonatomic, strong, readwrite) NSDecimalNumber *amount;
@property (nonatomic, strong, readwrite) NSString *currencyCode;
@property (nonatomic, strong, readwrite) NSString *transactionToken;


@end

@implementation WPAuthorizationInfo

- (instancetype) initWithAmount:(double) amount
- (instancetype) initWithAmount:(NSDecimalNumber *)amount
currencyCode:(NSString *)currencyCode
transactionToken:(NSString *)transactionToken
tokenId:(NSString* )tokenId
Expand All @@ -38,7 +38,7 @@ - (NSDictionary *) toDict
NSMutableDictionary *dict = [NSMutableDictionary dictionary];

[dict setValue:self.tokenId ? self.tokenId : [NSNull null] forKey:@"tokenId"];
[dict setValue:self.amount ? @(self.amount) : [NSNull null] forKey:@"amount"];
[dict setValue:self.amount ? self.amount : [NSNull null] forKey:@"amount"];
[dict setValue:self.currencyCode ? self.currencyCode : [NSNull null] forKey:@"currencyCode"];
[dict setValue:self.transactionToken ? self.transactionToken : [NSNull null] forKey:@"transactionToken"];

Expand Down
10 changes: 5 additions & 5 deletions WePay/WePay.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,16 @@ didFailAuthorization:(NSError *)error;

/**
* Called when an EMV reader is connected, so that you can provide the amount, currency code and the WePay account Id of the merchant. The transaction cannot proceed until the completion block is executed.
* Note: In the staging environment, use amounts of 20.61, 120.61, 23.61 and 123.61 to simulate authorization errors. Amounts of 21.61, 121.61, 22.61 and 122.61 will simulate successful auth.
* Note: In the staging environment, use amounts of 20.61, 120.61, 23.61 and 123.61 to simulate authorization errors. Amounts of 21.61, 121.61, 22.61, 122.61, 24.61, 124.61, 25.61, and 125.61 will simulate successful auth.
* Example:
* completion(21.61, @"USD", 1234567);
* completion([NSDecimalNumber decimalNumberWithString:@"21.61"], kWPCurrencyCodeUSD, 1234567);
*
* @param completion The block to be executed with the amount, currency code and merchant account Id for the transaction.
* @param amount The amount for the transaction. It will be truncated to two places after the decimal point.
* @param currencyCode The 3-character ISO 4217 currency code. e.g. @"USD".
* @param amount The amount for the transaction. For USD amounts, there can be a maximum of two places after the decimal point. (amount.decimalValue._exponent must be >= -2)
* @param currencyCode The 3-character ISO 4217 currency code. The only supported currency code is kWPCurrencyCodeUSD.
* @param accountId The WePay account id of the merchant.
*/
- (void) authorizeAmountWithCompletion:(void (^)(double amount, NSString *currencyCode, long accountId))completion;
- (void) authorizeAmountWithCompletion:(void (^)(NSDecimalNumber *amount, NSString *currencyCode, long accountId))completion;

@end

Expand Down
2 changes: 1 addition & 1 deletion WePayExample/WePayExample/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>4.0.0</string>
<string>5.0.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@
/**
* The amount that was authorized.
*/
@property (nonatomic, readonly) double amount;
@property (nonatomic, strong, readonly) NSDecimalNumber *amount;

/**
* The currency code that the amount is specified in.
*/
@property (nonatomic, strong, readonly) NSString* currencyCode;
@property (nonatomic, strong, readonly) NSString *currencyCode;

/**
* The transaction token that certifies the transaction.
*/
@property (nonatomic, strong, readonly) NSString* transactionToken;
@property (nonatomic, strong, readonly) NSString *transactionToken;

/**
* Initializes a \ref WPAuthorizationInfo with the info provided.
Expand All @@ -38,7 +38,7 @@
*
* @return A \ref WPAuthorizationInfo object initialized with the info provided.
*/
- (instancetype) initWithAmount:(double) amount
- (instancetype) initWithAmount:(NSDecimalNumber *)amount
currencyCode:(NSString *)currencyCode
transactionToken:(NSString *)transactionToken
tokenId:(NSString* )tokenId;
Expand Down
Loading

0 comments on commit 78fb2e0

Please sign in to comment.