diff --git a/Example/Podfile b/Example/Podfile old mode 100644 new mode 100755 diff --git a/Example/Podfile.lock b/Example/Podfile.lock new file mode 100644 index 0000000..3dd79bc --- /dev/null +++ b/Example/Podfile.lock @@ -0,0 +1,16 @@ +PODS: + - RXPiOS (1.2.0) + +DEPENDENCIES: + - RXPiOS (from `../`) + +EXTERNAL SOURCES: + RXPiOS: + :path: ../ + +SPEC CHECKSUMS: + RXPiOS: 32a1cd1ede45fad554912bcae2ddf470ad3e8e02 + +PODFILE CHECKSUM: 52c366f98357bafca21816643cc3089ddafc46d1 + +COCOAPODS: 1.2.1 diff --git a/Example/Pods/Local Podspecs/RXPiOS.podspec.json b/Example/Pods/Local Podspecs/RXPiOS.podspec.json old mode 100644 new mode 100755 index cdfe933..bbe964f --- a/Example/Pods/Local Podspecs/RXPiOS.podspec.json +++ b/Example/Pods/Local Podspecs/RXPiOS.podspec.json @@ -1,6 +1,6 @@ { "name": "RXPiOS", - "version": "1.1.0", + "version": "1.2.0", "summary": "The official Realex Payments iOS SDK for HPP and Remote API.", "homepage": "https://developer.realexpayments.com", "license": "MIT", @@ -10,7 +10,7 @@ }, "source": { "git": "https://github.com/realexpayments/rxp-ios.git", - "tag": "1.1.0" + "tag": "1.2.0" }, "platforms": { "ios": "8.0" diff --git a/Example/Pods/Manifest.lock b/Example/Pods/Manifest.lock new file mode 100644 index 0000000..3dd79bc --- /dev/null +++ b/Example/Pods/Manifest.lock @@ -0,0 +1,16 @@ +PODS: + - RXPiOS (1.2.0) + +DEPENDENCIES: + - RXPiOS (from `../`) + +EXTERNAL SOURCES: + RXPiOS: + :path: ../ + +SPEC CHECKSUMS: + RXPiOS: 32a1cd1ede45fad554912bcae2ddf470ad3e8e02 + +PODFILE CHECKSUM: 52c366f98357bafca21816643cc3089ddafc46d1 + +COCOAPODS: 1.2.1 diff --git a/Example/Pods/Pods.xcodeproj/project.pbxproj b/Example/Pods/Pods.xcodeproj/project.pbxproj old mode 100644 new mode 100755 diff --git a/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/RXPiOS.xcscheme b/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/RXPiOS.xcscheme old mode 100644 new mode 100755 index ba93429..c1b8094 --- a/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/RXPiOS.xcscheme +++ b/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/RXPiOS.xcscheme @@ -1,36 +1,39 @@ + buildForArchiving = "YES" + buildForAnalyzing = "YES"> + BuildableIdentifier = "primary" + BlueprintIdentifier = "7FA4F02FCB3089D0D2120D4DF5202AE3" + BuildableName = "RXPiOS.framework" + BlueprintName = "RXPiOS" + ReferencedContainer = "container:Pods.xcodeproj"> + shouldUseLaunchSchemeArgsEnv = "YES"> + + + + + + + debugDocumentVersioning = "YES"> diff --git a/Example/Pods/Target Support Files/RXPiOS/Info.plist b/Example/Pods/Target Support Files/RXPiOS/Info.plist index 21a30b4..2a9158a 100644 --- a/Example/Pods/Target Support Files/RXPiOS/Info.plist +++ b/Example/Pods/Target Support Files/RXPiOS/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.1.0 + 1.2.0 CFBundleSignature ???? CFBundleVersion diff --git a/Example/RXPiOS.xcodeproj/project.pbxproj b/Example/RXPiOS.xcodeproj/project.pbxproj old mode 100644 new mode 100755 index c32687e..1c07f63 --- a/Example/RXPiOS.xcodeproj/project.pbxproj +++ b/Example/RXPiOS.xcodeproj/project.pbxproj @@ -212,7 +212,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0720; - LastUpgradeCheck = 0630; + LastUpgradeCheck = 0830; ORGANIZATIONNAME = CocoaPods; TargetAttributes = { 607FACCF1AFB9204008FA782 = { @@ -419,14 +419,17 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; @@ -442,7 +445,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.1; + IPHONEOS_DEPLOYMENT_TARGET = 10.3; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -463,8 +466,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -480,9 +485,10 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.1; + IPHONEOS_DEPLOYMENT_TARGET = 10.3; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; VALIDATE_PRODUCT = YES; }; name = Release; @@ -492,14 +498,12 @@ baseConfigurationReference = 4F0CB0B97766810708DF3262 /* Pods-RXPiOS_Example.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/build/Debug-iphoneos", - ); + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = RXPiOS/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; MODULE_NAME = ExampleApp; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 3.0; }; @@ -518,6 +522,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; MODULE_NAME = ExampleApp; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 3.0; }; @@ -528,16 +533,14 @@ baseConfigurationReference = 86F8034E5ADF876BA55456BE /* Pods-RXPiOS_Tests.debug.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; - FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", - "$(inherited)", - ); + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", ); INFOPLIST_FILE = Tests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 3.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/RXPiOS_Example.app/RXPiOS_Example"; @@ -555,6 +558,7 @@ ); INFOPLIST_FILE = Tests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 3.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/RXPiOS_Example.app/RXPiOS_Example"; diff --git a/Example/RXPiOS.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Example/RXPiOS.xcodeproj/project.xcworkspace/contents.xcworkspacedata old mode 100644 new mode 100755 diff --git a/Example/RXPiOS.xcodeproj/xcshareddata/xcschemes/RXPiOS-Example.xcscheme b/Example/RXPiOS.xcodeproj/xcshareddata/xcschemes/RXPiOS-Example.xcscheme old mode 100644 new mode 100755 index 98a4e9a..0e5abe1 --- a/Example/RXPiOS.xcodeproj/xcshareddata/xcschemes/RXPiOS-Example.xcscheme +++ b/Example/RXPiOS.xcodeproj/xcshareddata/xcschemes/RXPiOS-Example.xcscheme @@ -1,6 +1,6 @@ - + + - + - + + + + + + + + + + + + + + + + + + + @@ -21,24 +39,66 @@ - + + + + + + + + + + + - + - - + + + + + + + + + + + + + + + + + + + diff --git a/Example/RXPiOS/Images.xcassets/AppIcon.appiconset/Contents.json b/Example/RXPiOS/Images.xcassets/AppIcon.appiconset/Contents.json old mode 100644 new mode 100755 diff --git a/Example/RXPiOS/Info.plist b/Example/RXPiOS/Info.plist old mode 100644 new mode 100755 index 2960c1d..eb18faa --- a/Example/RXPiOS/Info.plist +++ b/Example/RXPiOS/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/Example/RXPiOS/ViewController.swift b/Example/RXPiOS/ViewController.swift old mode 100644 new mode 100755 index 9ca689d..6f3c10c --- a/Example/RXPiOS/ViewController.swift +++ b/Example/RXPiOS/ViewController.swift @@ -8,8 +8,14 @@ import RXPiOS class ViewController: UIViewController, HPPManagerDelegate { + @IBOutlet weak var result_textView: UITextView! + + @IBOutlet weak var payButton: UIButton! + @IBOutlet weak var activityIndicator: UIActivityIndicatorView! override func viewDidLoad() { super.viewDidLoad() + self.activityIndicator.isHidden = true + // Do any additional setup after loading the view, typically from a nib. } @@ -22,11 +28,15 @@ class ViewController: UIViewController, HPPManagerDelegate { @IBAction func payButtonAction(_ sender: AnyObject) { let hppManager = HPPManager() - - hppManager.HPPRequestProducerURL = URL(string: "https://myserver.com/hppRequestProducer") + hppManager.isEncoded = true + hppManager.HPPRequestProducerURL = URL(string: "https://myserver.com/hppRequestProducer") hppManager.HPPURL = URL(string: "https://pay.sandbox.realexpayments.com/pay") - hppManager.HPPResponseConsumerURL = URL(string: "https://myserver.com/hppResponseConsumer") + hppManager.HPPResponseConsumerURL = URL(string: "https://myserver.com/hppResponseConsumer") + self.activityIndicator.isHidden = false + activityIndicator.startAnimating() + self.payButton.isEnabled = false + activityIndicator.hidesWhenStopped = true hppManager.delegate = self hppManager.presentViewInViewController(self) } @@ -37,17 +47,31 @@ class ViewController: UIViewController, HPPManagerDelegate { func HPPManagerCompletedWithResult(_ result: Dictionary ) { // success print(NSString(format: "%@", result) as String) - } + //self.result_text.text = "helo how are you" + DispatchQueue.main.async() { + self.DisplayResult(result: NSString(format: "%@", result) as String); + } + } func HPPManagerFailedWithError(_ error: NSError?) { // error if let hppError = error { print(hppError.localizedDescription) + self.DisplayResult(result: hppError.localizedDescription) } } func HPPManagerCancelled() { // cancelled print("Cancelled by user.") + self.DisplayResult(result: "Cancelled by User") } + + func DisplayResult(result : String) + { + self.result_textView.text = NSString(format: "%@", result) as String + self.result_textView.textAlignment = .left + self.activityIndicator.stopAnimating(); + self.payButton.isEnabled = true; + } } diff --git a/Example/Tests/Info.plist b/Example/Tests/Info.plist old mode 100644 new mode 100755 index ee0a311..ba72822 --- a/Example/Tests/Info.plist +++ b/Example/Tests/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - org.cocoapods.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/Example/Tests/Tests.swift b/Example/Tests/Tests.swift old mode 100644 new mode 100755 diff --git a/Pod/Classes/.gitkeep b/Pod/Classes/.gitkeep old mode 100644 new mode 100755 diff --git a/Pod/Classes/RealexComponent/Dictionary+URLDictionary.swift b/Pod/Classes/RealexComponent/Dictionary+URLDictionary.swift old mode 100644 new mode 100755 diff --git a/Pod/Classes/RealexComponent/HPPManager.swift b/Pod/Classes/RealexComponent/HPPManager.swift old mode 100644 new mode 100755 index d8640af..2f7e72a --- a/Pod/Classes/RealexComponent/HPPManager.swift +++ b/Pod/Classes/RealexComponent/HPPManager.swift @@ -171,9 +171,16 @@ open class HPPManager: NSObject, UIWebViewDelegate, HPPViewControllerDelegate { open var validateCardOnly:String! = "" /** - * Transaction level configuration to enable/disable a DCC request. (Only if the merchant is configured). + * Used to check HppRequest base64 encoding. + If set to true - the iOS library should decode the Base64 encoded values in the HPP request JSON + + If set to false - the iOS library should just leave the values alone */ - open var dccEnable:String! = "" + open var isEncoded:Bool! = false + /** + * Transaction level configuration to enable/disable a DCC request. (Only if the merchant is configured). + */ + open var dccEnable:String! = "" /** * Supplementary data to be sent to Realex Payments. This will be returned in the HPP response. @@ -230,14 +237,14 @@ open class HPPManager: NSObject, UIWebViewDelegate, HPPViewControllerDelegate { - returns: The data encoded HTML string representation of the paramaters and values. */ fileprivate func httpBodyWithJSON(_ json: NSDictionary) -> Data { + print(json) var parameters: Dictionary! = [:] for (key, value) in json { parameters[key as! String] = value as? String } - - parameters["HPP_TEMPLATE_TYPE"] = "LIGHTBOX" - parameters["HPP_ORIGIN"] = self.HPPRequestProducerURL.scheme! + "://" + self.HPPRequestProducerURL.host! + parameters["HPP_VERSION"] = "2" + parameters["HPP_POST_RESPONSE"] = self.HPPRequestProducerURL.scheme! + "://" + self.HPPRequestProducerURL.host! let parameterString = parameters.stringFromHttpParameters() return parameterString.data(using: String.Encoding.utf8)!; @@ -306,7 +313,7 @@ open class HPPManager: NSObject, UIWebViewDelegate, HPPViewControllerDelegate { if self.language != "" { parameters["HPP_LANG"] = self.language } - if self.cardPaymentButtonText != "" { + if self.cardPaymentButtonText != "" { parameters["CARD_PAYMENT_BUTTON"] = self.cardPaymentButtonText } if self.cardStorageEnable != "" { @@ -330,6 +337,7 @@ open class HPPManager: NSObject, UIWebViewDelegate, HPPViewControllerDelegate { if self.dccEnable != "" { parameters["DCC_ENABLE"] = self.dccEnable } + if self.supplementaryData != [:] { for (key,value) in self.supplementaryData { @@ -350,8 +358,9 @@ open class HPPManager: NSObject, UIWebViewDelegate, HPPViewControllerDelegate { UIApplication.shared.isNetworkActivityIndicatorVisible = true let cachePolicy = NSURLRequest.CachePolicy.reloadIgnoringLocalCacheData - let request = NSMutableURLRequest(url: self.HPPRequestProducerURL, cachePolicy: cachePolicy, timeoutInterval: 30.0) - request.httpMethod = "POST" + let request: NSMutableURLRequest = NSMutableURLRequest(url: self.HPPRequestProducerURL, cachePolicy: cachePolicy, timeoutInterval: 30.0) + + request.httpMethod = "POST" request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type") request.setValue("*/*", forHTTPHeaderField: "Accept") request.httpBody = self.getParametersString().data(using: String.Encoding.utf8) @@ -363,6 +372,12 @@ open class HPPManager: NSObject, UIWebViewDelegate, HPPViewControllerDelegate { if let receivedData = data { // success self.HPPRequest = try JSONSerialization.jsonObject(with: receivedData, options: []) as! NSDictionary + // let hppMutableRequest = NSMutableDictionary.init(dictionary: self.HPPRequest) + if (self.isEncoded == true) + { + self.HPPRequest = self.HPPRequest.DecodeAllValues() + } + self.getPaymentForm() } else { @@ -469,7 +484,8 @@ open class HPPManager: NSObject, UIWebViewDelegate, HPPViewControllerDelegate { - parameter error: The error which occured. */ - func HPPViewControllerFailedWithError(_ error: Error?) { + + private func HPPViewControllerFailedWithError(_ error: Error?) { self.delegate?.HPPManagerFailedWithError!(error as NSError?) self.hppViewController.dismiss(animated: true, completion: nil) } @@ -482,3 +498,42 @@ open class HPPManager: NSObject, UIWebViewDelegate, HPPViewControllerDelegate { } } +extension NSDictionary { + //: ### Base64 encoding a string + + func DecodeAllValues() -> NSMutableDictionary + { + let dic: NSMutableDictionary! = NSMutableDictionary.init(capacity: self.count) + for value in self { + if (value.value as? String) != "" + { + dic[value.key] = (value.value as?String)?.base64Decoded() + + } + else{ + dic[value.key] = value.value + + } + } + + return dic + } + +} +extension String +{ + func base64Encoded() -> String? { + if let data = self.data(using: .utf8) { + return data.base64EncodedString() + } + return nil + } + + //: ### Base64 decoding a string + func base64Decoded() -> String? { + if let data = Data(base64Encoded: self) { + return String(data: data, encoding: .utf8) + } + return nil + } +} diff --git a/Pod/Classes/RealexComponent/HPPViewController.swift b/Pod/Classes/RealexComponent/HPPViewController.swift old mode 100644 new mode 100755 diff --git a/Pod/Classes/RealexComponent/String+URLString.swift b/Pod/Classes/RealexComponent/String+URLString.swift old mode 100644 new mode 100755 diff --git a/Pod/Classes/RealexRemote/RealexRemote.swift b/Pod/Classes/RealexRemote/RealexRemote.swift old mode 100644 new mode 100755 diff --git a/RXPiOS.podspec b/RXPiOS.podspec old mode 100644 new mode 100755