-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
1,138 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#import <React/RCTBridgeModule.h> | ||
|
||
@interface RNCloudPayments : NSObject <RCTBridgeModule> | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#import "RNCloudPayments.h" | ||
#import "SDK/Card.m" | ||
|
||
@implementation RNCloudPayments | ||
|
||
RCT_EXPORT_MODULE(); | ||
|
||
RCT_EXPORT_METHOD(isValidNumber: (NSString *)cardNumber | ||
cardExp: (NSString *)cardExp | ||
cardCvv: (NSString *)cardCvv | ||
resolve: (RCTPromiseResolveBlock)resolve | ||
reject: (RCTPromiseRejectBlock)reject) | ||
{ | ||
if([Card isCardNumberValid: cardNumber]) { | ||
resolve(@YES); | ||
} else { | ||
resolve(@NO); | ||
} | ||
}; | ||
|
||
RCT_EXPORT_METHOD(getType: (NSString *)cardNumber | ||
cardExp: (NSString *)cardExp | ||
cardCvv: (NSString *)cardCvv | ||
resolve: (RCTPromiseResolveBlock)resolve | ||
reject: (RCTPromiseRejectBlock)reject) | ||
{ | ||
CardType cardType = [Card cardTypeFromCardNumber: cardNumber]; | ||
NSString *cardTypeString = [Card cardTypeToString: cardType]; | ||
|
||
resolve(cardTypeString); | ||
} | ||
|
||
RCT_EXPORT_METHOD(createCryptogram: (NSString *)cardNumber | ||
cardExp: (NSString *)cardExp | ||
cardCvv: (NSString *)cardCvv | ||
publicId: (NSString *)publicId | ||
resolve: (RCTPromiseResolveBlock)resolve | ||
reject: (RCTPromiseRejectBlock)reject) | ||
{ | ||
Card *_card = [[Card alloc] init]; | ||
|
||
NSString *cryptogram = [_card makeCardCryptogramPacket: cardNumber andExpDate:cardExp andCVV:cardCvv andMerchantPublicID:publicId]; | ||
|
||
resolve(cryptogram); | ||
} | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,297 @@ | ||
// !$*UTF8*$! | ||
{ | ||
archiveVersion = 1; | ||
classes = { | ||
}; | ||
objectVersion = 50; | ||
objects = { | ||
|
||
/* Begin PBXBuildFile section */ | ||
954FC90C20AADA700017B273 /* RNCloudPayments.m in Sources */ = {isa = PBXBuildFile; fileRef = 954FC90B20AADA700017B273 /* RNCloudPayments.m */; }; | ||
954FC9F920AC08E60017B273 /* Card.m in Sources */ = {isa = PBXBuildFile; fileRef = 954FC9F620AC08E60017B273 /* Card.m */; }; | ||
954FC9FA20AC08E60017B273 /* NSDataENBase64.m in Sources */ = {isa = PBXBuildFile; fileRef = 954FC9F720AC08E60017B273 /* NSDataENBase64.m */; }; | ||
/* End PBXBuildFile section */ | ||
|
||
/* Begin PBXCopyFilesBuildPhase section */ | ||
95E3C63020ADAE9D0098BA8E /* CopyFiles */ = { | ||
isa = PBXCopyFilesBuildPhase; | ||
buildActionMask = 2147483647; | ||
dstPath = "include/$(PRODUCT_NAME)"; | ||
dstSubfolderSpec = 16; | ||
files = ( | ||
); | ||
runOnlyForDeploymentPostprocessing = 0; | ||
}; | ||
/* End PBXCopyFilesBuildPhase section */ | ||
|
||
/* Begin PBXFileReference section */ | ||
954FC90720AADA700017B273 /* libRNCloudPayments.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNCloudPayments.a; sourceTree = BUILT_PRODUCTS_DIR; }; | ||
954FC90A20AADA700017B273 /* RNCloudPayments.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNCloudPayments.h; sourceTree = "<group>"; }; | ||
954FC90B20AADA700017B273 /* RNCloudPayments.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNCloudPayments.m; sourceTree = "<group>"; }; | ||
954FC9F520AC08E60017B273 /* NSDataENBase64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSDataENBase64.h; sourceTree = "<group>"; }; | ||
954FC9F620AC08E60017B273 /* Card.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Card.m; sourceTree = "<group>"; }; | ||
954FC9F720AC08E60017B273 /* NSDataENBase64.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSDataENBase64.m; sourceTree = "<group>"; }; | ||
954FC9F820AC08E60017B273 /* Card.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Card.h; sourceTree = "<group>"; }; | ||
/* End PBXFileReference section */ | ||
|
||
/* Begin PBXFrameworksBuildPhase section */ | ||
954FC90420AADA700017B273 /* Frameworks */ = { | ||
isa = PBXFrameworksBuildPhase; | ||
buildActionMask = 2147483647; | ||
files = ( | ||
); | ||
runOnlyForDeploymentPostprocessing = 0; | ||
}; | ||
/* End PBXFrameworksBuildPhase section */ | ||
|
||
/* Begin PBXGroup section */ | ||
954FC8FE20AADA700017B273 = { | ||
isa = PBXGroup; | ||
children = ( | ||
954FC9F420AC08D70017B273 /* SDK */, | ||
954FC90B20AADA700017B273 /* RNCloudPayments.m */, | ||
954FC90A20AADA700017B273 /* RNCloudPayments.h */, | ||
954FC90820AADA700017B273 /* Products */, | ||
); | ||
sourceTree = "<group>"; | ||
}; | ||
954FC90820AADA700017B273 /* Products */ = { | ||
isa = PBXGroup; | ||
children = ( | ||
954FC90720AADA700017B273 /* libRNCloudPayments.a */, | ||
); | ||
name = Products; | ||
sourceTree = "<group>"; | ||
}; | ||
954FC9F420AC08D70017B273 /* SDK */ = { | ||
isa = PBXGroup; | ||
children = ( | ||
954FC9F820AC08E60017B273 /* Card.h */, | ||
954FC9F620AC08E60017B273 /* Card.m */, | ||
954FC9F520AC08E60017B273 /* NSDataENBase64.h */, | ||
954FC9F720AC08E60017B273 /* NSDataENBase64.m */, | ||
); | ||
path = SDK; | ||
sourceTree = "<group>"; | ||
}; | ||
/* End PBXGroup section */ | ||
|
||
/* Begin PBXNativeTarget section */ | ||
954FC90620AADA700017B273 /* RNCloudPayments */ = { | ||
isa = PBXNativeTarget; | ||
buildConfigurationList = 954FC91020AADA700017B273 /* Build configuration list for PBXNativeTarget "RNCloudPayments" */; | ||
buildPhases = ( | ||
954FC90320AADA700017B273 /* Sources */, | ||
954FC90420AADA700017B273 /* Frameworks */, | ||
95E3C63020ADAE9D0098BA8E /* CopyFiles */, | ||
); | ||
buildRules = ( | ||
); | ||
dependencies = ( | ||
); | ||
name = RNCloudPayments; | ||
productName = RNCloudPayments; | ||
productReference = 954FC90720AADA700017B273 /* libRNCloudPayments.a */; | ||
productType = "com.apple.product-type.library.static"; | ||
}; | ||
/* End PBXNativeTarget section */ | ||
|
||
/* Begin PBXProject section */ | ||
954FC8FF20AADA700017B273 /* Project object */ = { | ||
isa = PBXProject; | ||
attributes = { | ||
LastUpgradeCheck = 0930; | ||
TargetAttributes = { | ||
954FC90620AADA700017B273 = { | ||
CreatedOnToolsVersion = 9.3; | ||
}; | ||
}; | ||
}; | ||
buildConfigurationList = 954FC90220AADA700017B273 /* Build configuration list for PBXProject "RNCloudPayments" */; | ||
compatibilityVersion = "Xcode 9.3"; | ||
developmentRegion = en; | ||
hasScannedForEncodings = 0; | ||
knownRegions = ( | ||
en, | ||
); | ||
mainGroup = 954FC8FE20AADA700017B273; | ||
productRefGroup = 954FC90820AADA700017B273 /* Products */; | ||
projectDirPath = ""; | ||
projectRoot = ""; | ||
targets = ( | ||
954FC90620AADA700017B273 /* RNCloudPayments */, | ||
); | ||
}; | ||
/* End PBXProject section */ | ||
|
||
/* Begin PBXSourcesBuildPhase section */ | ||
954FC90320AADA700017B273 /* Sources */ = { | ||
isa = PBXSourcesBuildPhase; | ||
buildActionMask = 2147483647; | ||
files = ( | ||
954FC90C20AADA700017B273 /* RNCloudPayments.m in Sources */, | ||
954FC9F920AC08E60017B273 /* Card.m in Sources */, | ||
954FC9FA20AC08E60017B273 /* NSDataENBase64.m in Sources */, | ||
); | ||
runOnlyForDeploymentPostprocessing = 0; | ||
}; | ||
/* End PBXSourcesBuildPhase section */ | ||
|
||
/* Begin XCBuildConfiguration section */ | ||
954FC90E20AADA700017B273 /* Debug */ = { | ||
isa = XCBuildConfiguration; | ||
buildSettings = { | ||
ALWAYS_SEARCH_USER_PATHS = NO; | ||
CLANG_ANALYZER_NONNULL = YES; | ||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; | ||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; | ||
CLANG_CXX_LIBRARY = "libc++"; | ||
CLANG_ENABLE_MODULES = YES; | ||
CLANG_ENABLE_OBJC_ARC = YES; | ||
CLANG_ENABLE_OBJC_WEAK = YES; | ||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; | ||
CLANG_WARN_BOOL_CONVERSION = YES; | ||
CLANG_WARN_COMMA = YES; | ||
CLANG_WARN_CONSTANT_CONVERSION = YES; | ||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; | ||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; | ||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES; | ||
CLANG_WARN_EMPTY_BODY = YES; | ||
CLANG_WARN_ENUM_CONVERSION = YES; | ||
CLANG_WARN_INFINITE_RECURSION = YES; | ||
CLANG_WARN_INT_CONVERSION = YES; | ||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; | ||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; | ||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; | ||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; | ||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; | ||
CLANG_WARN_STRICT_PROTOTYPES = YES; | ||
CLANG_WARN_SUSPICIOUS_MOVE = YES; | ||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; | ||
CLANG_WARN_UNREACHABLE_CODE = YES; | ||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; | ||
CODE_SIGN_IDENTITY = "iPhone Developer"; | ||
COPY_PHASE_STRIP = NO; | ||
DEBUG_INFORMATION_FORMAT = dwarf; | ||
ENABLE_STRICT_OBJC_MSGSEND = YES; | ||
ENABLE_TESTABILITY = YES; | ||
GCC_C_LANGUAGE_STANDARD = gnu11; | ||
GCC_DYNAMIC_NO_PIC = NO; | ||
GCC_NO_COMMON_BLOCKS = YES; | ||
GCC_OPTIMIZATION_LEVEL = 0; | ||
GCC_PREPROCESSOR_DEFINITIONS = ( | ||
"DEBUG=1", | ||
"$(inherited)", | ||
); | ||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES; | ||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; | ||
GCC_WARN_UNDECLARED_SELECTOR = YES; | ||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; | ||
GCC_WARN_UNUSED_FUNCTION = YES; | ||
GCC_WARN_UNUSED_VARIABLE = YES; | ||
IPHONEOS_DEPLOYMENT_TARGET = 11.3; | ||
MTL_ENABLE_DEBUG_INFO = YES; | ||
ONLY_ACTIVE_ARCH = YES; | ||
SDKROOT = iphoneos; | ||
}; | ||
name = Debug; | ||
}; | ||
954FC90F20AADA700017B273 /* Release */ = { | ||
isa = XCBuildConfiguration; | ||
buildSettings = { | ||
ALWAYS_SEARCH_USER_PATHS = NO; | ||
CLANG_ANALYZER_NONNULL = YES; | ||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; | ||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; | ||
CLANG_CXX_LIBRARY = "libc++"; | ||
CLANG_ENABLE_MODULES = YES; | ||
CLANG_ENABLE_OBJC_ARC = YES; | ||
CLANG_ENABLE_OBJC_WEAK = YES; | ||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; | ||
CLANG_WARN_BOOL_CONVERSION = YES; | ||
CLANG_WARN_COMMA = YES; | ||
CLANG_WARN_CONSTANT_CONVERSION = YES; | ||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; | ||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; | ||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES; | ||
CLANG_WARN_EMPTY_BODY = YES; | ||
CLANG_WARN_ENUM_CONVERSION = YES; | ||
CLANG_WARN_INFINITE_RECURSION = YES; | ||
CLANG_WARN_INT_CONVERSION = YES; | ||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; | ||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; | ||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; | ||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; | ||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; | ||
CLANG_WARN_STRICT_PROTOTYPES = YES; | ||
CLANG_WARN_SUSPICIOUS_MOVE = YES; | ||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; | ||
CLANG_WARN_UNREACHABLE_CODE = YES; | ||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; | ||
CODE_SIGN_IDENTITY = "iPhone Developer"; | ||
COPY_PHASE_STRIP = NO; | ||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; | ||
ENABLE_NS_ASSERTIONS = NO; | ||
ENABLE_STRICT_OBJC_MSGSEND = YES; | ||
GCC_C_LANGUAGE_STANDARD = gnu11; | ||
GCC_NO_COMMON_BLOCKS = YES; | ||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES; | ||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; | ||
GCC_WARN_UNDECLARED_SELECTOR = YES; | ||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; | ||
GCC_WARN_UNUSED_FUNCTION = YES; | ||
GCC_WARN_UNUSED_VARIABLE = YES; | ||
IPHONEOS_DEPLOYMENT_TARGET = 11.3; | ||
MTL_ENABLE_DEBUG_INFO = NO; | ||
SDKROOT = iphoneos; | ||
VALIDATE_PRODUCT = YES; | ||
}; | ||
name = Release; | ||
}; | ||
954FC91120AADA700017B273 /* Debug */ = { | ||
isa = XCBuildConfiguration; | ||
buildSettings = { | ||
CODE_SIGN_STYLE = Automatic; | ||
OTHER_LDFLAGS = "-ObjC"; | ||
PRODUCT_NAME = "$(TARGET_NAME)"; | ||
SKIP_INSTALL = YES; | ||
TARGETED_DEVICE_FAMILY = "1,2"; | ||
}; | ||
name = Debug; | ||
}; | ||
954FC91220AADA700017B273 /* Release */ = { | ||
isa = XCBuildConfiguration; | ||
buildSettings = { | ||
CODE_SIGN_STYLE = Automatic; | ||
OTHER_LDFLAGS = "-ObjC"; | ||
PRODUCT_NAME = "$(TARGET_NAME)"; | ||
SKIP_INSTALL = YES; | ||
TARGETED_DEVICE_FAMILY = "1,2"; | ||
}; | ||
name = Release; | ||
}; | ||
/* End XCBuildConfiguration section */ | ||
|
||
/* Begin XCConfigurationList section */ | ||
954FC90220AADA700017B273 /* Build configuration list for PBXProject "RNCloudPayments" */ = { | ||
isa = XCConfigurationList; | ||
buildConfigurations = ( | ||
954FC90E20AADA700017B273 /* Debug */, | ||
954FC90F20AADA700017B273 /* Release */, | ||
); | ||
defaultConfigurationIsVisible = 0; | ||
defaultConfigurationName = Release; | ||
}; | ||
954FC91020AADA700017B273 /* Build configuration list for PBXNativeTarget "RNCloudPayments" */ = { | ||
isa = XCConfigurationList; | ||
buildConfigurations = ( | ||
954FC91120AADA700017B273 /* Debug */, | ||
954FC91220AADA700017B273 /* Release */, | ||
); | ||
defaultConfigurationIsVisible = 0; | ||
defaultConfigurationName = Release; | ||
}; | ||
/* End XCConfigurationList section */ | ||
}; | ||
rootObject = 954FC8FF20AADA700017B273 /* Project object */; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#import <Foundation/Foundation.h> | ||
|
||
typedef enum { | ||
Unknown, | ||
Visa, | ||
MasterCard, | ||
Maestro, | ||
Mir, | ||
JCB | ||
} CardType; | ||
|
||
@interface Card : NSObject { | ||
NSMutableArray *keyRefs; | ||
} | ||
|
||
+(BOOL) isCardNumberValid: (NSString *) cardNumberString; | ||
|
||
/** | ||
* Create cryptogram | ||
* cardNumberString valid card number stirng | ||
* expDateString string in format YYMM | ||
* CVVString 3-digit number | ||
* storePublicID public_id of store | ||
*/ | ||
-(NSString *) makeCardCryptogramPacket: (NSString *) cardNumberString andExpDate: (NSString *) expDateString andCVV: (NSString *) CVVString andMerchantPublicID: (NSString *) merchantPublicIDString; | ||
|
||
+(CardType) cardTypeFromCardNumber:(NSString *)cardNumberString; | ||
+(NSString *) cardTypeToString:(CardType)cardType; | ||
@end | ||
|
Oops, something went wrong.