├── .gitignore ├── .swift-version ├── LICENSE ├── PayDock.podspec ├── PayDock.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ ├── IDEWorkspaceChecks.plist │ │ └── WorkspaceSettings.xcsettings │ └── xcuserdata │ │ └── amin.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── shurex.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── PayDock.xcscheme │ └── xcschememanagement.plist ├── PayDock ├── .jazzy.yaml ├── Assets.xcassets │ ├── Contents.json │ ├── camera.imageset │ │ ├── Contents.json │ │ └── camera.png │ ├── icBank.imageset │ │ ├── Contents.json │ │ └── icBank.png │ ├── icTick.imageset │ │ ├── Contents.json │ │ └── icTick.png │ ├── ic_card.imageset │ │ ├── Contents.json │ │ └── ic_card.png │ ├── icamex.imageset │ │ ├── Contents.json │ │ └── icamex.png │ ├── iccup.imageset │ │ ├── Contents.json │ │ └── iccup.png │ ├── icdefault.imageset │ │ ├── Contents.json │ │ └── icdefault.png │ ├── icdiners.imageset │ │ ├── Contents.json │ │ └── icdiners.png │ ├── icdinersclub.imageset │ │ ├── Contents.json │ │ └── icdinersclub.png │ ├── icmastercard.imageset │ │ ├── Contents.json │ │ └── icmastercard.png │ └── icvisa.imageset │ │ ├── Contents.json │ │ └── icvisa.png ├── BSBFormViewController.swift ├── CardFormViewController.swift ├── CardType.swift ├── Checkout.swift ├── Constants.swift ├── ConstantsUi.swift ├── CustomCellTableViewCell.swift ├── Errors.swift ├── ExternalCheckout.swift ├── Info.plist ├── Info1.plist ├── Mapper │ └── Mapable.swift ├── Models │ ├── Address.swift │ ├── Charge │ │ └── Charge.swift │ ├── Customer │ │ └── Customer.swift │ ├── Parameters │ │ ├── ChargeRequest.swift │ │ ├── CustomerRequest.swift │ │ ├── ExternalCheckoutRequest.swift │ │ ├── ListParameters.swift │ │ ├── Parameterable.swift │ │ ├── SubscriptionRequest.swift │ │ └── TokenRequest.swift │ ├── Payment Sources │ │ ├── BSB.swift │ │ ├── BankAccount.swift │ │ ├── Card.swift │ │ └── Payment Source.swift │ ├── Subscription │ │ ├── Schedule.swift │ │ └── Subscription.swift │ └── Transaction │ │ ├── Refund.swift │ │ ├── Sale.swift │ │ └── Transaction.swift ├── Networking │ ├── PayDockNetwork.swift │ └── PayDockSession.swift ├── PayDock.h ├── PayDock.swift ├── Services │ ├── ChargeServices.swift │ ├── CustomerServices.swift │ ├── ExternalCheckoutServices.swift │ ├── SubscriptionServices.swift │ └── TokenServices.swift ├── VaultViewController.swift └── cardForm.storyboard ├── PayDockTests ├── ChargeIntergrationTests.swift ├── CustomerIntegrationTests.swift ├── Demo_app_swift │ ├── Demo_app_swift-Bridging-Header.h │ ├── Demo_app_swift │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ │ └── Contents.json │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Main.storyboard │ │ ├── Info.plist │ │ └── ViewController.swift │ └── Settings.bundle │ │ ├── Root.plist │ │ ├── acknowledgments.plist │ │ └── en.lproj │ │ └── Root.strings ├── ExternalCheckoutTests.swift ├── Info.plist ├── ModelMapTests.swift ├── PayDockSessionTests.swift ├── SubscriptionIntegrationTest.swift ├── TokenIntegrationTest.swift ├── bassentStoryboard.storyboard ├── cardView.xib ├── chargeAdd.json ├── chargeInfo.json ├── chargeList.json ├── customerAdd.json ├── customerItem.json ├── customerList.json ├── externalCheckoutAdd.json ├── subscriptionAdd.json ├── subscriptionItem.json ├── subscriptionList.json └── subscriptionUpdate.json ├── README.md └── docs ├── Classes.html ├── Classes └── PayDock.html ├── Enums.html ├── Enums ├── Errors.html └── PaymentSource.html ├── Getting Started.md ├── Guides.html ├── Protocols.html ├── Protocols ├── Parameterable.html └── PayDockNetwork.html ├── Structs.html ├── Structs ├── Address.html ├── Charge.html ├── ChargeRequest.html ├── Customer.html ├── CustomerRequest.html ├── ListParameters.html ├── Schedule.html ├── Subscription.html ├── SubscriptionRequest.html └── TokenRequest.html ├── css ├── highlight.css └── jazzy.css ├── docsets ├── PayDock.docset │ └── Contents │ │ ├── Info.plist │ │ └── Resources │ │ ├── Documents │ │ ├── Classes.html │ │ ├── Classes │ │ │ └── PayDock.html │ │ ├── Enums.html │ │ ├── Enums │ │ │ ├── Errors.html │ │ │ └── PaymentSource.html │ │ ├── Getting Started.md │ │ ├── Guides.html │ │ ├── Protocols.html │ │ ├── Protocols │ │ │ ├── Parameterable.html │ │ │ └── PayDockNetwork.html │ │ ├── Structs.html │ │ ├── Structs │ │ │ ├── Address.html │ │ │ ├── Charge.html │ │ │ ├── ChargeRequest.html │ │ │ ├── Customer.html │ │ │ ├── CustomerRequest.html │ │ │ ├── ListParameters.html │ │ │ ├── Schedule.html │ │ │ ├── Subscription.html │ │ │ ├── SubscriptionRequest.html │ │ │ └── TokenRequest.html │ │ ├── css │ │ │ ├── highlight.css │ │ │ └── jazzy.css │ │ ├── getting-started.html │ │ ├── img │ │ │ ├── carat.png │ │ │ ├── dash.png │ │ │ └── gh.png │ │ ├── index.html │ │ ├── js │ │ │ ├── jazzy.js │ │ │ └── jquery.min.js │ │ └── undocumented.json │ │ └── docSet.dsidx └── PayDock.tgz ├── getting-started.html ├── img ├── carat.png ├── dash.png └── gh.png ├── index.html ├── js ├── jazzy.js └── jquery.min.js └── undocumented.json /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | ## Playgrounds 32 | timeline.xctimeline 33 | playground.xcworkspace 34 | 35 | # Swift Package Manager 36 | # 37 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 38 | # Packages/ 39 | # Package.pins 40 | # Package.resolved 41 | .build/ 42 | 43 | # CocoaPods 44 | # 45 | # We recommend against adding the Pods directory to your .gitignore. However 46 | # you should judge for yourself, the pros and cons are mentioned at: 47 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 48 | # 49 | # Pods/ 50 | 51 | # Carthage 52 | # 53 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 54 | # Carthage/Checkouts 55 | 56 | Carthage/Build 57 | 58 | # fastlane 59 | # 60 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 61 | # screenshots whenever they are needed. 62 | # For more information about the recommended setup visit: 63 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 64 | 65 | fastlane/report.xml 66 | fastlane/Preview.html 67 | fastlane/screenshots 68 | fastlane/test_output 69 | 70 | -------------------------------------------------------------------------------- /.swift-version: -------------------------------------------------------------------------------- 1 | 3.2 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 PayDockDev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /PayDock.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'PayDock' 3 | s.platform = :ios 4 | s.ios.deployment_target = '9.0' 5 | s.requires_arc = true 6 | s.module_name = 'PayDock' 7 | s.version = '1.1.1' 8 | 9 | s.summary = 'PayDock is an open-source SDK for iOS and a solution for collecting and handling payment sources in secure way through PayDock.' 10 | s.description = 'PayDock is a smart payments platform connecting to your e-commerce or online payments solution/gateway. We enable you to add multiple payment gateways instantly, access new payment methods and manage all payments data from one place.' 11 | s.homepage = 'https://paydock.com' 12 | s.license = 'MIT' 13 | s.author = 'PayDock' 14 | s.source = { :git => 'https://github.com/PayDockDev/paydock_ios_sdk.git',:tag => s.version.to_s } 15 | s.source_files = 'PayDock/**/*.{h,m}', 'PayDock/**/*.swift' 16 | s.resources = 'PayDock/Assets.xcassets', 'PayDock/**/*.storyboard', 'PayDock/Info1.plist' 17 | s.resource_bundles = { 18 | 'PayDock' => [ 'PayDock/**/*.{storyboard,xcassets,json,imageset,png,plist}' ] 19 | } 20 | end 21 | -------------------------------------------------------------------------------- /PayDock.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /PayDock.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /PayDock.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | BuildSystemType 6 | Original 7 | 8 | 9 | -------------------------------------------------------------------------------- /PayDock.xcodeproj/project.xcworkspace/xcuserdata/amin.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PayDock/paydock_ios_sdk/29052dd731ddc0370da9f0da10a6665bf82d1dff/PayDock.xcodeproj/project.xcworkspace/xcuserdata/amin.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /PayDock.xcodeproj/xcuserdata/shurex.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /PayDock.xcodeproj/xcuserdata/shurex.xcuserdatad/xcschemes/PayDock.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 53 | 54 | 64 | 65 | 71 | 72 | 73 | 74 | 75 | 76 | 82 | 83 | 89 | 90 | 91 | 92 | 94 | 95 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /PayDock.xcodeproj/xcuserdata/shurex.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | PayDock.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 8435D0711E9B49E200AE0BAA 16 | 17 | primary 18 | 19 | 20 | 8435D07A1E9B49E300AE0BAA 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /PayDock/.jazzy.yaml: -------------------------------------------------------------------------------- 1 | module: PayDock 2 | author: RoundTableApps 3 | min_acl: public 4 | hide_documentation_coverage: true 5 | skip_undocumented: true 6 | theme: fullwidth 7 | documentation: docs/*.md 8 | -------------------------------------------------------------------------------- /PayDock/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /PayDock/Assets.xcassets/camera.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "camera.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /PayDock/Assets.xcassets/camera.imageset/camera.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PayDock/paydock_ios_sdk/29052dd731ddc0370da9f0da10a6665bf82d1dff/PayDock/Assets.xcassets/camera.imageset/camera.png -------------------------------------------------------------------------------- /PayDock/Assets.xcassets/icBank.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "icBank.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /PayDock/Assets.xcassets/icBank.imageset/icBank.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PayDock/paydock_ios_sdk/29052dd731ddc0370da9f0da10a6665bf82d1dff/PayDock/Assets.xcassets/icBank.imageset/icBank.png -------------------------------------------------------------------------------- /PayDock/Assets.xcassets/icTick.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "icTick.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /PayDock/Assets.xcassets/icTick.imageset/icTick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PayDock/paydock_ios_sdk/29052dd731ddc0370da9f0da10a6665bf82d1dff/PayDock/Assets.xcassets/icTick.imageset/icTick.png -------------------------------------------------------------------------------- /PayDock/Assets.xcassets/ic_card.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "ic_card.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /PayDock/Assets.xcassets/ic_card.imageset/ic_card.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PayDock/paydock_ios_sdk/29052dd731ddc0370da9f0da10a6665bf82d1dff/PayDock/Assets.xcassets/ic_card.imageset/ic_card.png -------------------------------------------------------------------------------- /PayDock/Assets.xcassets/icamex.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "icamex.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /PayDock/Assets.xcassets/icamex.imageset/icamex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PayDock/paydock_ios_sdk/29052dd731ddc0370da9f0da10a6665bf82d1dff/PayDock/Assets.xcassets/icamex.imageset/icamex.png -------------------------------------------------------------------------------- /PayDock/Assets.xcassets/iccup.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "iccup.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /PayDock/Assets.xcassets/iccup.imageset/iccup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PayDock/paydock_ios_sdk/29052dd731ddc0370da9f0da10a6665bf82d1dff/PayDock/Assets.xcassets/iccup.imageset/iccup.png -------------------------------------------------------------------------------- /PayDock/Assets.xcassets/icdefault.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "icdefault.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /PayDock/Assets.xcassets/icdefault.imageset/icdefault.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PayDock/paydock_ios_sdk/29052dd731ddc0370da9f0da10a6665bf82d1dff/PayDock/Assets.xcassets/icdefault.imageset/icdefault.png -------------------------------------------------------------------------------- /PayDock/Assets.xcassets/icdiners.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "icdiners.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /PayDock/Assets.xcassets/icdiners.imageset/icdiners.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PayDock/paydock_ios_sdk/29052dd731ddc0370da9f0da10a6665bf82d1dff/PayDock/Assets.xcassets/icdiners.imageset/icdiners.png -------------------------------------------------------------------------------- /PayDock/Assets.xcassets/icdinersclub.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "icdinersclub.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /PayDock/Assets.xcassets/icdinersclub.imageset/icdinersclub.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PayDock/paydock_ios_sdk/29052dd731ddc0370da9f0da10a6665bf82d1dff/PayDock/Assets.xcassets/icdinersclub.imageset/icdinersclub.png -------------------------------------------------------------------------------- /PayDock/Assets.xcassets/icmastercard.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "icmastercard.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /PayDock/Assets.xcassets/icmastercard.imageset/icmastercard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PayDock/paydock_ios_sdk/29052dd731ddc0370da9f0da10a6665bf82d1dff/PayDock/Assets.xcassets/icmastercard.imageset/icmastercard.png -------------------------------------------------------------------------------- /PayDock/Assets.xcassets/icvisa.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "icvisa.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /PayDock/Assets.xcassets/icvisa.imageset/icvisa.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PayDock/paydock_ios_sdk/29052dd731ddc0370da9f0da10a6665bf82d1dff/PayDock/Assets.xcassets/icvisa.imageset/icvisa.png -------------------------------------------------------------------------------- /PayDock/CardType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CardType.swift 3 | // PayDock 4 | // 5 | // Created by Oleksandr Omelchenko on 07.11.17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class CardType: NSObject { 12 | var mCardScheme : String? 13 | var mImageResource : String? 14 | var mMinCardLength : Int? 15 | var mMaxCardLength : Int? 16 | init(cardScheme:String,imageResource:String,minCardLength:Int,maxCardlength:Int){ 17 | mCardScheme = cardScheme 18 | mImageResource = imageResource 19 | mMinCardLength = minCardLength 20 | mMaxCardLength = maxCardlength 21 | } 22 | override init(){ 23 | mCardScheme = "Default Card" 24 | mMinCardLength = 16 25 | mMaxCardLength = 16 26 | } 27 | static func getCreditCardType(creditCardNumber : String)-> CardType{ 28 | let regexVisa = "^4\\d*" 29 | let regexMaster = "^(222[1-9]|22[3-9]|2[3-6]|27[0-1]|2720|5[1-5])\\d*" 30 | let regexAMEX = "^3[47]\\d*" 31 | let regexDiners = "^(30[0-5]|309|36|3[8-9])\\d*" 32 | let regexCUP = "^62\\d*" 33 | 34 | let pattern = [regexVisa,regexMaster,regexAMEX,regexDiners,regexCUP] 35 | let cardName = ["Visa","MasterCard","AMEX","Diners Club" ,"China Union Pay"] 36 | let cardimg = ["icvisa","icmastercard","icamex","icdiners","iccup"] 37 | let cardMinLength = [16,16,15,14,16] 38 | let cardMaxLength = [16,16,15,19,19] 39 | var checKType = false 40 | 41 | for i in 0 ..< pattern.count{ 42 | do { 43 | let regex = try NSRegularExpression(pattern: pattern[i], 44 | options: .caseInsensitive) 45 | checKType = regex.matches(in: creditCardNumber, 46 | options: [], 47 | range: NSMakeRange(0, creditCardNumber.count)).count > 0 48 | 49 | } catch { 50 | checKType = false 51 | } 52 | if checKType == true{ 53 | return CardType(cardScheme: cardName[i], imageResource: cardimg[i], minCardLength: cardMinLength[i], maxCardlength: cardMaxLength[i]) 54 | } 55 | }//end for 56 | return CardType(cardScheme: "Default Card", imageResource: "icdefault", minCardLength: 16, maxCardlength: 16) 57 | } 58 | func isvalid(creditCardNumber : String)->Bool{ 59 | if creditCardNumber.count == 0 || creditCardNumber.count > mMaxCardLength! || creditCardNumber.count < mMinCardLength! { 60 | return false 61 | } 62 | return true 63 | } 64 | func greaterThanMax(creditCardNumber : String)->Bool{ 65 | if creditCardNumber.count > mMaxCardLength! { 66 | return true 67 | } 68 | return false 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /PayDock/Checkout.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Card.swift 3 | // PayDock 4 | // 5 | // Created by RTA on 19/4/17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | public struct Checkout: Parameterable, Mapable { 12 | public typealias Kind = Checkout 13 | /// card id 14 | public var id: String? 15 | /// Cardholder name (as on card) 16 | public var status: String? 17 | /// Cardholder name (as on card) 18 | public var type: String? 19 | /// Cardholder name (as on card) 20 | public var checkoutEmail: String? 21 | /// Cardholder name (as on card) 22 | public var checkoutHolder: String? 23 | /// Cardholder name (as on card) 24 | public var address: Address? 25 | /// Gateway ID 26 | public var gatewayId: String? 27 | public var customerId: String? 28 | public var gatewayType: String? 29 | public var gatewayMode: String? 30 | public var customerReference: String? 31 | /// ref Token 32 | public var refToken: String? 33 | /// Created Date 34 | public var createdAt: Date? 35 | /// Updated Date 36 | public var updatedAt: Date? 37 | // primary 38 | public var primary :Bool? 39 | public var rawJson: [String: Any]? 40 | 41 | 42 | init(json: Dictionary) throws { 43 | self.id = try? json.value(for: "_id") 44 | self.checkoutEmail = try? json.value(for: "checkout_email") 45 | self.checkoutHolder = try? json.value(for: "checkout_holder") 46 | self.type = try? json.value(for: "type") 47 | // self.status = try? json.value(for: "status") 48 | self.gatewayId = try? json.value(for: "gateway_id") 49 | self.customerId = try? json.value(for: "customer_id") 50 | self.gatewayType = try? json.value(for: "gateway_type") 51 | self.gatewayMode = try? json.value(for: "gateway_mode") 52 | self.primary = try? json.value(for: "primary") 53 | self.customerReference = try? json.value(for: "customer_reference") 54 | 55 | // self.refToken = try? json.value(for: "ref_token") 56 | // self.createdAt = try? json.value(for: "created_at") 57 | // self.updatedAt = try? json.value(for: "updated_at") 58 | // 59 | // self.address = try? Address(json: json) 60 | // self.rawJson = json 61 | 62 | } 63 | public func toDictionary() -> [String : Any] { 64 | var param: [String: Any] = ["type": "checkout"] 65 | address?.toDictionary().forEach { (key, value) in 66 | param[key] = value 67 | } 68 | param.appendNonNilable(key: "_id", item: id) 69 | param.appendNonNilable(key: "checkout_email", item: checkoutEmail) 70 | param.appendNonNilable(key: "checkout_holder", item: checkoutHolder) 71 | param.appendNonNilable(key: "type", item: type) 72 | param.appendNonNilable(key: "gateway_id", item: gatewayId) 73 | param.appendNonNilable(key: "customer_id", item: customerId) 74 | param.appendNonNilable(key: "gateway_type", item: gatewayType) 75 | param.appendNonNilable(key: "gateway_mode", item: gatewayMode) 76 | 77 | // param.appendNonNilable(key: "rawJson", item: rawJson) 78 | param.appendNonNilable(key: "primary", item: primary) 79 | param.appendNonNilable(key: "customer_reference", item: customerReference) 80 | return param 81 | } 82 | 83 | 84 | } 85 | -------------------------------------------------------------------------------- /PayDock/Constants.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Constants.swift 3 | // PayDock 4 | // 5 | // Created by Round Table Apps on 18/4/17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | 12 | /// constant values 13 | struct Constants { 14 | /// charge url 15 | static var charge = "v1/charges" 16 | 17 | /// subscriptino url 18 | static let subscription = "v1/subscriptions" 19 | 20 | /// token url 21 | static let token = "v1/payment_sources/tokens" 22 | 23 | /// customer url 24 | static let customers = "v1/customers" 25 | 26 | /// customer url 27 | static let paymentSources = "v1/customers/payment_sources" 28 | 29 | /// external checkout url 30 | static let externalCheckout = "v1/payment_sources/external_checkout" 31 | 32 | private init() { } 33 | } 34 | -------------------------------------------------------------------------------- /PayDock/ConstantsUi.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ConstantsUi.swift 3 | // PayDock 4 | // 5 | // Created by Oleksandr Omelchenko on 08.11.17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ConstantsUi { 12 | let cardNameIsRequired = "Card name is required" 13 | let cardNameIsInvalid = "Card name is invalid" 14 | let cardNumberIsRequired = "Card number is required" 15 | let cardNumberIsInvalid = "Card number is invalid" 16 | let expiryIsRequired = "Expiry is required" 17 | let expiryIsInvalid = "Expiry is invalid" 18 | let securityCodeInvalid = "Security code invalid" 19 | let securityCodeIsRequired = "Security Code is required" 20 | let accountNumberIsRequired = "Account number is required" 21 | let accountNumberIsInvalid = "Account number is invalid" 22 | let bSBNumberIsRequired = "BSB number is required" 23 | let bSBNumberIsInvalid = "BSB number is invalid" 24 | let bankAccountNameIsRequired = "Bank account name is required" 25 | let bankAccountNameIsInvalide = "Bank account name is invalid" 26 | } 27 | -------------------------------------------------------------------------------- /PayDock/CustomCellTableViewCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CustomCellTableViewCell.swift 3 | // PayDock 4 | // 5 | // Created by Oleksandr Omelchenko on 12.11.17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class CustomCellTableViewCell: UITableViewCell { 12 | 13 | @IBOutlet weak var primaryImg: UIImageView! 14 | 15 | @IBOutlet weak var typeImg: UIImageView! 16 | 17 | @IBOutlet weak var nameLabel: UILabel! 18 | 19 | @IBOutlet weak var numberLabel: UILabel! 20 | override func setSelected(_ selected: Bool, animated: Bool) { 21 | super.setSelected(selected, animated: animated) 22 | 23 | // Configure the view for the selected state 24 | } 25 | override func awakeFromNib() { 26 | super.awakeFromNib() 27 | // Initialization code 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /PayDock/Errors.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Errors.swift 3 | // PayDock 4 | // 5 | // Created by Round Table Apps on 15/4/17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /// PayDock Errors 12 | /// 13 | /// - urlInitFailed: errors when can not create URL 14 | /// - networkError: errors when URLSession fails 15 | /// - serverError: errors that server returns 16 | /// - parsingFailed: errors on mapping json to object 17 | /// - invalidJsonFormat: errors on parsing data to json 18 | public enum Errors: Error { 19 | case urlInitFailed(reason: urlInitFailedReason) 20 | case networkError(reason: networkErrorReason) 21 | case serverError(message: String, details: AnyObject?, status: Int) 22 | case parsingFailed 23 | case invalidJsonFormat 24 | 25 | var details: AnyObject? { 26 | switch self { 27 | case .serverError( _,let details, _): return details 28 | default: return nil 29 | } 30 | } 31 | var status: Int { 32 | switch self { 33 | case .serverError( _, _, let status): return status 34 | default: return 0 35 | } 36 | } 37 | var message: String? { 38 | switch self { 39 | case .serverError(let message, _, _): return message 40 | default: return nil 41 | } 42 | } 43 | } 44 | 45 | extension Errors: LocalizedError { 46 | public var errorDescription: String? { 47 | switch self { 48 | case .serverError(let message, _, _): 49 | return NSLocalizedString(message , comment: "") 50 | default: 51 | return NSLocalizedString("\(self)", comment: "") 52 | } 53 | } 54 | } 55 | 56 | 57 | 58 | 59 | 60 | /// errors when can not create URL 61 | /// 62 | /// - couldNotEncodeParameter: errors when could not encode parameters in url 63 | /// - couldNotCreateUrlWithGivenString: errors when given stirng can not be used to create URL 64 | public enum urlInitFailedReason { 65 | case couldNotEncodeParameter 66 | case couldNotCreateUrlWithGivenString 67 | } 68 | 69 | 70 | /// errors when URLSession fails 71 | /// 72 | /// - noResponse: response is nil 73 | /// - unacceptableStatusCode: status code is not accaptable 74 | /// - noDataRecived: data is nil 75 | public enum networkErrorReason { 76 | case noResponse 77 | case unacceptableStatusCode 78 | case noDataRecived 79 | } 80 | -------------------------------------------------------------------------------- /PayDock/ExternalCheckout.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ExternalCheckout.swift 3 | // PayDock 4 | // 5 | // Created by Oleksandr Omelchenko on 13.08.17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | 12 | /// External Checkout model 13 | public struct ExternalCheckout: Parameterable, Mapable { 14 | 15 | public typealias Kind = ExternalCheckout 16 | 17 | /// Checkout type 18 | public var checkoutType: String? 19 | /// Checkout link 20 | public var link: String? 21 | /// Billing agreement reference value for Paypal checkout 22 | public var referenceId: String? 23 | /// Eternal checkout token to consume with One-time token creation 24 | public var token: String? 25 | 26 | /// Environment mode: test or live, optional 27 | public var mode: String? = "test" // request 28 | /// Payment gateway Id 29 | public var gatewayId: String? // request required 30 | /// Url to redirect when checkout succeed 31 | public var successRedirectUrl: String? // request required 32 | /// Url to redirect when checkout failed 33 | public var errorRedirectUrl: String? // request required 34 | /// Custom description that will be shown on a PayPal page when accepting the token 35 | public var description: String? // request 36 | 37 | 38 | /// JSON response 39 | public var rawJson: [String: Any]? 40 | 41 | init(json: Dictionary) throws { 42 | 43 | self.checkoutType = try? json.value(for: "checkout_type") 44 | self.link = try? json.value(for: "link") 45 | self.referenceId = try? json.value(for: "reference_id") 46 | self.mode = try? json.value(for: "mode") 47 | self.token = try? json.value(for: "token") 48 | self.rawJson = json 49 | } 50 | 51 | init(mode: String?, gatewayId: String?, successRedirectUrl: String?, errorRedirectUrl: String?, description: String?) { 52 | self.mode = mode 53 | self.gatewayId = gatewayId 54 | self.successRedirectUrl = successRedirectUrl 55 | self.errorRedirectUrl = errorRedirectUrl 56 | self.description = description 57 | } 58 | 59 | public func toDictionary() -> [String : Any] { 60 | var param: [String: Any] = [:] 61 | param.appendNonNilable(key: "mode", item: mode) 62 | param.appendNonNilable(key: "gateway_id", item: gatewayId) 63 | param.appendNonNilable(key: "success_redirect_url", item: successRedirectUrl) 64 | param.appendNonNilable(key: "error_redirect_url", item: errorRedirectUrl) 65 | param.appendNonNilable(key: "phone", item: description) 66 | return param 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /PayDock/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | PayDock 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | FMWK 19 | CFBundleShortVersionString 20 | 1.1.1 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | urls 26 | 27 | production 28 | https://api.paydock.com/ 29 | sandbox 30 | https://api-sandbox.paydock.com/ 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /PayDock/Info1.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | urls 6 | 7 | production 8 | https://api.paydock.com/ 9 | sandbox 10 | https://api-sandbox.paydock.com/ 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /PayDock/Mapper/Mapable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Mapable.swift 3 | // PayDock 4 | // 5 | // Created by Round Table Apps on 23/4/17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /// Protocol that gives models ability to be mapped from json 12 | protocol Mapable { 13 | 14 | associatedtype Kind 15 | 16 | /// init from json 17 | /// 18 | /// - Parameter json: Json Dictionary 19 | /// - Throws: errors if could not map from given JSON 20 | init(json: Dictionary) throws 21 | 22 | } 23 | -------------------------------------------------------------------------------- /PayDock/Models/Address.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Address.swift 3 | // PayDock 4 | // 5 | // Created by Round Table Apps on 19/4/17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /// address model 12 | public struct Address: Parameterable, Mapable { 13 | public typealias Kind = Address 14 | 15 | 16 | /// Customer Address, line 1 17 | public var line1: String? 18 | /// Customer Address, line 2 19 | public var line2: String? 20 | /// Customer Address, City 21 | public var city: String? 22 | /// Customer Address, Postcade 23 | public var postcode: String? 24 | /// Customer Address, State 25 | public var state: String? 26 | /// Customer Address, Country Code 27 | public var country: String? 28 | 29 | init(json: Dictionary) throws { 30 | self.line1 = try? json.value(for: "address_line1") 31 | 32 | self.line2 = try? json.value(for: "address_line2") 33 | //self.line2 = try? json.value(for: "line2") 34 | //self.city = try? json.value(for: "city") 35 | self.city = try? json.value(for: "address_city") 36 | // self.postcode = try? json.value(for: "postcode") 37 | self.postcode = try? json.value(for: "address_postcode") 38 | self.state = try? json.value(for: "address_state") 39 | // self.state = try? json.value(for: "state") 40 | // self.country = try? json.value(for: "country") 41 | self.country = try? json.value(for: "address_country") 42 | } 43 | 44 | public init(line1: String?, line2: String?, city: String?, postcode: String?, state: String?, country: String?) { 45 | self.line1 = line1 46 | self.line2 = line2 47 | self.city = city 48 | self.postcode = postcode 49 | self.state = state 50 | self.country = country 51 | } 52 | 53 | public func toDictionary() -> [String : Any] { 54 | var param: [String: Any] = [:] 55 | param.appendNonNilable(key: "line1", item: line1) 56 | param.appendNonNilable(key: "line2", item: line2) 57 | param.appendNonNilable(key: "city", item: city) 58 | param.appendNonNilable(key: "state", item: state) 59 | param.appendNonNilable(key: "country", item: country) 60 | param.appendNonNilable(key: "postcode", item: postcode) 61 | return param 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /PayDock/Models/Charge/Charge.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Charge.swift 3 | // PayDock 4 | // 5 | // Created by Round Table Apps on 19/4/17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | /// charge model 11 | public struct Charge: Parameterable, Mapable { 12 | typealias Kind = Charge 13 | /// charge ID 14 | public var id: String? 15 | /// external ID 16 | public var externalId: String? 17 | /// subscription ID 18 | public var subscriptionId: String? 19 | /// company ID 20 | public var companyId: String? 21 | /// user ID 22 | public var userId: String? 23 | /// Amount of payment 24 | public var amount: Float 25 | /// Currency code, AUD by default 26 | public var currency: String = "AUD" 27 | /// Manually defined reference for customer in payment systems 28 | public var reference: String? 29 | /// Manually defined description for payments in payment systems 30 | public var description: String? 31 | /// One-time token with all the payment source information 32 | public var token: String? 33 | /// Customer email 34 | public var email: String? 35 | /// Existing customer ID 36 | public var customerId: String? 37 | /// Customer 38 | public var customer: Customer? 39 | /// Created Date 40 | public var createdAt: Date? 41 | /// Updated Date 42 | public var updatedAt: Date? 43 | /// is one off 44 | public var isOneOff: Bool? 45 | /// is archived 46 | public var isArchived: Bool? 47 | /// 48 | public var _v: Int? 49 | /// Payment source ID 50 | public var paymentSourceId: String? 51 | /// list of transactions 52 | public var transactions: [Transaction]? 53 | /// status 54 | public var status: String? 55 | /// JSON response 56 | public var rawJson: [String: Any]? 57 | 58 | 59 | private init(amount: Float, currency: String, reference: String?, description: String?, token: String?, email: String?, customerId: String?, customer: Customer?, paymentSourceId: String?) { 60 | self.amount = amount 61 | self.currency = currency 62 | self.reference = reference 63 | self.description = description 64 | self.token = token 65 | self.email = email 66 | self.customerId = customerId 67 | self.customer = customer 68 | } 69 | 70 | 71 | /// init for one-time token request 72 | init(amount: Float, currency: String, token: String, reference: String?, description: String?, email: String? ) { 73 | self.init(amount: amount, currency: currency, reference: reference, description: description, token: token, email: email, customerId: nil, customer: nil,paymentSourceId: nil) 74 | } 75 | 76 | /// init for Charge with credit card or bank Account 77 | init(amount: Float, currency: String, reference: String?, description: String?, customer: Customer) { 78 | self.init(amount: amount, currency: currency, reference: reference, description: description, token: nil, email: nil, customerId: nil, customer: customer, paymentSourceId: nil) 79 | } 80 | 81 | /// init for Charge with customer id 82 | init(amount: Float, currency: String, reference: String?, description: String?, customerId: String) { 83 | self.init(amount: amount, currency: currency, reference: reference, description: description, token: nil, email: nil, customerId: customerId, customer: nil, paymentSourceId: nil) 84 | } 85 | 86 | /// init for customer with non-default payment source 87 | init(amount: Float, currency: String, reference: String?, description: String?, customerId: String, paymentSourceId: String) { 88 | self.init(amount: amount, currency: currency, reference: reference, description: description, token: nil, email: nil, customerId: customerId, customer: nil, paymentSourceId: paymentSourceId) 89 | } 90 | init(json: Dictionary) throws { 91 | self.currency = try json.value(for: "currency") 92 | self.amount = try json.value(for: "amount") 93 | self.id = try? json.value(for: "_id") 94 | self.externalId = try? json.value(for: "external_id") 95 | self.subscriptionId = try? json.value(for: "subscription_id") 96 | self.companyId = try? json.value(for: "company_id") 97 | self.userId = try? json.value(for: "user_id") 98 | self.reference = try? json.value(for: "reference") 99 | self.description = try? json.value(for: "description") 100 | self.token = try? json.value(for: "token") 101 | self.email = try? json.value(for: "email") 102 | self.customerId = try? json.value(for: "customer_id") 103 | self.createdAt = try? json.value(for: "created_at") 104 | self.updatedAt = try? json.value(for: "updated_at") 105 | self.isOneOff = try? json.value(for: "one_off") 106 | self.isArchived = try? json.value(for: "archived") 107 | self._v = try? json.value(for: "__v") 108 | self.paymentSourceId = try? json.value(for: "payment_source_id") 109 | self.status = try? json.value(for: "status") 110 | self.rawJson = json 111 | let transactions: [Dictionary]? = try? json.value(for: "transactions") 112 | if let availableTransactions = transactions { 113 | self.transactions = [] 114 | for transaction in availableTransactions { 115 | if let maped:Transaction = try? Transaction(json: transaction) { 116 | self.transactions?.append(maped) 117 | } 118 | } 119 | } 120 | 121 | if let _customer: Customer = try? json.valueMapable(for: "customer") { 122 | self.customer = _customer 123 | } 124 | } 125 | 126 | 127 | 128 | public func toDictionary() -> [String : Any] { 129 | var params: [String: Any] = [ 130 | "amount": amount, 131 | "currency": currency] 132 | params.appendNonNilable(key: "reference", item: reference) 133 | params.appendNonNilable(key: "description", item: description) 134 | params.appendNonNilable(key: "token", item: token) 135 | params.appendNonNilable(key: "email", item: email) 136 | params.appendNonNilable(key: "customer_id", item: customerId) 137 | params.appendNonNilable(key: "payment_source_id", item: paymentSourceId) 138 | params.appendNonNilable(key: "customer", item: customer?.toDictionary()) 139 | return params 140 | } 141 | } 142 | 143 | 144 | 145 | 146 | -------------------------------------------------------------------------------- /PayDock/Models/Customer/Customer.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Customer.swift 3 | // PayDock 4 | // 5 | // Created by Round Table Apps on 18/4/17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /// customer model 12 | public struct Customer: Parameterable, Mapable { 13 | 14 | public typealias Kind = Customer 15 | /// Customer ID 16 | public var id: String? 17 | /// Customer first name optional for one-time token 18 | public var firstName: String? // request 19 | /// Customer last name optional for one-time token 20 | public var lastName: String? // request 21 | /// Customer email optional for one-time token 22 | public var email: String? // request 23 | /// Manually defined reference for customer in payment systems 24 | public var reference: String? // request 25 | /// Customer phone in E.164 international notation (Example: +12345678901) 26 | public var phone: String? // request 27 | /// status 28 | public var status: String? 29 | /// default Payment Source ID 30 | public var defaultSource: String? 31 | /// 32 | public var _v: Int? 33 | /// Gateway ID 34 | public var gatewayId: String? 35 | /// One-time token with all the payment source information 36 | public var token: String? 37 | /// Created At Date 38 | public var createdAt: Date? 39 | /// Updated At Date 40 | public var updateAt: Date? 41 | /// list of Payment Sources 42 | public var paymentSources: [PaymentSource]? 43 | /// Payment Source 44 | public var paymentSource: PaymentSource? // request required for charge 45 | /// 46 | public var statistics: [String: Any]? 47 | /// 48 | public var _service: [String: Any]? 49 | /// JSON response 50 | public var rawJson: [String: Any]? 51 | 52 | init(firstName: String?, lastName: String?, email: String?, reference: String?, phone: String?, paymentSource: PaymentSource?) { 53 | self.firstName = firstName 54 | self.lastName = lastName 55 | self.email = email 56 | self.reference = reference 57 | self.phone = phone 58 | self.paymentSource = paymentSource 59 | } 60 | 61 | init(firstName: String?, lastName: String?, email: String?, reference: String?, phone: String?) { 62 | self.firstName = firstName 63 | self.lastName = lastName 64 | self.email = email 65 | self.reference = reference 66 | self.phone = phone 67 | } 68 | 69 | init(firstName: String?, lastName: String?, email: String?, reference: String?, phone: String?, token: String) { 70 | self.firstName = firstName 71 | self.lastName = lastName 72 | self.email = email 73 | self.reference = reference 74 | self.phone = phone 75 | self.token = token 76 | } 77 | 78 | init(json: Dictionary) throws { 79 | 80 | self.firstName = try? json.value(for: "first_name") 81 | self.lastName = try? json.value(for: "last_name") 82 | self.id = try? json.value(for: "_id") 83 | self.email = try? json.value(for: "email") 84 | self.reference = try? json.value(for: "reference") 85 | self.phone = try? json.value(for: "phone") 86 | self.status = try? json.value(for: "status") 87 | self.defaultSource = try? json.value(for: "default_source") 88 | self._v = try? json.value(for: "__v") 89 | self.gatewayId = try? json.value(for: "gateway_id") 90 | self.token = try? json.value(for: "token") 91 | self.createdAt = try? json.value(for: "created_at") 92 | self.updateAt = try? json.value(for: "updated_at") 93 | self.statistics = try? json.value(for: "statistics") 94 | self._service = try? json.value(for: "__service") 95 | self.paymentSource = try? json.valueMapable(for: "payment_source") 96 | if let _paymentSources: [[String: Any]] = try? json.value(for: "payment_sources") { 97 | self.paymentSources = [] 98 | for source in _paymentSources { 99 | if let _paymentSource: PaymentSource = try? PaymentSource(json: source) { 100 | self.paymentSources?.append(_paymentSource) 101 | } 102 | } 103 | } 104 | self.rawJson = json 105 | } 106 | 107 | 108 | public func toDictionary() -> [String : Any] { 109 | var param: [String: Any] = [:] 110 | param.appendNonNilable(key: "first_name", item: firstName) 111 | param.appendNonNilable(key: "last_name", item: lastName) 112 | param.appendNonNilable(key: "email", item: email) 113 | param.appendNonNilable(key: "reference", item: reference) 114 | param.appendNonNilable(key: "phone", item: phone) 115 | param.appendNonNilable(key: "default_source", item: defaultSource) 116 | param.appendNonNilable(key: "token", item: token) 117 | param.appendNonNilable(key: "payment_source", item: paymentSource?.toDictionary()) 118 | return param 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /PayDock/Models/Parameters/ChargeRequest.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ChargeRequest.swift 3 | // PayDock 4 | // 5 | // Created by Round Table Apps on 22/4/17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | /// Parameter for Charge APIs 11 | public struct ChargeRequest: Parameterable { 12 | private let _charge: Charge 13 | 14 | /// Amount of payment 15 | public var amount: Float { 16 | get { 17 | return _charge.amount 18 | } 19 | } 20 | 21 | /// Currency code, AUD by default 22 | public var currency: String { 23 | get { 24 | return _charge.currency 25 | } 26 | } 27 | 28 | /// Customer 29 | public var customer: Customer? { 30 | get { 31 | return _charge.customer 32 | } 33 | } 34 | 35 | /// Existing customer ID 36 | public var customerId: String? { 37 | get { 38 | return _charge.customerId 39 | } 40 | } 41 | 42 | /// Payment source ID 43 | public var paymentSourceId: String? { 44 | get { 45 | return _charge.paymentSourceId 46 | } 47 | } 48 | 49 | 50 | /// One-time token with all the payment source information 51 | public var token: String? { 52 | get { 53 | return _charge.token 54 | } 55 | } 56 | 57 | /// Customer email 58 | public var email: String? { 59 | get { 60 | return _charge.email 61 | } 62 | } 63 | 64 | /// Manually defined description for payments in payment systems 65 | public var description: String? { 66 | get { 67 | return _charge.description 68 | } 69 | } 70 | 71 | 72 | /// Manually defined reference for customer in payment systems 73 | public var reference: String? { 74 | get { 75 | return _charge.reference 76 | } 77 | } 78 | 79 | /// init for Charge with credit card or bank Account 80 | public init(amount: Float, currency: String, reference: String?, description: String?, customer: CustomerRequest) { 81 | _charge = Charge(amount: amount, currency: currency, reference: reference, description: description, customer: customer._customer) 82 | } 83 | 84 | /// init for Charge with customer id 85 | public init(amount: Float, currency: String, reference: String?, description: String?, customerId: String) { 86 | _charge = Charge(amount: amount, currency: currency, reference: reference, description: description, customerId: customerId) 87 | } 88 | 89 | /// init for customer with non-default payment source 90 | public init(amount: Float, currency: String, reference: String?, description: String?, customerId: String, paymentSourceId: String) { 91 | _charge = Charge(amount: amount, currency: currency, reference: reference, description: description, customerId: customerId, paymentSourceId: paymentSourceId) 92 | } 93 | 94 | /// init for one-time token request 95 | public init(amount: Float, currency: String, token: String, reference: String?, description: String?, email: String?) { 96 | _charge = Charge(amount: amount, currency: currency, token: token, reference: reference, description: description, email: email) 97 | } 98 | 99 | public func toDictionary() -> [String : Any] { 100 | return _charge.toDictionary() 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /PayDock/Models/Parameters/CustomerRequest.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CustomerRequest.swift 3 | // PayDock 4 | // 5 | // Created by Round Table Apps on 22/4/17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /// Parameter for Customer APIs 12 | public struct CustomerRequest: Parameterable { 13 | let _customer: Customer 14 | 15 | /// Customer first name optional for one-time token 16 | public var firstName: String? { 17 | get { 18 | return _customer.firstName 19 | } 20 | } 21 | 22 | /// Customer last name optional for one-time token 23 | public var lastName: String? { 24 | get { 25 | return _customer.lastName 26 | } 27 | } 28 | 29 | /// Customer email optional for one-time token 30 | public var email: String? { 31 | get { 32 | return _customer.email 33 | } 34 | } 35 | 36 | 37 | /// Customer phone in E.164 international notation (Example: +12345678901) 38 | public var phone: String? { 39 | get { 40 | return _customer.phone 41 | } 42 | } 43 | 44 | /// Manually defined reference for customer in payment systems 45 | public var reference: String? { 46 | get { 47 | return _customer.reference 48 | } 49 | } 50 | 51 | /// One-time token with all the payment source information 52 | public var token: String? { 53 | get { 54 | return _customer.token 55 | } 56 | } 57 | 58 | /// Payment Source 59 | public var paymentSource: PaymentSource? { 60 | get { 61 | return _customer.paymentSource 62 | } 63 | } 64 | 65 | /// init CustomerRequest with Payment Source (credit card details, direct debit details using bank account or BSB) 66 | public init(firstName: String?, lastName: String?, email: String?, reference: String?, phone: String?, paymentSource: PaymentSource) { 67 | _customer = Customer(firstName: firstName, lastName: lastName, email: email, reference: reference, phone: phone, paymentSource: paymentSource) 68 | } 69 | /// init CustomerRequest without Payment Source 70 | public init(firstName: String?, lastName: String?, email: String?, reference: String?, phone: String?) { 71 | _customer = Customer(firstName: firstName, lastName: lastName, email: email, reference: reference, phone: phone) 72 | } 73 | /// init CustomerRequest with one-time Token 74 | public init(firstName: String?, lastName: String?, email: String?, reference: String?, phone: String?, token: String) { 75 | _customer = Customer(firstName: firstName, lastName: lastName, email: email, reference: reference, phone: phone, token: token) 76 | } 77 | 78 | public func toDictionary() -> [String : Any] { 79 | return _customer.toDictionary() 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /PayDock/Models/Parameters/ExternalCheckoutRequest.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ExternalCheckoutRequest.swift 3 | // PayDock 4 | // 5 | // Created by Oleksandr Omelchenko on 13.08.17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | 12 | /// Parameter for External Checkout APIs 13 | public struct ExternalCheckoutRequest : Parameterable { 14 | private var _externalCheckout: ExternalCheckout! 15 | 16 | /// Environment mode: test or live, optional 17 | public var mode: String? { 18 | get { return _externalCheckout.mode } 19 | } 20 | 21 | /// Payment gateway Id 22 | public var gatewayId: String { 23 | get { return _externalCheckout.gatewayId! } 24 | } 25 | 26 | /// Url to redirect when checkout succeed 27 | public var successRedirectUrl: String { 28 | get { return _externalCheckout.successRedirectUrl! } 29 | } 30 | 31 | /// Url to redirect when checkout failed 32 | public var errorRedirectUrl: String { 33 | get { return _externalCheckout.errorRedirectUrl! } 34 | } 35 | 36 | /// Custom description that will be shown on a PayPal page when accepting the token 37 | public var description: String? { 38 | get { return _externalCheckout.description } 39 | } 40 | 41 | /// init for checkout request 42 | public init(mode: String?, gatewayId: String?, successRedirectUrl: String?, errorRedirectUrl: String?, description: String? ) { 43 | _externalCheckout = ExternalCheckout(mode: mode, gatewayId: gatewayId, successRedirectUrl: successRedirectUrl, errorRedirectUrl: errorRedirectUrl, description: description) 44 | } 45 | 46 | 47 | public func toDictionary() -> [String : Any] { 48 | return _externalCheckout.toDictionary() 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /PayDock/Models/Parameters/ListParameters.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ChargeListParameters.swift 3 | // PayDock 4 | // 5 | // Created by Round Table Apps on 19/4/17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /// Parameter for geting list items 12 | public struct ListParameters: Parameterable { 13 | /// Pagination parameter to skip first n transactions from list, default = 0 14 | public var skip: Int? 15 | /// Pagination parameter to limit output to n , default = 100 , maximum value = 1000 16 | public var limit: Int? 17 | /// To only fetch transactions related to particular subscription 18 | public var subscription_id: String? 19 | /// ID of a gateway with which charges were created 20 | public var gateway_id: String? 21 | /// ID of a company with which charges were created 22 | public var company_id: String? 23 | /// Parameter to set range of created transactions date 24 | public var createdAtFrom: Date? 25 | /// Parameter to set range of created transactions date 26 | public var createdAtTo: Date? 27 | /// Word of phrase Customer want to search in created charges (search works by fields: First, Last names and Emails) 28 | public var search: String? 29 | /// Status could be: complete, failed, archived, requested, refund_requested, refunded, inprogress 30 | public var status: String? 31 | /// Set to true to show all the archived charges. Default: false 32 | public var isArchived: Bool? 33 | /// Generated backend side jwt token with search query with public key 34 | public var queryToken: String? 35 | 36 | public init(skip: Int?, limit: Int?, subscription_id: String?, gateway_id: String?, company_id: String?, createdAtFrom: Date?, createdAtTo: Date?, search: String?, status: String?, isArchived: Bool?, queryToken: String?) { 37 | self.skip = skip 38 | self.limit = limit 39 | self.subscription_id = subscription_id 40 | self.gateway_id = gateway_id 41 | self.company_id = company_id 42 | self.createdAtFrom = createdAtFrom 43 | self.createdAtTo = createdAtTo 44 | self.search = search 45 | self.status = status 46 | self.isArchived = isArchived 47 | self.queryToken = queryToken 48 | } 49 | 50 | public func toDictionary() -> [String : Any] { 51 | var param: [String: Any] = [:] 52 | param.appendNonNilable(key: "skip", item: skip) 53 | param.appendNonNilable(key: "limit", item: limit) 54 | param.appendNonNilable(key: "subscription_id", item: subscription_id) 55 | param.appendNonNilable(key: "gateway_id", item: gateway_id) 56 | param.appendNonNilable(key: "company_id", item: company_id) 57 | param.appendNonNilable(key: "created_at.from", item: createdAtFrom?.toUTCString()) 58 | param.appendNonNilable(key: "created_at.to", item: createdAtTo?.toUTCString()) 59 | param.appendNonNilable(key: "search", item: search) 60 | param.appendNonNilable(key: "status", item: status) 61 | param.appendNonNilable(key: "archived", item: isArchived) 62 | param.appendNonNilable(key: "query_token", item: queryToken) 63 | return param 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /PayDock/Models/Parameters/Parameterable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Parameterable.swift 3 | // PayDock 4 | // 5 | // Created by Round Table Apps on 18/4/17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /// protocol to turn objects to Dictionary 12 | public protocol Parameterable { 13 | /// convert the class to Dictionary sutable for parameters 14 | func toDictionary() -> [String: Any] 15 | } 16 | -------------------------------------------------------------------------------- /PayDock/Models/Parameters/SubscriptionRequest.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SubscriptionRequest.swift 3 | // PayDock 4 | // 5 | // Created by Round Table Apps on 4/22/17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /// Parameter for Subscription APIs 12 | public struct SubscriptionRequest : Parameterable { 13 | private var _subscription: Subscription! 14 | 15 | /// Amount of payment 16 | public var amount: Float { 17 | get { return _subscription.amount } 18 | } 19 | 20 | /// Currency code, AUD by default 21 | public var currency: String { 22 | get { return _subscription.currency } 23 | } 24 | /// Manually defined reference for payments in payment systems 25 | public var reference: String? { 26 | get { return _subscription.reference } 27 | } 28 | /// Manually defined description for payments in payment systems 29 | public var description: String? { 30 | get { return _subscription.description } 31 | } 32 | /// One-time token with all payment source information 33 | public var token: String? { 34 | get { return _subscription.token } 35 | } 36 | /// Schedule with subscription schedule information 37 | public var schedule: Schedule { 38 | get { return _subscription.schedule! } 39 | } 40 | /// Customer with customers information 41 | public var customer: Customer? { 42 | get { return _subscription.customer } 43 | /// ID of PayDock customer 44 | } 45 | public var customerId: String? { 46 | get { return _subscription.customerId } 47 | } 48 | /// init for one-time token request 49 | public init(amount: Float, currency: String, reference: String?, description: String?, token: String, schedule: Schedule ) { 50 | _subscription = Subscription(amount: amount, currency: currency, reference: reference, description: description, token: token, schedule: schedule) 51 | } 52 | 53 | /// init for Subscription with customer and payment source 54 | public init(amount: Float, currency: String, reference: String?, description: String?, customer: CustomerRequest, schedule: Schedule) { 55 | _subscription = Subscription(amount: amount, currency: currency, reference: reference, description: description, customer: customer._customer, schedule: schedule) 56 | } 57 | 58 | /// init for Subscription with customer id 59 | public init(amount: Float, currency: String, reference: String?, description: String?, customerId: String, schedule: Schedule ) { 60 | _subscription = Subscription(amount: amount, currency: currency, reference: reference, description: description, customerId: customerId, schedule: schedule) 61 | } 62 | 63 | /// init for updating subscription 64 | public init(amount: Float, currency: String, reference: String?, description: String?, schedule: Schedule) { 65 | _subscription = Subscription(amount: amount, currency: currency, reference: reference, description: description, schedule: schedule) 66 | } 67 | 68 | public func toDictionary() -> [String : Any] { 69 | return _subscription.toDictionary() 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /PayDock/Models/Parameters/TokenRequest.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Token.swift 3 | // PayDock 4 | // 5 | // Created by Round Table Apps on 4/22/17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /// Parameters to get one-time token 12 | public struct TokenRequest: Parameterable { 13 | 14 | /// CustomerRequest instance 15 | public var customer: CustomerRequest? 16 | /// Address instance 17 | public var address: Address? 18 | /// Payment Source Instance 19 | public var paymentSource: PaymentSource 20 | 21 | public init(customer: CustomerRequest?, address: Address?, paymentSource: PaymentSource ) { 22 | self.customer = customer 23 | self.address = address 24 | self.paymentSource = paymentSource 25 | } 26 | 27 | public func toDictionary() -> [String : Any] { 28 | var param = [String: Any]() 29 | address?.toDictionary().forEach { (key, value) in 30 | param[key] = value 31 | } 32 | customer?.toDictionary().forEach { (key, value) in 33 | param[key] = value 34 | } 35 | paymentSource.toDictionary().forEach { (key, value) in 36 | param[key] = value 37 | } 38 | return param 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /PayDock/Models/Payment Sources/BSB.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BSB.swift 3 | // PayDock 4 | // 5 | // Created by Round Table Apps on 19/4/17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | public struct BSB: Parameterable,Mapable { 12 | public typealias Kind = BSB 13 | 14 | /// bsb ID 15 | public var id: String? 16 | /// Gateway ID 17 | public var gatewayId: String? // request required 18 | /// Gateway Name 19 | public var gatewayName: String? 20 | /// Gateway Type 21 | public var gatewayType: String? 22 | /// Gateway Mode 23 | public var gatewayMode: String? 24 | /// Number of Customer account. Parameter required when using Direct Debit only 25 | public var accountNumber: String? // request required 26 | /// Customer bank state branch number. Parameter required when using Direct Debit only 27 | public var accountBSB: String? // request required 28 | /// Customer account name. Parameter required when using Direct Debit only 29 | public var accountName: String? // request required 30 | /// Customer's Address 31 | public var address: Address? 32 | /// ref Token 33 | public var refToken: String? 34 | /// status 35 | public var status: String? 36 | /// Created Date 37 | public var createdAt: Date? 38 | /// Updated At 39 | public var updatedAt: Date? 40 | /// Raw Json Response from server 41 | public var rawJson: [String: Any]? 42 | // primary 43 | public var primary :Bool? 44 | init(json: Dictionary) throws { 45 | self.primary = try? json.value(for: "primary") 46 | self.id = try? json.value(for: "_id") 47 | self.gatewayId = try? json.value(for: "gateway_id") 48 | self.gatewayName = try? json.value(for: "gateway_name") 49 | self.gatewayType = try? json.value(for: "gateway_type") 50 | self.gatewayMode = try? json.value(for: "gateway_mode") 51 | self.accountNumber = try? json.value(for: "account_number") 52 | self.accountBSB = try? json.value(for: "account_bsb") 53 | self.accountName = try? json.value(for: "account_name") 54 | self.status = try? json.value(for: "status") 55 | self.refToken = try? json.value(for: "ref_token") 56 | self.createdAt = try? json.value(for: "created_at") 57 | self.updatedAt = try? json.value(for: "updated_at") 58 | self.address = try? Address(json: json) 59 | self.rawJson = json 60 | } 61 | public init(gatewayId: String, accountNumber: String?, accountName: String?, accountBSB: String) { 62 | self.gatewayId = gatewayId 63 | self.accountNumber = accountNumber 64 | self.accountBSB = accountBSB 65 | self.accountName = accountName 66 | } 67 | 68 | public func toDictionary() -> [String : Any] { 69 | var param: [String: Any] = ["type": "bsb"] 70 | address?.toDictionary().forEach({ param[$0] = $1 }) 71 | param.appendNonNilable(key: "id", item: self.id) 72 | param.appendNonNilable(key: "gateway_id", item: gatewayId) 73 | param.appendNonNilable(key: "gateway_name", item: gatewayName) 74 | param.appendNonNilable(key: "gateway_type", item: gatewayType) 75 | param.appendNonNilable(key: "gateway_mode", item: gatewayMode) 76 | param.appendNonNilable(key: "account_number", item: accountNumber) 77 | param.appendNonNilable(key: "account_bsb", item: accountBSB) 78 | param.appendNonNilable(key: "account_name", item: accountName) 79 | // param.appendNonNilable(key: "rawJson", item: rawJson) 80 | param.appendNonNilable(key: "primary", item: primary) 81 | return param 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /PayDock/Models/Payment Sources/BankAccount.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BankAccount.swift 3 | // PayDock 4 | // 5 | // Created by Round Table Apps on 19/4/17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | public struct BankAccount: Parameterable, Mapable { 12 | public typealias Kind = BankAccount 13 | /// Bank Account ID 14 | public var id: String? 15 | /// Gateway ID 16 | public var gatewayId: String? // request required 17 | /// Customer account name. Parameter required when using Direct Debit only 18 | public var accountName: String? 19 | /// Number of Customer account. Parameter required when using Direct Debit only 20 | public var accountNumber: String? // request required 21 | /// Customer's Address 22 | public var address: Address? 23 | /// Number of Customer account. BSB/Routing/SWIFT/IBAN Number. 24 | public var accountRouting: String? // request required 25 | /// Type 26 | public var type: String? 27 | /// account type ('personal’ or 'business’) 28 | public var holderType: String? // request required 29 | /// Name of account bank 30 | public var bankName: String? // request required 31 | /// Updated Date 32 | public var updatedAt: Date? 33 | /// Created Date 34 | public var createdAt: Date? 35 | /// status 36 | public var status: String? 37 | /// ref token 38 | public var refToken: String? 39 | /// JSON response from server 40 | public var rawJson: [String: Any]? 41 | 42 | init(json: Dictionary) throws { 43 | self.id = try? json.value(for: "_id") 44 | self.gatewayId = try? json.value(for: "gateway_id") 45 | self.accountName = try? json.value(for: "account_name") 46 | self.accountNumber = try? json.value(for: "account_number") 47 | self.accountRouting = try? json.value(for: "account_routing") 48 | self.type = try? json.value(for: "type") 49 | self.holderType = try? json.value(for: "account_holder_type") 50 | self.bankName = try? json.value(for: "account_bank_name") 51 | self.status = try? json.value(for: "status") 52 | self.refToken = try? json.value(for: "ref_token") 53 | self.createdAt = try? json.value(for: "created_at") 54 | self.updatedAt = try? json.value(for: "updated_at") 55 | self.address = try? Address(json: json) 56 | self.rawJson = json 57 | } 58 | 59 | public init(gatewayId: String, accountNumber: String?, accountName: String?, bankName: String?, accountRouting: String?, holderType: String?, address: Address?, type: String?) { 60 | self.gatewayId = gatewayId 61 | self.accountNumber = accountNumber 62 | self.accountRouting = accountRouting 63 | self.holderType = holderType 64 | self.bankName = bankName 65 | self.address = address 66 | self.type = type 67 | self.accountName = accountName 68 | } 69 | 70 | public func toDictionary() -> [String : Any] { 71 | var param: [String: Any] = ["type": "bank_account"] 72 | address?.toDictionary().forEach({ param[$0] = $1 }) 73 | param.appendNonNilable(key: "gateway_id", item: gatewayId) 74 | param.appendNonNilable(key: "account_name", item: accountName) 75 | param.appendNonNilable(key: "account_number", item: accountNumber) 76 | param.appendNonNilable(key: "account_routing", item: accountRouting) 77 | param.appendNonNilable(key: "account_holder_type", item: holderType) 78 | param.appendNonNilable(key: "account_bank_name", item: bankName) 79 | param.appendNonNilable(key: "account_type", item: type) 80 | return param 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /PayDock/Models/Payment Sources/Card.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Card.swift 3 | // PayDock 4 | // 5 | // Created by Round Table Apps on 19/4/17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | public struct Card: Parameterable, Mapable { 12 | public typealias Kind = Card 13 | /// card id 14 | public var id: String? 15 | /// Cardholder name (as on card) 16 | public var name: String? // request required 17 | /// Card number 18 | public var number: String? // request required 19 | /// Last 4 digits of Card Number 20 | public var last4Number: String? 21 | /// Card CCV number 22 | public var ccv: String? 23 | /// Card Scheme 24 | public var scheme: String? 25 | /// Card expiration month mm format 26 | public var expireMonth: Int? // request required 27 | /// Card expiration year yyyy format 28 | public var expireYear: Int? // request required 29 | /// Customer's Address 30 | public var address: Address? 31 | /// Gateway ID 32 | public var gatewayId: String? // request required 33 | /// ref Token 34 | public var refToken: String? 35 | /// Created Date 36 | public var createdAt: Date? 37 | /// Updated Date 38 | public var updatedAt: Date? 39 | /// raw json response from server 40 | public var rawJson: [String: Any]? 41 | // primary 42 | public var primary :Bool? 43 | 44 | public init(gatewayId: String, name: String, number: String, expireMonth: Int, expireYear: Int, ccv: String?, address: Address?) { 45 | self.gatewayId = gatewayId 46 | self.name = name 47 | self.number = number 48 | self.expireMonth = expireMonth 49 | self.expireYear = expireYear 50 | self.address = address 51 | self.ccv = ccv 52 | } 53 | 54 | init(json: Dictionary) throws { 55 | self.primary = try? json.value(for: "primary") 56 | self.id = try? json.value(for: "_id") 57 | self.name = try? json.value(for: "card_name") 58 | self.number = try? json.value(for: "card_number") 59 | self.last4Number = try? json.value(for: "card_number_last4") 60 | self.ccv = try? json.value(for: "card_ccv") 61 | self.scheme = try? json.value(for: "card_scheme") 62 | self.expireMonth = try? json.value(for: "expire_month") 63 | self.expireYear = try? json.value(for: "expire_year") 64 | self.gatewayId = try? json.value(for: "gateway_id") 65 | self.refToken = try? json.value(for: "ref_token") 66 | self.createdAt = try? json.value(for: "created_at") 67 | self.updatedAt = try? json.value(for: "updated_at") 68 | self.address = try? Address(json: json) 69 | self.rawJson = json 70 | 71 | } 72 | public func toDictionary() -> [String : Any] { 73 | var param: [String: Any] = ["type": "card"] 74 | address?.toDictionary().forEach { (key, value) in 75 | param[key] = value 76 | } 77 | param.appendNonNilable(key: "card_name", item: name) 78 | param.appendNonNilable(key: "expire_year", item: expireYear) 79 | param.appendNonNilable(key: "expire_month", item: expireMonth) 80 | param.appendNonNilable(key: "card_number", item: number) 81 | param.appendNonNilable(key: "card_ccv", item: ccv) 82 | param.appendNonNilable(key: "gateway_id", item: gatewayId) 83 | param.appendNonNilable(key: "card_scheme", item: scheme) 84 | param.appendNonNilable(key: "id", item: id) 85 | param.appendNonNilable(key: "card_number_last4", item: last4Number) 86 | // param.appendNonNilable(key: "rawJson", item: rawJson) 87 | param.appendNonNilable(key: "primary", item: primary) 88 | return param 89 | } 90 | 91 | } 92 | -------------------------------------------------------------------------------- /PayDock/Models/Payment Sources/Payment Source.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Payment Source.swift 3 | // PayDock 4 | // 5 | // Created by Round Table Apps on 19/4/17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | 12 | /// model for Payment Source 13 | /// 14 | /// - card: if source is card 15 | /// - bankAccount: if source is bank account 16 | /// - bsb: if source is bsb 17 | public enum PaymentSource: Parameterable, Mapable { 18 | 19 | case card(value: Card) 20 | case bankAccount(value: BankAccount) 21 | case bsb(value: BSB) 22 | case checkout(value: Checkout) 23 | 24 | typealias Kind = PaymentSource 25 | 26 | public func toDictionary() -> [String : Any] { 27 | switch self { 28 | case .card(let card): 29 | return card.toDictionary() 30 | case .bankAccount(let bankAccount): 31 | return bankAccount.toDictionary() 32 | case .bsb(let bsb): 33 | return bsb.toDictionary() 34 | case .checkout(let checkout): 35 | return checkout.toDictionary() 36 | } 37 | } 38 | 39 | 40 | init(json: Dictionary) throws { 41 | if let _: String? = (try? json.value(for: "card_name")) { 42 | let card: Card = try Card(json: json) 43 | self = PaymentSource.card(value: card) 44 | return 45 | } else if let _: String? = try? json.value(for: "account_bsb") { 46 | let bsb: BSB = try BSB(json: json) 47 | self = PaymentSource.bsb(value: bsb) 48 | return 49 | } else if let _: String? = try? json.value(for: "account_holder_type") { 50 | let account: BankAccount = try BankAccount(json: json) 51 | self = PaymentSource.bankAccount(value: account) 52 | return 53 | } else if let type: String? = try? json.value(for: "type") { 54 | if type == "card" { 55 | let card: Card = try Card(json: json) 56 | self = PaymentSource.card(value: card) 57 | return 58 | } else if type == "bsb" { 59 | let bsb: BSB = try BSB(json: json) 60 | self = PaymentSource.bsb(value: bsb) 61 | return 62 | } else if type == "bank_account" { 63 | let account: BankAccount = try BankAccount(json: json) 64 | self = PaymentSource.bankAccount(value: account) 65 | return 66 | } else if type == "checkout" { 67 | let checkout: Checkout = try Checkout(json: json) 68 | self = PaymentSource.checkout(value: checkout) 69 | 70 | return 71 | } 72 | } 73 | 74 | throw Errors.parsingFailed 75 | } 76 | 77 | 78 | } 79 | -------------------------------------------------------------------------------- /PayDock/Models/Subscription/Schedule.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Schedule.swift 3 | // PayDock 4 | // 5 | // Created by Round Table Apps on 4/19/17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /// schedule model 12 | public struct Schedule: Parameterable, Mapable { 13 | 14 | public typealias Kind = Schedule 15 | 16 | /// Assessment interval one-off, week, month, year, day 17 | public var interval: String // request required 18 | /// Start date 19 | public var startDate: Date? // request optional 20 | /// End date 21 | public var endDate: Date? // request optional 22 | /// next assessent date 23 | public var nextAssessment: Date? 24 | /// first assessment date 25 | public var firstAssessment: Date? 26 | /// last assessment date 27 | public var lastAssessment: Date? 28 | /// status 29 | public var status: String? 30 | /// is Locked? 31 | public var isLocked: Bool? 32 | /// completed Payments 33 | public var completedCount: Bool? 34 | /// retry Count 35 | public var retryCount: Bool? 36 | /// Assessment frequency, 1 by default (i.e. “3” = “Every 3 weeks”) 37 | public var frequency: Int // request required 38 | /// Total amount of all successful transactions (equals or exceeds) 39 | public var endAmountAfter: Float? 40 | /// Total amount of all successful transactions (not to exceed) 41 | public var endAmountBefore: Float? 42 | /// Total count of all successful transactions 43 | public var endTransactions: Int? 44 | /// Total amount to be payid with subscription (equals). NOTE: If last payment of subscription schedule will be less then $ 1.00, some gateways may respond with error and subscription status will become 'failed’. 45 | public var endAmountTotal: Float? 46 | /// JSON response 47 | public var rawJson: [String: Any]? 48 | 49 | 50 | public init(interval: String, frequency: Int, startDate: Date?, endDate:Date?, endAmountAfter: Float?, endAmountBefore: Float?, endAmountTotal: Float?, endTransactions: Int?) { 51 | self.interval = interval 52 | self.frequency = frequency 53 | self.startDate = startDate 54 | self.endDate = endDate 55 | self.endAmountAfter = endAmountAfter 56 | self.endAmountBefore = endAmountBefore 57 | self.endAmountTotal = endAmountTotal 58 | self.endTransactions = endTransactions 59 | } 60 | 61 | init(json: Dictionary) throws { 62 | self.interval = try json.value(for: "interval") 63 | self.startDate = try? json.value(for: "startDate") 64 | self.frequency = try json.value(for: "frequency") 65 | self.endDate = try? json.value(for: "endDate") 66 | self.firstAssessment = try? json.value(for: "first_assessment") 67 | self.lastAssessment = try? json.value(for: "last_assessment") 68 | self.nextAssessment = try? json.value(for: "next_assessment") 69 | self.isLocked = try? json.value(for: "locked") 70 | self.status = try? json.value(for: "status") 71 | self.completedCount = try? json.value(for: "completed_count") 72 | self.retryCount = try? json.value(for: "retry_count") 73 | self.endAmountAfter = try? json.value(for: "end_amount_after") 74 | self.endAmountBefore = try? json.value(for: "end_amount_before") 75 | self.endAmountTotal = try? json.value(for: "end_amount_total") 76 | self.endTransactions = try? json.value(for: "end_transactions") 77 | self.rawJson = json 78 | } 79 | 80 | public func toDictionary() -> [String : Any] { 81 | var param: [String: Any] = [ 82 | "interval": interval, 83 | "frequency": self.frequency] 84 | param.appendNonNilable(key: "start_date", item: startDate?.toUTCString()) 85 | param.appendNonNilable(key: "end_date", item: endDate?.toUTCString()) 86 | param.appendNonNilable(key: "end_amount_after", item: endAmountAfter) 87 | param.appendNonNilable(key: "end_amount_before", item: endAmountBefore) 88 | param.appendNonNilable(key: "end_amount_total", item: endAmountTotal) 89 | param.appendNonNilable(key: "end_transactions", item: endTransactions) 90 | 91 | return param 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /PayDock/Models/Subscription/Subscription.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Subscription.swift 3 | // PayDock 4 | // 5 | // Created by Round Table Apps on 4/19/17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /// subscription model 12 | public struct Subscription: Parameterable, Mapable { 13 | public typealias Kind = Subscription 14 | /// Subscription ID 15 | var id: String? 16 | /// Amount of payment 17 | var amount: Float // request required 18 | /// Currency code, AUD by default 19 | var currency: String // request required 20 | /// Manually defined description for payments in payment systems 21 | var description: String? // request optional 22 | /// Manually defined reference for payments in payment systems 23 | var reference: String? // request optional 24 | /// One-time token with all payment source information 25 | var token: String? // request required 26 | /// Created At 27 | var createdAt: Date? 28 | /// Updated At 29 | var updatedAt: Date? 30 | /// status 31 | var status: String? 32 | /// is Archived 33 | var isArchived: Bool? 34 | /// ID of PayDock customer 35 | var customerId: String? // request required 36 | /// PaymentSource ID 37 | var paymentSourceId: String? 38 | /// Gateway Type 39 | var gatewayType: String? 40 | /// Gateway Name 41 | var gatewayName: String? 42 | /// Gateway Mode 43 | var gatewayMode: String? 44 | /// Company ID 45 | var companyId: String? 46 | /// User ID 47 | var userId: String? 48 | /// 49 | var _v: Int? 50 | /// JSON response 51 | var rawJson: [String: Any]? 52 | 53 | /// 54 | var service: [String: Any]? 55 | /// 56 | var statistics: [String: Any]? 57 | 58 | /// Customer with customers information 59 | var customer: Customer? // request required 60 | /// Schedule with subscription schedule information 61 | var schedule: Schedule? // request required 62 | 63 | private init(id: String?, amount: Float, currency: String, description: String?, reference: String?, token: String?, customerId: String?, schedule: Schedule?, customer: Customer?) { 64 | self.id = id 65 | self.amount = amount 66 | self.currency = currency 67 | self.description = description 68 | self.reference = reference 69 | self.token = token 70 | self.customerId = customerId 71 | self.schedule = schedule 72 | self.customer = customer 73 | } 74 | 75 | /// init for one-time token request 76 | init(amount: Float, currency: String, reference: String?, description: String?, token: String, schedule: Schedule ) { 77 | self.init(id: nil, amount: amount, currency: currency, description: description, reference: reference, token: token, customerId: nil, schedule: schedule, customer: nil) 78 | } 79 | 80 | /// init for Subscription with customer and payment source 81 | init(amount: Float, currency: String, reference: String?, description: String?, customer: Customer, schedule: Schedule) { 82 | self.init(id: nil, amount: amount, currency: currency, description: description, reference: reference, token: nil, customerId: nil, schedule: schedule, customer: customer) 83 | } 84 | 85 | /// init for Subscription with customer id 86 | init(amount: Float, currency: String, reference: String?, description: String?, customerId: String, schedule: Schedule ) { 87 | self.init(id: nil, amount: amount, currency: currency, description: description, reference: reference, token: nil, customerId: customerId, schedule: schedule, customer: nil) 88 | } 89 | 90 | /// init for updating subscription 91 | init(amount: Float, currency: String, reference: String?, description: String?, schedule: Schedule ) { 92 | self.init(id: nil, amount: amount, currency: currency, description: description, reference: reference, token: nil, customerId: nil, schedule: schedule, customer: nil) 93 | } 94 | 95 | init(json: Dictionary) throws { 96 | 97 | self.id = try? json.value(for: "_id") 98 | self.amount = try json.value(for: "amount") 99 | self.currency = try json.value(for: "currency") 100 | self.description = try? json.value(for: "description") 101 | self.reference = try? json.value(for: "reference") 102 | self.token = try? json.value(for: "token") 103 | self.createdAt = try? json.value(for: "created_at") 104 | self.updatedAt = try? json.value(for: "updated_at") 105 | self.status = try? json.value(for: "status") 106 | self.isArchived = try? json.value(for: "archived") 107 | self.customerId = try? json.value(for: "customer_id") 108 | self.paymentSourceId = try? json.value(for: "payment_source_id") 109 | self._v = try? json.value(for: "__v") 110 | self.gatewayType = try? json.value(for: "gateway_type") 111 | self.gatewayName = try? json.value(for: "gateway_name") 112 | self.companyId = try? json.value(for: "company_id") 113 | self.userId = try? json.value(for: "user_id") 114 | self.customer = try? json.valueMapable(for: "customer") 115 | self.schedule = try? json.valueMapable(for: "schedule") 116 | 117 | self.rawJson = json 118 | } 119 | 120 | public func toDictionary() -> [String : Any] { 121 | 122 | var param: [String: Any] = [ 123 | "amount": amount, 124 | "currency": currency ] 125 | param.appendNonNilable(key: "description", item: description) 126 | param.appendNonNilable(key: "reference", item: reference) 127 | param.appendNonNilable(key: "token", item: token) 128 | param.appendNonNilable(key: "customer_id", item: customerId) 129 | param.appendNonNilable(key: "payment_source_id", item: paymentSourceId) 130 | param.appendNonNilable(key: "gateway_type", item: gatewayType) 131 | param.appendNonNilable(key: "gateway_name", item: gatewayName) 132 | param.appendNonNilable(key: "gateway_mode", item: gatewayMode) 133 | param.appendNonNilable(key: "company_id", item: companyId) 134 | param.appendNonNilable(key: "user_id", item: userId) 135 | 136 | param.appendNonNilable(key: "customer", item: customer?.toDictionary()) 137 | param.appendNonNilable(key: "schedule", item: schedule?.toDictionary()) 138 | 139 | return param 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /PayDock/Models/Transaction/Refund.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Refund.swift 3 | // PayDock 4 | // 5 | // Created by Round Table Apps on 19/4/17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | 12 | public struct Refund: Mapable { 13 | public typealias Kind = Refund 14 | 15 | init(json: Dictionary) throws { 16 | self.id = try json.value(for: "_id") 17 | self.amount = try json.value(for: "amount") 18 | self.currency = try json.value(for: "currency") 19 | self.status = try json.value(for: "status") 20 | self.pendedAt = try json.value(for: "pended_at") 21 | self.createdAt = try? json.value(for: "created_at") 22 | self.serviceLogs = try? json.value(for: "service_logs") 23 | self.rawJson = json 24 | } 25 | 26 | public var id: String 27 | public var amount: String 28 | public var currency: String 29 | public var status: String 30 | public var pendedAt: Date? 31 | public var createdAt: Date? 32 | public var serviceLogs: [[String: Any]]? 33 | public var rawJson: [String: Any]? 34 | } 35 | -------------------------------------------------------------------------------- /PayDock/Models/Transaction/Sale.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Sale.swift 3 | // PayDock 4 | // 5 | // Created by Round Table Apps on 19/4/17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | 12 | public struct Sale: Mapable { 13 | public typealias Kind = Sale 14 | 15 | init(json: Dictionary) throws { 16 | self.id = try json.value(for: "_id") 17 | self.amount = try json.value(for: "amount") 18 | self.currency = try json.value(for: "currency") 19 | self.status = try json.value(for: "status") 20 | self.createdAt = try? json.value(for: "created_at") 21 | self.serviceLogs = try? json.value(for: "service_logs") 22 | self.rawJson = json 23 | } 24 | public var id: String 25 | public var amount: Float 26 | public var currency: String 27 | public var status: String 28 | public var createdAt: Date? 29 | public var serviceLogs: [[String: Any]]? 30 | public var rawJson: [String: Any]? 31 | 32 | } 33 | -------------------------------------------------------------------------------- /PayDock/Models/Transaction/Transaction.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Transaction.swift 3 | // PayDock 4 | // 5 | // Created by Round Table Apps on 19/4/17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | 12 | 13 | /// transaction model 14 | /// 15 | /// - sale: if Model is Sale 16 | /// - refund: if Model is Refund 17 | public enum Transaction: Mapable { 18 | case sale(value: Sale) 19 | case refund(value: Refund) 20 | public typealias Kind = Transaction 21 | init(json: Dictionary) throws { 22 | if let type: String = try? json.value(for: "type") { 23 | switch type { 24 | case "sale": 25 | let sale = try Sale(json: json) 26 | self = Transaction.sale(value: sale) 27 | return 28 | case "refund": 29 | let refund = try Refund(json: json) 30 | self = Transaction.refund(value: refund) 31 | return 32 | default: 33 | throw Errors.parsingFailed 34 | } 35 | } 36 | throw Errors.parsingFailed 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /PayDock/Networking/PayDockNetwork.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PayDockNetwork.swift 3 | // PayDock 4 | // 5 | // Created by Round Table Apps on 15/4/17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | typealias DataCompletion = (_ data: () throws -> Data) -> Void 12 | 13 | /// a protocol for implementing network requests for paydock API 14 | public protocol PayDockNetwork: class { 15 | 16 | /// base url for paydock api 17 | var url: String { get set } 18 | /// needed headers for each request to paydock (content-type, x-user-secret-key) 19 | var headerDictionary: [AnyHashable : Any]? { get set } 20 | /// https request for GET methods 21 | /// 22 | /// - parameter from: url string 23 | /// - parameter with: parameters for request 24 | /// - parameter completion: a closure which returns a throwable closure which returns data 25 | /// 26 | /// - parameter data : Data from http response 27 | /// 28 | /// ``` 29 | /// func get(from url: String, with parameters: [String : Any]?, completion: @escaping (_ data: () throws -> Data) -> Void) { 30 | /// completion { return data } 31 | /// //or 32 | /// completion { throw error } 33 | /// } 34 | /// ``` 35 | func get(from url: String, with parameters: [String : Any]?, completion: @escaping (_ data: () throws -> Data) -> Void) 36 | /// https request for POST methods 37 | /// 38 | /// - parameter from: url string 39 | /// - parameter with: parameters for request 40 | /// - parameter completion: a closure which returns a throwable closure which returns data 41 | /// 42 | /// - parameter data : Data from http response 43 | /// 44 | /// ``` 45 | /// func post(to url: String, with parameters: [String : Any]?, completion: @escaping (_ data: () throws -> Data) -> Void) { 46 | /// completion { return data } 47 | /// //or 48 | /// completion { throw error } 49 | /// } 50 | /// ``` 51 | func post(to url: String, with parameters: [String : Any]?, completion: @escaping (_ data: () throws -> Data) -> Void) 52 | /// https request for PUT methods 53 | /// 54 | /// - parameter from: url string 55 | /// - parameter with: parameters for request 56 | /// - parameter completion: a closure which returns a throwable closure which returns data 57 | /// 58 | /// - parameter data : Data from http response 59 | /// 60 | /// ``` 61 | /// func put(to url: String, with parameters: [String : Any]?, completion: @escaping (_ data: () throws -> Data) -> Void) { 62 | /// completion { return data } 63 | /// //or 64 | /// completion { throw error } 65 | /// } 66 | /// ``` 67 | func put(to url: String, with parameters: [String : Any]?, completion: @escaping (_ data: () throws -> Data) -> Void) 68 | /// https request for DELETE methods 69 | /// DELETE request should encode parameters inside url 70 | /// 71 | /// - parameter from: url string 72 | /// - parameter with: parameters for request 73 | /// - parameter completion: a closure which returns a throwable closure which returns data 74 | /// 75 | /// - parameter data : Data from http response 76 | /// 77 | /// ``` 78 | /// func delete(from url: String, with parameters: [String : Any]?, completion: @escaping (_ data: () throws -> Data) -> Void) { 79 | /// completion { return data } 80 | /// //or 81 | /// completion { throw error } 82 | /// } 83 | /// ``` 84 | func delete(from url: String, with parameters: [String : Any]?, completion: @escaping (_ data: () throws -> Data) -> Void) 85 | } 86 | 87 | 88 | extension PayDockNetwork { 89 | var url: String { 90 | get { 91 | return PayDock.shared.url 92 | } 93 | } 94 | 95 | var headerDictionary: [AnyHashable : Any]? { 96 | get { 97 | return [ 98 | "content-type" : "application/json", 99 | "x-user-secret-key" : "\(PayDock.shared.secretKey)" 100 | ] 101 | } 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /PayDock/PayDock.h: -------------------------------------------------------------------------------- 1 | // 2 | // PayDock.h 3 | // PayDock 4 | // 5 | // Created by Round Table Apps on 10/4/17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | @import Foundation; 10 | 11 | //! Project version number for PayDock. 12 | FOUNDATION_EXPORT double PayDockVersionNumber; 13 | 14 | //! Project version string for PayDock. 15 | FOUNDATION_EXPORT const unsigned char PayDockVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /PayDock/Services/ChargeServices.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ChargeServices.swift 3 | // PayDock 4 | // 5 | // Created by Round Table Apps on 18/4/17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /// Charge Services for SDK 12 | class ChargeServices { 13 | weak var network: PayDockNetwork? 14 | 15 | init(network: PayDockNetwork) { 16 | self.network = network 17 | } 18 | 19 | /// Create Charge request. ChargeRequest init will define which type of add-charge request is created. see ChargeRequest inits for more information 20 | /// 21 | /// - parameter with: ChargeRequest for charging 22 | /// - parameter completion: result on creating charge 23 | /// - parameter charge: a charge instance filled with server response 24 | func charge(with charge: ChargeRequest, completion: @escaping (_ result: @escaping () throws -> Charge) -> Void) { 25 | self.network?.post(to: Constants.charge, with: charge.toDictionary(), completion: { (result) in 26 | do { 27 | let data = try result() 28 | let json: [String: Any] = try data.getResource() 29 | let charge: Charge = try Charge(json: json) 30 | completion { return charge } 31 | } catch let error { 32 | completion { throw error } 33 | } 34 | }) 35 | } 36 | 37 | /// Get list of charges with parameter options. nil parameters will returns all charges for the account, limited to 100 records. 38 | /// 39 | /// - parameter with: optional parameters for filtering result 40 | /// - parameter completion: returns a closure which returns charges or throws error 41 | /// - paramter charges: charge items from server 42 | func getCharges(with parameters: ListParameters?, completion: @escaping (_ charges: @escaping () throws -> [Charge]) -> Void) { 43 | self.network?.get(from: Constants.charge, with: parameters?.toDictionary(), completion: { (result) in 44 | do { 45 | let data = try result() 46 | var charges: [Charge] = [] 47 | let json: [Dictionary] = try data.getResource() 48 | for object in json { 49 | charges.append( try Charge(json: object)) 50 | } 51 | completion {return charges } 52 | } catch let error { 53 | completion { throw error } 54 | } 55 | }) 56 | 57 | 58 | } 59 | /// Get specific charge detail 60 | /// 61 | /// - parameter with: Charge identifier 62 | /// - parameter completion: returns a closure which returns charge or throws error 63 | /// - paramter charge: charge item from server 64 | func getCharge(with id: String, completion: @escaping (_ charge: @escaping () throws -> Charge) -> Void) { 65 | let parameter: [String: Any] = ["_id" : id] 66 | self.network?.get(from: Constants.charge, with: parameter, completion: { (result) in 67 | do { 68 | let data = try result() 69 | let json: [String: Any] = try data.getResource() 70 | let charge: Charge = try Charge(json: json) 71 | completion { return charge } 72 | } catch let error { 73 | completion { throw error } 74 | } 75 | }) 76 | } 77 | 78 | /// request to refund a charge 79 | /// 80 | /// - parameter with: Charge identifier 81 | /// - parameter amount: amount of money to refund 82 | /// - parameter completion: returns a closure which returns charge or throws error 83 | /// - paramter charge: charge item from server 84 | func refundCharge(with id: String, amount: Float, completion: @escaping (_ charge: @escaping () throws -> Charge) -> Void) { 85 | let parameter: [String: Any] = ["_id" : id, "amount" : amount] 86 | self.network?.post(to: Constants.charge, with: parameter, completion: { (result) in 87 | do { 88 | let data = try result() 89 | let json: [String: Any] = try data.getResource() 90 | let charge: Charge = try Charge(json: json) 91 | completion { return charge } 92 | } catch let error { 93 | completion { throw error } 94 | } 95 | }) 96 | } 97 | 98 | /// Archive Charge to hide it it from charges list. You can still retrieve archived charges, see [Get charges list with parameters 99 | /// 100 | /// - parameter with: Charge identifier 101 | /// - parameter completion: returns a closure which returns charge or throws error 102 | /// - paramter charge: charge item from server 103 | func archiveCharge(with id: String, completion: @escaping (_ charge: @escaping () throws -> Charge) -> Void) { 104 | let url = Constants.charge + "/\(id)" 105 | self.network?.delete(from: url, with: nil, completion: { (result) in 106 | do { 107 | let data = try result() 108 | let json: [String: Any] = try data.getResource() 109 | let charge: Charge = try Charge(json: json) 110 | completion { return charge } 111 | } catch let error { 112 | completion { throw error } 113 | } 114 | }) 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /PayDock/Services/CustomerServices.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CustomerServices.swift 3 | // PayDock 4 | // 5 | // Created by Round Table Apps on 22/4/17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /// Customer Services 12 | class CustomerServices { 13 | weak var network: PayDockNetwork? 14 | var publicKey: String = "" 15 | 16 | init(network: PayDockNetwork) { 17 | self.network = network 18 | } 19 | 20 | init(network: PayDockNetwork, publicKey: String) { 21 | self.network = network 22 | self.publicKey = publicKey 23 | } 24 | 25 | /// add a customer with defualt payment source 26 | /// 27 | /// - parameter customer: customer request instance 28 | /// - parameter completion: returns a closure which returns customer or throws error 29 | /// - paramter customer: customer item from server 30 | func add(customer: CustomerRequest, completion: @escaping (_ result: @escaping () throws -> Customer) -> Void ) { 31 | network?.post(to: Constants.customers , with: customer.toDictionary(), completion: { (result) in 32 | do { 33 | let data = try result() 34 | let json: [String: Any] = try data.getResource() 35 | let customer: Customer = try Customer(json: json) 36 | completion { return customer } 37 | } catch let error { 38 | completion { throw error } 39 | } 40 | }) 41 | } 42 | 43 | /// get details for a customer 44 | /// 45 | /// - parameter with: customer's id 46 | /// - parameter completion: returns a closure which returns customer or throws error 47 | /// - paramter customer: customer item from server 48 | func getCustomer(with id: String, completion: @escaping (_ result: @escaping () throws -> Customer) -> Void) { 49 | let param: [String: Any] = [ "_id" : id] 50 | network?.get(from: Constants.customers, with: param, completion: { (result) in 51 | do { 52 | let data = try result() 53 | let json: [String: Any] = try data.getResource() 54 | let customer: Customer = try Customer(json: json) 55 | completion { return customer } 56 | } catch let error { 57 | completion { throw error } 58 | } 59 | }) 60 | } 61 | 62 | /// get list of customers from server 63 | /// 64 | /// - parameter with: filter properties 65 | /// - parameter completion: returns a closure which returns customers or throws error 66 | /// - paramter customer: customers item from server 67 | func getCustomers(with parameters: ListParameters?, completion: @escaping (_ charges: @escaping () throws -> [Customer]) -> Void) { 68 | network?.get(from: Constants.customers, with: parameters?.toDictionary(), completion: { (result) in 69 | do { 70 | let data = try result() 71 | var customers: [Customer] = [] 72 | let json: [Dictionary] = try data.getResource() 73 | for object in json { 74 | customers.append( try Customer(json: object)) 75 | } 76 | completion {return customers } 77 | } catch let error { 78 | completion { throw error } 79 | } 80 | }) 81 | } 82 | 83 | /// get list of cusomers Payment sources 84 | /// 85 | /// - parameter with: filter properties 86 | /// - parameter completion: returns a closure which returns customers or throws error 87 | /// - paramter customer: customers item from server 88 | func getCustomerPaymentSources(with parameters: ListParameters?, completion: @escaping (_ paymentSources: @escaping () throws -> [PaymentSource]) -> Void) { 89 | let relativeUrl = Constants.paymentSources + "?public_key=\(publicKey)" 90 | network?.get(from: relativeUrl, with: parameters?.toDictionary(), completion: { (result) in 91 | do { 92 | let data = try result() 93 | var paymentSources: [PaymentSource] = [] 94 | let json: [Dictionary] = try data.getResource() 95 | for object in json { 96 | paymentSources.append( try PaymentSource(json: object)) 97 | } 98 | completion {return paymentSources } 99 | } catch let error { 100 | completion { throw error } 101 | } 102 | }) 103 | } 104 | 105 | /// updates the customer's detail 106 | /// 107 | /// - parameter with: customer id 108 | /// - parameter customer: customer request instance 109 | /// - parameter completion: returns a closure which returns customer or throws error 110 | /// - paramter customer: customer item from server 111 | func updateCustomer(with id: String, customer: CustomerRequest, completion: @escaping (_ subscription: @escaping () throws -> Customer) -> Void) { 112 | let url = Constants.customers + "/" + id 113 | network?.put(to: url, with: customer.toDictionary(), completion: { (result) in 114 | do { 115 | let data = try result() 116 | let json: [String: Any] = try data.getResource() 117 | let customer: Customer = try Customer(json: json) 118 | completion { return customer } 119 | } catch let error { 120 | completion { throw error } 121 | } 122 | }) 123 | } 124 | 125 | /// archive a customer 126 | /// 127 | /// - parameter with: customer id 128 | /// - parameter completion: returns a closure which returns customer or throws error 129 | /// - paramter customer: customer item from server 130 | func archiveCustomer(with id: String, completion: @escaping (_ result: @escaping () throws -> Customer) -> Void) { 131 | let param: [String: Any] = [ "_id" : id] 132 | network?.delete(from: Constants.customers, with: param, completion: { (result) in 133 | do { 134 | let data = try result() 135 | let json: [String: Any] = try data.getResource() 136 | let customer: Customer = try Customer(json: json) 137 | completion { return customer } 138 | } catch let error { 139 | completion { throw error } 140 | } 141 | }) 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /PayDock/Services/ExternalCheckoutServices.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ExternalCheckoutServices.swift 3 | // PayDock 4 | // 5 | // Created by Oleksandr Omelchenko on 13.08.17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | 12 | /// External Checkout Services 13 | class ExternalCheckoutServices { 14 | weak var network: PayDockNetwork? 15 | 16 | init(network: PayDockNetwork) { 17 | self.network = network 18 | } 19 | 20 | /// create a checkout url object 21 | /// 22 | /// - parameter customer: external checkout request instance 23 | /// - parameter completion: returns a closure which returns checkout or throws error 24 | /// - parameter customer: checkout item from server 25 | func create(externalCheckout: ExternalCheckoutRequest, completion: @escaping (_ result: @escaping () throws -> ExternalCheckout) -> Void ) { 26 | self.network?.post(to: Constants.externalCheckout , with: externalCheckout.toDictionary(), completion: { (result) in 27 | do { 28 | let data = try result() 29 | let json: [String: Any] = try data.getResource() 30 | let externalCheckout: ExternalCheckout = try ExternalCheckout(json: json) 31 | completion { return externalCheckout } 32 | } catch let error { 33 | completion { throw error } 34 | } 35 | }) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /PayDock/Services/SubscriptionServices.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SubscriptionService.swift 3 | // PayDock 4 | // 5 | // Created by Round Table Apps on 4/19/17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /// Subscription Services 12 | class SubscriptionServices { 13 | weak var network: PayDockNetwork? 14 | 15 | init(network: PayDockNetwork) { 16 | self.network = network 17 | } 18 | 19 | /// Create Subscription request. Subscription init will define which type of add-subscription request is created. see subscription inits for more information 20 | /// 21 | /// - parameter subscription: one-time Token parameter model 22 | /// - parameter completion: result on creating subscription 23 | /// - parameter result: test 24 | func create(subscription: SubscriptionRequest, completion: @escaping (_ result: @escaping () throws -> Subscription) -> Void) { 25 | self.network?.post(to: Constants.subscription, with: subscription.toDictionary(), completion: { (result) in 26 | do { 27 | let data = try result() 28 | let json: [String: Any] = try data.getResource() 29 | let subscription: Subscription = try Subscription(json: json) 30 | completion { return subscription } 31 | } catch let error { 32 | completion { throw error } 33 | } 34 | }) 35 | } 36 | 37 | /// Update subscription details 38 | /// 39 | /// - parameter subscription: SubscriptionRequest parameter model 40 | /// - parameter with: subscription identifier 41 | /// - parameter completion: returns a closure which returns subscription or throws error 42 | /// - paramter subscription: subscription item from server 43 | func update(subscription: SubscriptionRequest, with id: String, completion: @escaping (_ subscription: @escaping () throws -> Subscription) -> Void) { 44 | let relativeUrl = Constants.subscription + "/\(id)" 45 | self.network?.post(to: relativeUrl, with: subscription.toDictionary(), completion: { (result) in 46 | do { 47 | let data = try result() 48 | let json: [String: Any] = try data.getResource() 49 | let subscription: Subscription = try Subscription(json: json) 50 | completion { return subscription } 51 | } catch let error { 52 | completion { throw error } 53 | } 54 | }) 55 | } 56 | 57 | /// Get list of subscriptions with parameter options. nil parameters will returns all subscriptions for the account, limited to 100 records. 58 | /// 59 | /// - parameter with: optional parameters for filtering result 60 | /// - parameter completion: returns a closure which returns subscription or throws error 61 | /// - paramter subscriptions: Subscription items from server 62 | func getSubscriptions(with parameters: ListParameters?, completion: @escaping (_ subscriptions: @escaping () throws -> [Subscription]) -> Void) { 63 | self.network?.get(from: Constants.subscription, with: parameters?.toDictionary(), completion: { (result) in 64 | do { 65 | let data = try result() 66 | var subscriptions: [Subscription] = [] 67 | let json: [Dictionary] = try data.getResource() 68 | for object in json { 69 | subscriptions.append( try Subscription(json: object)) 70 | } 71 | completion { return subscriptions } 72 | } catch let error { 73 | completion { throw error } 74 | } 75 | }) 76 | 77 | 78 | } 79 | 80 | /// Get specific subscription detail 81 | /// 82 | /// - parameter with: Subscription identifier 83 | /// - parameter completion: returns a closure which returns subscription or throws error 84 | /// - paramter subscription: subscription item from server 85 | func getSubscription(with id: String, completion: @escaping (_ subscription: @escaping () throws -> Subscription) -> Void) { 86 | let parameter: [String: Any] = ["_id" : id] 87 | self.network?.get(from: Constants.subscription, with: parameter, completion: { (result) in 88 | do { 89 | let data = try result() 90 | let json: [String: Any] = try data.getResource() 91 | let subscription: Subscription = try Subscription(json: json) 92 | completion { return subscription } 93 | } catch let error { 94 | completion { throw error } 95 | } 96 | }) 97 | } 98 | 99 | /// Delete specific subscription 100 | /// 101 | /// - parameter with: Subscription identifier 102 | /// - parameter completion: returns a closure which returns subscription or throws error 103 | /// - paramter subscription: subscription item from server 104 | func deleteSubscription(with id: String, completion: @escaping (_ subscription: @escaping () throws -> Subscription) -> Void) { 105 | let parameter: [String: Any] = ["_id" : id] 106 | self.network?.delete(from: Constants.subscription, with: parameter, completion: { (result) in 107 | do { 108 | let data = try result() 109 | let json: [String: Any] = try data.getResource() 110 | let subscription: Subscription = try Subscription(json: json) 111 | completion { return subscription } 112 | } catch let error { 113 | completion { throw error } 114 | } 115 | }) 116 | } 117 | 118 | 119 | } 120 | -------------------------------------------------------------------------------- /PayDock/Services/TokenServices.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TokenServices.swift 3 | // PayDock 4 | // 5 | // Created by Round Table Apps on 4/22/17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | 12 | /// Token Services 13 | class TokenServices { 14 | weak var network: PayDockNetwork? 15 | var publicKey: String 16 | 17 | init(network: PayDockNetwork, publicKey: String) { 18 | self.network = network 19 | self.publicKey = publicKey 20 | } 21 | 22 | /// Create One-time token request. It is a disposable token for creating charges/subscriptions/customers or updating customers. 23 | /// 24 | /// - parameter token: TokenRequest which is including customer details and paymentSource details 25 | /// - parameter completion: Result on creating token 26 | /// - parameter result: A token as a string 27 | public func create(token: TokenRequest, completion: @escaping (_ result: @escaping () throws -> String) -> Void) { 28 | let relativeUrl = Constants.token + "?public_key=\(publicKey)" 29 | self.network?.post(to: relativeUrl, with: token.toDictionary(), completion: { (result) in 30 | do { 31 | let data = try result() 32 | let token: String = try data.getResource() 33 | completion { return token } 34 | } catch let error { 35 | completion { throw error } 36 | } 37 | }) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /PayDock/VaultViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // VaultViewController.swift 3 | // PayDock 4 | // 5 | // Created by Oleksandr Omelchenko on 12.11.17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class VaultViewController: UIViewController,UITableViewDelegate,UITableViewDataSource { 12 | 13 | @IBOutlet weak var tableView: UITableView! 14 | 15 | // MARK:- variable 16 | var paymentSource :[PaymentSource]? 17 | 18 | //MARK:-lifecycle 19 | override func viewDidLoad() { 20 | super.viewDidLoad() 21 | tableView.delegate = self 22 | tableView.dataSource = self 23 | // Do any additional setup after loading the view. 24 | } 25 | 26 | override func didReceiveMemoryWarning() { 27 | super.didReceiveMemoryWarning() 28 | // Dispose of any resources that can be recreated. 29 | } 30 | //MARK:- Table function 31 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 32 | let cell = self.tableView.dequeueReusableCell(withIdentifier: "CustomCellTableViewCell") as! CustomCellTableViewCell 33 | var itemDictionary = paymentSource?[indexPath.row].toDictionary() 34 | if itemDictionary != nil{ 35 | if let primary = itemDictionary!["primary"] as? Bool{ 36 | if primary == true { 37 | let frameworkBundle = Bundle(for: type(of: self)) 38 | let image = UIImage(named: "icTick", in: frameworkBundle , compatibleWith: nil) 39 | cell.primaryImg.image = image 40 | }else{ 41 | let frameworkBundle = Bundle(for: type(of: self)) 42 | let image = UIImage(named: "", in: frameworkBundle , compatibleWith: nil) 43 | cell.primaryImg.image = image 44 | } 45 | } 46 | if itemDictionary!["type"] as!String == "bsb"{ 47 | if let accountNumber = itemDictionary!["account_number"] as? String 48 | { 49 | cell.numberLabel.text = accountNumber 50 | } 51 | if let accountName = itemDictionary!["account_name"] as? String { 52 | print("accountname\(accountName)") 53 | cell.nameLabel.text = accountName 54 | } 55 | let frameworkBundle = Bundle(for: type(of: self)) 56 | let image = UIImage(named: "icBank" , in: frameworkBundle , compatibleWith: nil) 57 | cell.typeImg.image = image 58 | }else{ //card 59 | if let scheme = itemDictionary!["card_scheme"] as? String 60 | { 61 | let cardName = ["visa","mastercard","amex","diners" ,"cup"] 62 | let cardimg = ["icvisa","icmastercard","icamex","icdiners","iccup"] 63 | let frameworkBundle = Bundle(for: type(of: self)) 64 | var flag = false 65 | for i in 0 ..< cardName.count{ 66 | if scheme == cardName[i] { //fill imageview with suitable card 67 | let image = UIImage(named: cardimg[i], in: frameworkBundle , compatibleWith: nil) 68 | cell.typeImg.image = image 69 | flag = true 70 | } 71 | } 72 | if flag == false{ 73 | let image = UIImage(named: "icdefault", in: frameworkBundle , compatibleWith: nil) 74 | cell.typeImg.image = image 75 | } 76 | } 77 | if let last4number = itemDictionary!["card_number_last4"] as? String{ 78 | cell.numberLabel.text = last4number 79 | } 80 | if let accountName = itemDictionary!["card_name"] as? String{ 81 | cell.nameLabel.text = accountName 82 | } 83 | } 84 | } 85 | return cell 86 | } 87 | func numberOfSections(in tableView: UITableView) -> Int { 88 | return 1 89 | } 90 | func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { 91 | return 100 92 | } 93 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 94 | return (paymentSource?.count)! 95 | } 96 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 97 | var itemDictionary = paymentSource?[indexPath.row].toDictionary() 98 | 99 | if itemDictionary != nil{ 100 | if let paymentSourceId = itemDictionary!["id"] as? String{ 101 | print("payment_source_id \(paymentSourceId)") 102 | } 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /PayDockTests/ChargeIntergrationTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PayDockTests.swift 3 | // PayDockTests 4 | // 5 | // Created by Round Table Apps on 10/4/17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import PayDock 11 | 12 | class PayDockChargeTests: XCTestCase { 13 | 14 | 15 | let chargeId: String = "58fdc65674bff715308237be" 16 | var archiveChargeId: String = "58fdc65674bff715308237be" 17 | let gatewayId: String = "58fdaffc74bff7153082359d" 18 | let cardGatewayId: String = "5620de31361b787230cb7d74" 19 | let customerId: String = "58fde04c74bff71530823818" 20 | 21 | 22 | override func setUp() { 23 | super.setUp() 24 | PayDock.setSecretKey(key: "73067bb83e485b1db4f376025c38ab103d477e66") 25 | PayDock.setPublicKey(key: "1b0496942b784d96b660d01542aa0ceba45dd9e9") 26 | PayDock.shared.isSandbox = true 27 | } 28 | 29 | override func tearDown() { 30 | super.tearDown() 31 | } 32 | 33 | 34 | 35 | ///add charge with credit card 36 | func testAddChargeWithCreditCard() { 37 | let address = Address(line1: "123 Forest Road", line2: nil, city: "Sydney", postcode: "1234", state: "NSW", country: "AUS") 38 | let card = Card(gatewayId: cardGatewayId, name: "Robert Davies", number: "5520000000000000", expireMonth: 12, expireYear: 18, ccv: "123", address: address) 39 | let paymentSource = PaymentSource.card(value: card) 40 | let customerRequest = CustomerRequest(firstName: "Justin", lastName: "James", email: "Test@test.com", reference: nil, phone: nil, paymentSource: paymentSource) 41 | let chargeRequest = ChargeRequest(amount: 10, currency: "AUD", reference: nil, description: "some charge description", customer: customerRequest) 42 | let expect = expectation(description: "PayDockSDK.ChargeTest") 43 | PayDock.shared.add(charge: chargeRequest, completion: { (charge) in 44 | defer { expect.fulfill() } 45 | do { 46 | let charge = try charge() 47 | debugPrint(charge) 48 | self.archiveChargeId = charge.id! 49 | } catch let error { 50 | debugPrint(error) 51 | XCTFail(error.localizedDescription) 52 | } 53 | }) 54 | self.waitForExpectations(timeout: 1000, handler: nil) 55 | } 56 | 57 | /// add charge with bank account 58 | func testAddChargeWithBankAccount() { 59 | let address = Address(line1: "one", line2: "two", city: "city", postcode: "1234", state: "state", country: "AU") 60 | let account = BankAccount(gatewayId: gatewayId, accountNumber: "411111111111111",accountName: "Test User", bankName: "Bank of Australia", accountRouting: "123123", holderType: "personal", address: address, type: "savings") 61 | let paymentSource = PaymentSource.bankAccount(value: account) 62 | let customerRequest = CustomerRequest(firstName: "Promise name", lastName: "Promise last name", email: "Test@test.com", reference: "AUS", phone: nil, paymentSource: paymentSource) 63 | let chargeRequest = ChargeRequest(amount: 10, currency: "AUD", reference: "some charge reference", description: "some charge description", customer: customerRequest) 64 | let expect = expectation(description: "PayDockSDK.ChargeTest") 65 | PayDock.shared.add(charge: chargeRequest, completion: { (charge) in 66 | defer { expect.fulfill() } 67 | do { 68 | let charge = try charge() 69 | debugPrint(charge) 70 | self.archiveChargeId = charge.id! 71 | } catch let error { 72 | debugPrint(error) 73 | XCTFail(error.localizedDescription) 74 | } 75 | }) 76 | self.waitForExpectations(timeout: 1000, handler: nil) 77 | } 78 | 79 | /// add charge with customer id 80 | func testAddChargeWithCustomerId() { 81 | let expect = expectation(description: "PayDockSDK.ChargeTest") 82 | let request = ChargeRequest(amount: 100, currency: "AUD", reference: nil, description: nil, customerId: customerId) 83 | PayDock.shared.add(charge: request) { (charge) in 84 | defer { expect.fulfill() } 85 | do { 86 | let charge = try charge() 87 | debugPrint(charge) 88 | } catch let error { 89 | debugPrint(error.localizedDescription) 90 | XCTFail(error.localizedDescription) 91 | } 92 | } 93 | self.waitForExpectations(timeout: 1000, handler: nil) 94 | } 95 | 96 | func testGetAllCharges() { 97 | let expect = expectation(description: "PayDockSDK.ChargeTest") 98 | PayDock.shared.getCharges(with: nil) { (result) in 99 | defer { expect.fulfill() } 100 | do { 101 | let charges = try result() 102 | debugPrint(charges) 103 | 104 | } catch let error { 105 | print(error) 106 | XCTFail(error.localizedDescription) 107 | } 108 | 109 | } 110 | self.waitForExpectations(timeout: 1000, handler: nil) 111 | } 112 | 113 | 114 | func testGetCharge() { 115 | let expect = expectation(description: "PayDockSDK.ChargeTest") 116 | PayDock.shared.getCharge(with: chargeId) { (charge) in 117 | defer { expect.fulfill() } 118 | do { 119 | let charge = try charge() 120 | debugPrint(charge) 121 | 122 | } catch let error { 123 | print(error) 124 | XCTFail(error.localizedDescription) 125 | } 126 | } 127 | self.waitForExpectations(timeout: 1000, handler: nil) 128 | } 129 | 130 | func testArchiveCharge() { 131 | let expect = expectation(description: "PayDockSDK.ChargeTest") 132 | PayDock.shared.archiveCharge(with: archiveChargeId) { (charge) in 133 | defer { expect.fulfill() } 134 | do { 135 | let charge = try charge() 136 | debugPrint(charge) 137 | 138 | } catch let error { 139 | print(error) 140 | XCTFail(error.localizedDescription) 141 | } 142 | } 143 | self.waitForExpectations(timeout: 1000, handler: nil) 144 | 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /PayDockTests/CustomerIntegrationTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PayDockCustomerTests.swift 3 | // PayDock 4 | // 5 | // Created by Round Table Apps on 24/4/17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import PayDock 11 | 12 | class PayDockCustomerTests: XCTestCase { 13 | 14 | let gatewayId: String = "58fdaffc74bff7153082359d" 15 | let customerId: String = "58fde04c74bff71530823818" 16 | 17 | override func setUp() { 18 | super.setUp() 19 | PayDock.setSecretKey(key: "73067bb83e485b1db4f376025c38ab103d477e66") 20 | PayDock.setPublicKey(key: "1b0496942b784d96b660d01542aa0ceba45dd9e9") 21 | PayDock.shared.isSandbox = true 22 | } 23 | 24 | override func tearDown() { 25 | super.tearDown() 26 | } 27 | 28 | 29 | func testAddCustomer() { 30 | let expect = expectation(description: "PayDockSDK.CustomerTest") 31 | let address = Address(line1: "one", line2: "two", city: "city", postcode: "1234", state: "state", country: "AU") 32 | let account = BankAccount(gatewayId: gatewayId, accountNumber: "411111111111111",accountName: "Test User", bankName: "Bank of Australia", accountRouting: "123123", holderType: "personal", address: address, type: "savings") 33 | let paymentSource = PaymentSource.bankAccount(value: account) 34 | let customerRequest = CustomerRequest(firstName: "Promise name", lastName: "Promise last name", email: "Test@test.com", reference: "AUS", phone: nil, paymentSource: paymentSource) 35 | 36 | PayDock.shared.add(customer: customerRequest) { (customer) in 37 | defer { expect.fulfill() } 38 | do { 39 | let customer = try customer() 40 | debugPrint(customer) 41 | } catch let error { 42 | debugPrint(error.localizedDescription) 43 | XCTFail(error.localizedDescription) 44 | } 45 | } 46 | 47 | self.waitForExpectations(timeout: 1000, handler: nil) 48 | 49 | } 50 | 51 | func testGetCustomers() { 52 | let expect = expectation(description: "PayDockSDK.CustomerTest") 53 | PayDock.shared.getCustomers(with: nil) { (customers) in 54 | defer { expect.fulfill() } 55 | do { 56 | let customers = try customers() 57 | debugPrint(customers) 58 | } catch let error { 59 | debugPrint(error) 60 | XCTFail(error.localizedDescription) 61 | } 62 | } 63 | self.waitForExpectations(timeout: 1000, handler: nil) 64 | } 65 | 66 | func testGetCustomerItem() { 67 | let expect = expectation(description: "PayDockSDK.CustomerTest") 68 | PayDock.shared.getCustomer(with: customerId) { (customer) in 69 | defer { expect.fulfill() } 70 | do { 71 | let customer = try customer() 72 | debugPrint(customer) 73 | } catch let error { 74 | debugPrint(error) 75 | XCTFail(error.localizedDescription) 76 | } 77 | } 78 | self.waitForExpectations(timeout: 1000, handler: nil) 79 | } 80 | 81 | 82 | 83 | 84 | } 85 | -------------------------------------------------------------------------------- /PayDockTests/Demo_app_swift/Demo_app_swift-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | 5 | #import "CardIO/CardIO.h" 6 | -------------------------------------------------------------------------------- /PayDockTests/Demo_app_swift/Demo_app_swift/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // Demo_app_swift 4 | // 5 | // Created by Oleksandr Omelchenko on 18.10.17. 6 | // Copyright © 2017 Oleksandr Omelchenko. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /PayDockTests/Demo_app_swift/Demo_app_swift/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /PayDockTests/Demo_app_swift/Demo_app_swift/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /PayDockTests/Demo_app_swift/Demo_app_swift/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /PayDockTests/Demo_app_swift/Demo_app_swift/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /PayDockTests/Demo_app_swift/Settings.bundle/Root.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | StringsTable 6 | Root 7 | PreferenceSpecifiers 8 | 9 | 10 | Type 11 | PSGroupSpecifier 12 | Title 13 | About 14 | 15 | 16 | Type 17 | PSChildPaneSpecifier 18 | Title 19 | Acknowledgements 20 | File 21 | acknowledgments 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /PayDockTests/Demo_app_swift/Settings.bundle/acknowledgments.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | StringsTable 6 | Root 7 | PreferenceSpecifiers 8 | 9 | 10 | Type 11 | PSGroupSpecifier 12 | Title 13 | version 1.0 14 | FooterText 15 | This app uses the following software under the following license Agreements 16 | 17 | Copyright (C) 2012, Georg Kitz, @gekitz 18 | 19 | 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: 20 | 21 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 22 | 23 | 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. 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /PayDockTests/Demo_app_swift/Settings.bundle/en.lproj/Root.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PayDock/paydock_ios_sdk/29052dd731ddc0370da9f0da10a6665bf82d1dff/PayDockTests/Demo_app_swift/Settings.bundle/en.lproj/Root.strings -------------------------------------------------------------------------------- /PayDockTests/ExternalCheckoutTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ExternalCheckoutTests.swift 3 | // PayDock 4 | // 5 | // Created by Oleksandr Omelchenko on 13.08.17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import PayDock 11 | 12 | class PayDockExternalCheckoutTest: XCTestCase { 13 | 14 | let gatewayId: String = "5620de31361b787230cb7d74" 15 | 16 | override func setUp() { 17 | super.setUp() 18 | PayDock.setSecretKey(key: "73067bb83e485b1db4f376025c38ab103d477e66") 19 | PayDock.setPublicKey(key: "1b0496942b784d96b660d01542aa0ceba45dd9e9") 20 | PayDock.shared.isSandbox = true 21 | } 22 | 23 | override func tearDown() { 24 | super.tearDown() 25 | } 26 | 27 | func testCreateCheckout() { 28 | let expect = expectation(description: "PayDockSDK.ExternalCheckoutTest") 29 | let externalCheckout = ExternalCheckoutRequest(mode: "test", gatewayId: gatewayId, successRedirectUrl: "http://google.com", errorRedirectUrl: "http://google.com", description: "some description here") 30 | PayDock.shared.create(externalCheckout: externalCheckout) { (checkout) in 31 | defer { expect.fulfill() } 32 | do { 33 | let checkout = try checkout() 34 | debugPrint(checkout) 35 | } catch Errors.serverError(let message, let details, let httpStatus){ 36 | let statusString = String(httpStatus) 37 | XCTFail("Api error http status: \(statusString) \n Error message: \(message) \n Error details: \(String(describing: details))") 38 | 39 | 40 | } catch let error { 41 | debugPrint(error) 42 | 43 | XCTFail(error.localizedDescription) 44 | 45 | } 46 | } 47 | self.waitForExpectations(timeout: 1000, handler: nil) 48 | } 49 | 50 | 51 | 52 | 53 | } 54 | -------------------------------------------------------------------------------- /PayDockTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | NSCameraUsageDescription 22 | To scan credit cards 23 | 24 | 25 | -------------------------------------------------------------------------------- /PayDockTests/PayDockSessionTests.swift: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // PayDockSessionTests.swift 4 | // PayDock 5 | // 6 | // Created by Round Table Apps on 29/4/17. 7 | // Copyright © 2017 PayDock. All rights reserved. 8 | // 9 | 10 | import XCTest 11 | @testable import PayDock 12 | 13 | class PayDockSessionTests: XCTestCase { 14 | 15 | let payDockSession = PayDockSession() 16 | 17 | override func setUp() { 18 | super.setUp() 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | override func tearDown() { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | super.tearDown() 25 | } 26 | 27 | 28 | func testUrlEncoder() { 29 | let url = URL(string: "www.apple.com?test=456")! 30 | let params: [String: Any] = [ "ids": [1,2,3,4,5,6], 31 | "someText": "!@#$%^&**)([] Sometext", 32 | "someObject": [ 33 | "name": "somebody" 34 | ] 35 | ] 36 | let encodedUrl = payDockSession.encodeParametersToUrl(url: url, parameters: params) 37 | XCTAssertNotNil(encodedUrl, "result is nil") 38 | debugPrint(encodedUrl ?? "encodedURLDefaultvalue") 39 | 40 | } 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /PayDockTests/SubscriptionIntegrationTest.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PayDockSubscriptionTest.swift 3 | // PayDock 4 | // 5 | // Created by Round Table Apps on 26/4/17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import PayDock 11 | class PayDockSubscriptionTest: XCTestCase { 12 | 13 | let gatewayId: String = "58fdaffc74bff7153082359d" 14 | let subscriptionId: String = "5900525674bff71530823f5d" 15 | 16 | override func setUp() { 17 | super.setUp() 18 | PayDock.setSecretKey(key: "73067bb83e485b1db4f376025c38ab103d477e66") 19 | PayDock.setPublicKey(key: "1b0496942b784d96b660d01542aa0ceba45dd9e9") 20 | PayDock.shared.isSandbox = true 21 | } 22 | 23 | override func tearDown() { 24 | super.tearDown() 25 | } 26 | 27 | func testCreateSubscriptionWithCustomer() { 28 | let expect = expectation(description: "PayDockSDK.SubscriptionTest") 29 | let schedule = Schedule(interval: "day", frequency: 7, startDate: nil, endDate: nil, endAmountAfter: nil, endAmountBefore: nil, endAmountTotal: nil, endTransactions: nil) 30 | let address = Address(line1: "one", line2: "two", city: "city", postcode: "1234", state: "state", country: "AU") 31 | let account = BankAccount(gatewayId: gatewayId, accountNumber: "411111111111111",accountName: "Test User", bankName: "Bank of Australia", accountRouting: "123123", holderType: "personal", address: address, type: "savings") 32 | let paymentSource = PaymentSource.bankAccount(value: account) 33 | let customerRequest = CustomerRequest(firstName: "Promise name", lastName: "Promise last name", email: "Test@test.com", reference: "AUS", phone: nil, paymentSource: paymentSource) 34 | let subscriptionRequest = SubscriptionRequest(amount: 1, currency: "AUD", reference: "ref", description: "desc", customer: customerRequest, schedule: schedule) 35 | PayDock.shared.add(subscription: subscriptionRequest) { (sub) in 36 | defer { expect.fulfill() } 37 | do { 38 | let sub = try sub() 39 | debugPrint(sub) 40 | } catch let error { 41 | debugPrint(error.localizedDescription) 42 | XCTFail(error.localizedDescription) 43 | } 44 | } 45 | self.waitForExpectations(timeout: 1000, handler: nil) 46 | 47 | } 48 | 49 | func testGetSubscriptions() { 50 | let expect = expectation(description: "PayDockSDK.SubscriptionTest") 51 | PayDock.shared.getsubscriptions(with: nil) { (subs) in 52 | defer { expect.fulfill() } 53 | do { 54 | let subs = try subs() 55 | print(subs) 56 | } catch let error { 57 | debugPrint(error.localizedDescription) 58 | XCTFail(error.localizedDescription) 59 | } 60 | } 61 | self.waitForExpectations(timeout: 1000, handler: nil) 62 | } 63 | 64 | func testGetSubscription() { 65 | let expect = expectation(description: "PayDockSDK.SubscriptionTest") 66 | PayDock.shared.getSubscription(with: subscriptionId) { (sub) in 67 | defer { expect.fulfill() } 68 | do { 69 | let sub = try sub() 70 | debugPrint(sub) 71 | } catch let error { 72 | debugPrint(error.localizedDescription) 73 | XCTFail(error.localizedDescription) 74 | } 75 | } 76 | self.waitForExpectations(timeout: 1000, handler: nil) 77 | } 78 | 79 | func testUpdateSubscription() { 80 | let expect = expectation(description: "PayDockSDK.SubscriptionTest") 81 | let schedule = Schedule(interval: "month", frequency: 7, startDate: Date(), endDate: nil, endAmountAfter: nil, endAmountBefore: nil, endAmountTotal: nil, endTransactions: nil) 82 | let address = Address(line1: "one", line2: "two", city: "city", postcode: "1234", state: "state", country: "AU") 83 | let account = BankAccount(gatewayId: gatewayId, accountNumber: "411111111111111",accountName: "Test User", bankName: "Bank of Australia", accountRouting: "123123", holderType: "personal", address: address, type: "savings") 84 | let paymentSource = PaymentSource.bankAccount(value: account) 85 | let customerRequest = CustomerRequest(firstName: "Promise name", lastName: "Promise last name", email: "Test@test.com", reference: "AUS", phone: nil, paymentSource: paymentSource) 86 | let subscriptionRequest = SubscriptionRequest(amount: 1, currency: "AUD", reference: "ref", description: "desc", customer: customerRequest, schedule: schedule) 87 | PayDock.shared.update(subscription: subscriptionRequest, for: "5900525674bff71530823f5d") { (sub) in 88 | defer { expect.fulfill() } 89 | do { 90 | let sub = try sub() 91 | debugPrint(sub) 92 | } catch let error { 93 | debugPrint(error) 94 | XCTFail(error.localizedDescription) 95 | } 96 | } 97 | self.waitForExpectations(timeout: 1000, handler: nil) 98 | } 99 | 100 | 101 | 102 | 103 | 104 | } 105 | -------------------------------------------------------------------------------- /PayDockTests/TokenIntegrationTest.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PayDockTokenTest.swift 3 | // PayDock 4 | // 5 | // Created by Round Table Apps on 26/4/17. 6 | // Copyright © 2017 PayDock. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import PayDock 11 | 12 | class PayDockTokenTest: XCTestCase { 13 | 14 | let gatewayId: String = "58b60d8a6da7e425d6e4f6c7" 15 | 16 | override func setUp() { 17 | super.setUp() 18 | PayDock.setSecretKey(key: "") 19 | PayDock.setPublicKey(key: "8b2dad5fcf18f6f504685a46af0df82216781f3b") 20 | PayDock.shared.isSandbox = true 21 | } 22 | 23 | override func tearDown() { 24 | super.tearDown() 25 | } 26 | 27 | func testGetToken() { 28 | let expect = expectation(description: "PayDockSDK.TokenTest") 29 | let cardGatewayId: String = "58b60d8a6da7e425d6e4f6c7" 30 | let customerRequest = CustomerRequest(firstName: "Test_first_name", lastName: "Test_last_name", email: "Test@test.com", reference: "customer Refrence", phone: nil) 31 | let address = Address(line1: "one", line2: "two", city: "city", postcode: "1234", state: "state", country: "AU") 32 | // let account = BankAccount(gatewayId: gatewayId, accountNumber: "411111111111111",accountName: "Test User", bankName: "Bank of Australia", accountRouting: "123123", holderType: "personal", address: address, type: "savings") 33 | // let paymentSource = PaymentSource.bankAccount(value: account) 34 | // let customerRequest = CustomerRequest(firstName: "Promise name", lastName: "Promise last name", email: "Test@test.com", reference: "AUS", phone: nil, paymentSource: paymentSource) 35 | let card = Card(gatewayId: cardGatewayId, name: "mark", number: "4444333322221111", expireMonth: 5, expireYear: 18, ccv: "123", address: address) 36 | let paymentSource = PaymentSource.card(value: card) 37 | let tokenRequest = TokenRequest(customer: customerRequest, address: address, paymentSource: paymentSource) 38 | PayDock.shared.create(token: tokenRequest) { (token) in 39 | defer { expect.fulfill() } 40 | do { 41 | let token: String = try token() 42 | print(token) 43 | } catch let error { 44 | debugPrint(error.localizedDescription) 45 | XCTFail(error.localizedDescription) 46 | } 47 | } 48 | self.waitForExpectations(timeout: 10000, handler: nil) 49 | } 50 | 51 | 52 | 53 | 54 | } 55 | -------------------------------------------------------------------------------- /PayDockTests/cardView.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 26 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /PayDockTests/chargeAdd.json: -------------------------------------------------------------------------------- 1 | { 2 | "external_id": "ea1210e2-7be9-44b2-a9cb-f1d0c94ae646", 3 | "__v": 1, 4 | "_id": "585a65fe0daa499b1553c623", 5 | "amount": 7750, 6 | "company_id": "582d930808277de017a2a3f4", 7 | "created_at": "2016-12-21T11:22:38.520Z", 8 | "currency": "AUD", 9 | "reference": "Custom user reference", 10 | "updated_at": "2016-12-21T11:22:49.322Z", 11 | "user_id": "582d930808277de017a2a3f3", 12 | "transactions": [ 13 | { 14 | "_id": "585a65fe0daa499b1553c624", 15 | "amount": 7750, 16 | "created_at": "2016-12-21T11:22:38.516Z", 17 | "currency": "AUD", 18 | "status": "complete", 19 | "type": "sale" 20 | } 21 | ], 22 | "one_off": true, 23 | "archived": false, 24 | "customer": { 25 | "first_name": "", 26 | "last_name": "Promise last name", 27 | "email": "maybik87@gmail.com", 28 | "reference": "AUS", 29 | "payment_source": { 30 | "type": "card", 31 | "card_name": "Test User", 32 | "card_number_last4": "1111", 33 | "expire_month": 4, 34 | "expire_year": 2020, 35 | "address_postcode": "3000", 36 | "gateway_id": "5853d3974f76d26c24e69165", 37 | "card_scheme": "visa", 38 | "gateway_name": "Promose Pay way", 39 | "gateway_type": "PromisePay" 40 | } 41 | }, 42 | "status": "complete" 43 | } 44 | -------------------------------------------------------------------------------- /PayDockTests/chargeInfo.json: -------------------------------------------------------------------------------- 1 | { 2 | "_id": "585ba834e45b75bc368087b3", 3 | "created_at": "2016-12-22T10:17:24.504Z", 4 | "updated_at": "2016-12-22T10:17:41.072Z", 5 | "company_id": "582d930808277de017a2a3f4", 6 | "user_id": "582d930808277de017a2a3f3", 7 | "amount": 17, 8 | "currency": "AUD", 9 | "subscription_id": "585ba520e45b75bc368087ab", 10 | "reference": "Custom reference", 11 | "description": "Custom description", 12 | "__v": 1, 13 | "external_id": "ec4592bc-77e4-40c0-82f7-6c6637efe6df", 14 | "transactions": [ 15 | { 16 | "created_at": "2016-12-22T10:17:24.495Z", 17 | "amount": 17, 18 | "currency": "AUD", 19 | "_id": "585ba834e45b75bc368087b4", 20 | "service_logs": [ 21 | { 22 | "req": { 23 | "account_id": "70b234c5-3af7-41b5-9992-96a014eab056", 24 | "amount": 1700, 25 | "zip": "3000", 26 | "email": "chcsviginolegsdsd12f@gmail.com", 27 | "currency": "AUD", 28 | "country": "AUS", 29 | "retain_account": "true" 30 | }, 31 | "response_body": "{\"charges\":{\"id\":\"ec4592bc-77e4-40c0-82f7-6c6637efe6df\",\"name\":\"Charge ec4592bc-77e4-40c0-82f7-6c6637efe6df\",\"created_at\":\"2016-12-22T10:17:27.108Z\",\"updated_at\":\"2016-12-22T10:17:33.275Z\",\"state\":\"completed\",\"buyer_fees\":0,\"seller_fees\":0,\"credit_card_fee\":0,\"status\":22500,\"amount\":1700,\"custom_data\":null,\"account_id\":\"70b234c5-3af7-41b5-9992-96a014eab056\",\"account_type\":\"credit card\",\"promisepay_fee\":89,\"currency\":\"AUD\",\"payment_method\":\"charge\",\"buyer_name\":\"Oleg cCdekrigin\",\"buyer_email\":\"chcsviginolegsdsd12f@gmail.com\",\"buyer_zip\":\"3000\",\"buyer_country\":\"AUS\",\"related\":{\"buyers\":\"950074ce-bf25-4a8f-ac61-d4c3394ea14a\",\"sellers\":\"5fbeeee6fb58c2519703b115cde28573\"},\"links\":{\"self\":\"/charges/ec4592bc-77e4-40c0-82f7-6c6637efe6df\",\"buyers\":\"/charges/ec4592bc-77e4-40c0-82f7-6c6637efe6df/buyers\",\"sellers\":\"/charges/ec4592bc-77e4-40c0-82f7-6c6637efe6df/sellers\",\"status\":\"/charges/ec4592bc-77e4-40c0-82f7-6c6637efe6df/status\",\"fees\":\"/charges/ec4592bc-77e4-40c0-82f7-6c6637efe6df/fees\",\"transactions\":\"/charges/ec4592bc-77e4-40c0-82f7-6c6637efe6df/transactions\",\"batch_transactions\":\"/charges/ec4592bc-77e4-40c0-82f7-6c6637efe6df/batch_transactions\"}}}", 32 | "created_at": "2016-12-22T10:17:41.041Z", 33 | "statusCode": 0, 34 | "_id": "585ba845e45b75bc368087b5" 35 | } 36 | ], 37 | "status": "complete", 38 | "type": "sale" 39 | } 40 | ], 41 | "one_off": false, 42 | "archived": false, 43 | "customer": { 44 | "customer_id": "585ba514e45b75bc368087a8", 45 | "first_name": "Oleg", 46 | "last_name": "cCdekrigin", 47 | "email": "chcsviginolegsdsd12f@gmail.com", 48 | "phone": "+123451678910", 49 | "payment_source": { 50 | "type": "card", 51 | "card_name": "Test User", 52 | "card_number_last4": "1111", 53 | "card_scheme": "visa", 54 | "expire_month": 10, 55 | "expire_year": 2020, 56 | "address_line1": "Testline1", 57 | "address_line2": "Testline2", 58 | "address_city": "Testcity", 59 | "address_postcode": "3000", 60 | "address_state": "Teststate", 61 | "address_country": "AU", 62 | "gateway_id": "5853e89c2bd79538605a3fb6" 63 | } 64 | }, 65 | "status": "complete" 66 | } 67 | -------------------------------------------------------------------------------- /PayDockTests/chargeList.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "_id": "56f3babec1b4578a24b96813", 4 | "amount": 22, 5 | "created_at": "2016-03-24T10:00:30.266Z", 6 | "currency": "AUD", 7 | "external_id": "000000031b0c71b8", 8 | "subscription_id": "56b07e1d56b29f4e25b1e731", 9 | "updated_at": "2016-03-24T10:00:30.507Z", 10 | "one_off": false, 11 | "archived": false, 12 | "customer": { 13 | "customer_id": "56b07d6156b29f4e25b1e72a", 14 | "first_name": "TEST_FIRST_NAME", 15 | "last_name": "TEST_LAST_NAME", 16 | "email": "test@test.com", 17 | "reference": "CustomReferenceOfCustomer", 18 | "payment_source": { 19 | "type": "card", 20 | "card_name": "test user", 21 | "card_number_last4": "1111", 22 | "expire_month": 5, 23 | "expire_year": 2017, 24 | "address_line1": "test", 25 | "address_line2": "test", 26 | "address_city": "test", 27 | "address_postcode": "1234", 28 | "address_state": "nsw", 29 | "address_country": "AU", 30 | "gateway_id": "56b063f856b29f4e25b1e675" 31 | } 32 | }, 33 | "status": "complete" 34 | }, { 35 | "_id": "56f3b33ec1b4578a24b967f3", 36 | "amount": 53.99, 37 | "created_at": "2016-03-24T09:28:30.118Z", 38 | "currency": "AUD", 39 | "external_id": "000000031b0c371e", 40 | "subscription_id": "56b1c8314f5344b5279d98f9", 41 | "updated_at": "2016-03-24T09:28:30.387Z", 42 | "one_off": false, 43 | "archived": false, 44 | "customer": { 45 | "customer_id": "56b1c8314f5344b5279d98f7", 46 | "first_name": "TEST_NEW", 47 | "last_name": "TEST_NEW_2", 48 | "email": "test@test.com", 49 | "reference": "CustomReferenceOfCustomer", 50 | "payment_source": { 51 | "type": "card", 52 | "card_name": "test user", 53 | "card_number_last4": "1111", 54 | "expire_month": 5, 55 | "expire_year": 2017, 56 | "address_line1": "TEST_NEW", 57 | "address_line2": "TEST_NEW", 58 | "address_city": "TEST_NEW", 59 | "address_postcode": "1234", 60 | "address_state": "nsw", 61 | "address_country": "AU", 62 | "gateway_id": "56b063f856b29f4e25b1e675" 63 | } 64 | }, 65 | "status": "complete" 66 | } 67 | ] 68 | -------------------------------------------------------------------------------- /PayDockTests/customerAdd.json: -------------------------------------------------------------------------------- 1 | { 2 | "__v": 0, 3 | "created_at": "2016-12-22T10:36:08.171Z", 4 | "updated_at": "2016-12-22T10:36:08.171Z", 5 | "status": "active", 6 | "default_source": "585bac98e45b75bc368087b8", 7 | "first_name": "Oleg", 8 | "last_name": "cCdekrigin", 9 | "email": "chcsviginolegsdsd12f@gmail.com", 10 | "phone": "+123451678910", 11 | "_id": "585bac95e45b75bc368087b7", 12 | "payment_sources": [ 13 | { 14 | "updated_at": "2016-12-22T10:36:08.170Z", 15 | "vault_token": "94344342-a427-4b9f-9476-f64386d5bba9", 16 | "address_line1": "Testline1", 17 | "address_line2": "Testline2", 18 | "address_city": "Testcity", 19 | "address_state": "Teststate", 20 | "address_country": "AU", 21 | "address_postcode": "3000", 22 | "gateway_id": "5853e89c2bd79538605a3fb6", 23 | "card_name": "Test User", 24 | "expire_month": 10, 25 | "expire_year": 2020, 26 | "card_number_last4": "1111", 27 | "card_scheme": "visa", 28 | "ref_token": "754a2e68-32f9-437c-9544-afc6bef2beb8", 29 | "status": "active", 30 | "created_at": "2016-12-22T10:36:08.083Z", 31 | "_id": "585bac98e45b75bc368087b8", 32 | "type": "card" 33 | } 34 | ], 35 | "statistics": { 36 | "total_collected_amount": 0, 37 | "successful_transactions": 0 38 | }, 39 | "_service": { 40 | "default_gateway_id": "5853e89c2bd79538605a3fb6" 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /PayDockTests/customerItem.json: -------------------------------------------------------------------------------- 1 | { 2 | "_id": "585ba514e45b75bc368087a8", 3 | "created_at": "2016-12-22T10:04:06.418Z", 4 | "updated_at": "2016-12-22T10:04:06.418Z", 5 | "status": "active", 6 | "default_source": "585ba516e45b75bc368087a9", 7 | "first_name": "Oleg", 8 | "last_name": "cCdekrigin", 9 | "email": "chcsviginolegsdsd12f@gmail.com", 10 | "phone": "+123451678910", 11 | "__v": 0, 12 | "payment_sources": [ 13 | { 14 | "updated_at": "2016-12-22T10:04:06.417Z", 15 | "vault_token": "26338ebc-cc76-4eaa-a189-b0c3c27d0a69", 16 | "address_line1": "Testline1", 17 | "address_line2": "Testline2", 18 | "address_city": "Testcity", 19 | "address_state": "Teststate", 20 | "address_country": "AU", 21 | "address_postcode": "3000", 22 | "gateway_id": "5853e89c2bd79538605a3fb6", 23 | "card_name": "Test User", 24 | "expire_month": 10, 25 | "expire_year": 2020, 26 | "card_number_last4": "1111", 27 | "card_scheme": "visa", 28 | "ref_token": "70b234c5-3af7-41b5-9992-96a014eab056", 29 | "status": "active", 30 | "created_at": "2016-12-22T10:04:06.370Z", 31 | "_id": "585ba516e45b75bc368087a9", 32 | "type": "card" 33 | } 34 | ], 35 | "statistics": { 36 | "currency": { 37 | "AUD": { 38 | "count": 2, 39 | "total_amount": 27 40 | } 41 | }, 42 | "total_collected_amount": 27, 43 | "successful_transactions": 2 44 | }, 45 | "_service": { 46 | "default_gateway_id": "5853e89c2bd79538605a3fb6" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /PayDockTests/customerList.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "_id":"585bac95e45b75bc368087b7", 4 | "created_at":"2016-12-22T10:36:08.171Z", 5 | "updated_at":"2016-12-22T10:36:08.171Z", 6 | "status":"active", 7 | "_source_ip_address":"::1", 8 | "default_source":"585bac98e45b75bc368087b8", 9 | "company_id":"582d930808277de017a2a3f4", 10 | "user_id":"582d930808277de017a2a3f3", 11 | "first_name":"Oleg", 12 | "last_name":"cCdekrigin", 13 | "email":"chcsviginolegsdsd12f@gmail.com", 14 | "phone":"+123451678910", 15 | "payment_sources":[ 16 | { 17 | "updated_at":"2016-12-22T10:36:08.170Z", 18 | "vault_token":"94344342-a427-4b9f-9476-f64386d5bba9", 19 | "address_line1":"Testline1", 20 | "address_line2":"Testline2", 21 | "address_city":"Testcity", 22 | "address_state":"Teststate", 23 | "address_country":"AU", 24 | "address_postcode":"3000", 25 | "gateway_id":"5853e89c2bd79538605a3fb6", 26 | "card_name":"Test User", 27 | "expire_month":10, 28 | "expire_year":2020, 29 | "card_number_last4":"1111", 30 | "card_scheme":"visa", 31 | "ref_token":"754a2e68-32f9-437c-9544-afc6bef2beb8", 32 | "status":"active", 33 | "created_at":"2016-12-22T10:36:08.083Z", 34 | "_id":"585bac98e45b75bc368087b8", 35 | "type":"card" 36 | } 37 | ], 38 | "archived":false, 39 | "statistics":{ 40 | "total_collected_amount":0, 41 | "successful_transactions":0 42 | } 43 | } 44 | ] 45 | -------------------------------------------------------------------------------- /PayDockTests/externalCheckoutAdd.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "payment_source", 3 | "data": { 4 | "checkout_type": "link", 5 | "link": "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-12D76527BK035913Y", 6 | "reference_id": "EC-12D76527BK035913Y", 7 | "mode": "test", 8 | "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0eXBlIjoicGF5cGFsIiwiZ2F0ZXdheV9pZCI6IjU4M2JlYjViYTIzMjc3ZjYxOTExZjg2YiIsImdhdGV3YXlfdHlwZSI6IlBheXBhbENsYXNzaWMiLCJzcGVjaWZpY0RhdGEiOnsiY2hlY2tvdXRfdG9rZW4iOiJFQy0xMkQ3NjUyN0JLMDM1OTEzWSJ9LCJtb2RlIjoidGVzdCIsImlhdCI6MTQ4MDQ1MjI5MH0.DN5eLG-VyAIcQJlkBRX0NHav5svPQ4jrM_u0V9QRD1I" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /PayDockTests/subscriptionAdd.json: -------------------------------------------------------------------------------- 1 | { 2 | 3 | "__v": 0, 4 | "created_at": "2015-11-10T11:27:44.504Z", 5 | "updated_at": "2015-11-10T11:27:44.504Z", 6 | "amount": 10, 7 | "description": "Custom subscription description", 8 | "reference": "Custom subscription reference", 9 | "status": "active", 10 | "_id": "55b2213073065f9423a45d78", 11 | "archived": false, 12 | "_service": { 13 | "customer_default_gateway_id": "551bb4af43daf16f355ab259", 14 | "tags": "test_first_name test_last_name test@test.com" 15 | }, 16 | "customer": { 17 | "customer_id": "55b2212f73065f9423a45d76", 18 | "first_name": "Test_first_name", 19 | "last_name": "Test_last_name", 20 | "email": "test@test.com" 21 | }, 22 | "statistics": { 23 | "total_collected_amount": 0, 24 | "successful_transactions": 0 25 | }, 26 | "schedule": { 27 | "interval": "month", 28 | "start_date": "2015-11-10T11:27:43.743Z", 29 | "end_date": "2016-01-10T00:00:00.000Z", 30 | "next_assessment": "2015-12-10T11:27:43.743Z", 31 | "first_assessment": "2015-11-10T11:27:43.743Z", 32 | "status": "inprogress", 33 | "locked": false, 34 | "completed_count": 0, 35 | "retry_count": 0, 36 | "frequency": 1 37 | }, 38 | "currency": "AUD" 39 | } 40 | -------------------------------------------------------------------------------- /PayDockTests/subscriptionItem.json: -------------------------------------------------------------------------------- 1 | { 2 | "created_at": "2015-07-24T11:51:30.211Z", 3 | "updated_at": "2015-07-24T11:51:30.211Z", 4 | "user_id": "559241db556cc23c1ed3770a", 5 | "company_id": "559241db556cc23c1ed3770b", 6 | "amount": 10, 7 | "description": "Custom description", 8 | "reference": "Custom reference", 9 | "status": "active", 10 | "_id": "55b226c273065f9423a45d8d", 11 | "archived": false, 12 | "customer": { 13 | "customer_id": "55b226c173065f9423a45d8b", 14 | "first_name": "Test_first_name", 15 | "last_name": "Test_last_name", 16 | "email": "test@test.com", 17 | "reference": "CustomReference", 18 | "payment_source": { 19 | "gateway_name": "Ezidebit label", 20 | "gateway_type": "Ezidebit", 21 | "gateway_mode": "test", 22 | "updated_at": "2015-07-24T11:51:30.207Z", 23 | "address_line1": "Testline1", 24 | "address_line2": "Testline2", 25 | "address_city": "Testcity", 26 | "address_state": "Teststate", 27 | "address_country": "AU", 28 | "address_postcode": "1234", 29 | "gateway_id": "5592499f556cc23c1ed37710", 30 | "account_name": "Test", 31 | "account_bsb": 32000, 32 | "account_number": "XXXX00", 33 | "ref_token": "762958", 34 | "status": "active", 35 | "created_at": "2015-07-24T11:51:30.205Z", 36 | "_id": "55b226c273065f9423a45d8c", 37 | "type": "bsb" 38 | } 39 | }, 40 | "statistics": { 41 | "total_collected_amount": 0, 42 | "successful_transactions": 0 43 | }, 44 | "schedule": { 45 | "interval": "day", 46 | "start_date": "2015-07-25T00:00:00.000Z", 47 | "end_date": "2016-08-25T00:00:00.000Z", 48 | "next_assessment": "2015-07-25T00:00:00.000Z", 49 | "first_assessment": "2015-07-25T00:00:00.000Z", 50 | "status": "inprogress", 51 | "locked": false, 52 | "completed_count": 0, 53 | "retry_count": 0, 54 | "frequency": 1 55 | }, 56 | "currency": "AUD" 57 | } 58 | -------------------------------------------------------------------------------- /PayDockTests/subscriptionList.json: -------------------------------------------------------------------------------- 1 | [{ 2 | "_id": "56d84e98815b245d242b4996", 3 | "amount": 10.70, 4 | "company_id": "56a5e4e6489dc5402557d9b7", 5 | "created_at": "2016-03-03T14:47:52.834Z", 6 | "status": "expired", 7 | "updated_at": "2016-03-03T14:48:00.579Z", 8 | "user_id": "56a5e4e6489dc5402557d9b6", 9 | "archived": false, 10 | "customer": { 11 | "customer_id": "56d84e97815b245d242b4991", 12 | "first_name": "TEST_NEW_SUB55", 13 | "last_name": "Number", 14 | "email": "test@test.com", 15 | "reference": "CustomReference" 16 | }, 17 | "statistics": { 18 | "total_collected_amount": 10.59, 19 | "successful_transactions": 1 20 | }, 21 | "schedule": { 22 | "end_amount_total": 10.70, 23 | "first_assessment": "2016-03-03T14:47:51.739Z", 24 | "interval": "day", 25 | "last_assessment": "2016-03-03T14:48:00.576Z", 26 | "next_assessment": "2016-03-03T14:47:51.739Z", 27 | "start_date": "2016-03-03T14:47:51.739Z", 28 | "status": "complete", 29 | "locked": false, 30 | "completed_count": 1, 31 | "retry_count": 0, 32 | "frequency": 1 33 | }, 34 | "currency": "AUD", 35 | "gateway_type": "Stripe", 36 | "gateway_name": "strp", 37 | "gateway_mode": "test" 38 | }, { 39 | "_id": "56d84e7b815b245d242b494b", 40 | "amount": 12.00, 41 | "company_id": "56a5e4e6489dc5402557d9b7", 42 | "created_at": "2016-03-03T14:47:23.051Z", 43 | "status": "expired", 44 | "updated_at": "2016-03-03T14:47:30.590Z", 45 | "user_id": "56a5e4e6489dc5402557d9b6", 46 | "archived": false, 47 | "customer": { 48 | "customer_id": "56d84e79815b245d242b4949", 49 | "first_name": "TEST_NEW_SUB55", 50 | "last_name": "Number", 51 | "email": "test@test.com" 52 | }, 53 | "statistics": { 54 | "total_collected_amount": 10.59, 55 | "successful_transactions": 1 56 | }, 57 | "schedule": { 58 | "end_amount_total": 12.00, 59 | "first_assessment": "2016-03-03T14:47:21.805Z", 60 | "interval": "day", 61 | "last_assessment": "2016-03-03T14:47:30.588Z", 62 | "next_assessment": "2016-03-03T14:47:21.805Z", 63 | "start_date": "2016-03-03T14:47:21.805Z", 64 | "status": "complete", 65 | "locked": false, 66 | "completed_count": 1, 67 | "retry_count": 0, 68 | "frequency": 1 69 | }, 70 | "currency": "AUD", 71 | "gateway_type": "Stripe", 72 | "gateway_name": "strp", 73 | "gateway_mode": "test" 74 | }] 75 | -------------------------------------------------------------------------------- /PayDockTests/subscriptionUpdate.json: -------------------------------------------------------------------------------- 1 | { 2 | "_id": "55b2213073065f9423a45d78", 3 | "amount": 167, 4 | "company_id": "559241db556cc23c1ed3770b", 5 | "created_at": "2015-07-24T11:27:44.504Z", 6 | "description": "Custom description", 7 | "reference": "Custom reference", 8 | "status": "active", 9 | "updated_at": "2015-07-24T11:31:34.697Z", 10 | "user_id": "559241db556cc23c1ed3770a", 11 | "archived": false, 12 | "customer": { 13 | "customer_id": "55b2212f73065f9423a45d76", 14 | "first_name": "Test_first_name", 15 | "last_name": "Test_last_name", 16 | "email": "test@test.com" 17 | }, 18 | "statistics": { 19 | "total_collected_amount": 10, 20 | "successful_transactions": 1 21 | }, 22 | "schedule": { 23 | "end_date": "2016-07-25T00:00:00.000Z", 24 | "first_assessment": "2015-08-01T00:00:00.000Z", 25 | "interval": "year", 26 | "last_assessment": "2015-07-24T11:28:02.480Z", 27 | "next_assessment": "2015-08-01T00:00:00.000Z", 28 | "start_date": "2015-08-01T00:00:00.000Z", 29 | "status": "complete", 30 | "locked": false, 31 | "completed_count": 1, 32 | "retry_count": 0, 33 | "frequency": 1 34 | }, 35 | "currency": "AUD", 36 | "gateway_type": "Pin", 37 | "gateway_name": "Pin label", 38 | "gateway_mode": "test" 39 | } 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Deprecation Notice: paydock_ios_sdk is no longer supported or maintained. 2 | 3 | We are deprecating the paydock_ios_sdk repository in favor of newer, better-maintained alternatives. This means that the code in this repository will not receive any updates, bug fixes, or security patches. 4 | 5 | Please do not use this SDK for new development, as it will lead to compatibility issues and potential security risks. Instead, we recommend using direct REST API integration. 6 | 7 | We apologize for any inconvenience this may cause, but we must prioritize the stability and security of our software. 8 | 9 | If you have any questions or concerns, please open an issue in the repository or contact Paydock Support. 10 | 11 | Thank you for your understanding. 12 | -------------------------------------------------------------------------------- /docs/Guides.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Guides Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |

19 | 20 | PayDock Docs 21 | 22 | 23 |

24 | 25 | 26 |
27 | 28 | 33 | 34 |
35 | 121 |
122 | 123 |
124 |
125 |

Guides

126 |

The following guides are available globally.

127 | 128 |
129 |
130 | 131 |
132 |
133 |
134 |
135 | 136 |
137 |
138 | 142 | 143 | 144 | 145 | -------------------------------------------------------------------------------- /docs/css/highlight.css: -------------------------------------------------------------------------------- 1 | /* Credit to https://gist.github.com/wataru420/2048287 */ 2 | .highlight { 3 | /* Comment */ 4 | /* Error */ 5 | /* Keyword */ 6 | /* Operator */ 7 | /* Comment.Multiline */ 8 | /* Comment.Preproc */ 9 | /* Comment.Single */ 10 | /* Comment.Special */ 11 | /* Generic.Deleted */ 12 | /* Generic.Deleted.Specific */ 13 | /* Generic.Emph */ 14 | /* Generic.Error */ 15 | /* Generic.Heading */ 16 | /* Generic.Inserted */ 17 | /* Generic.Inserted.Specific */ 18 | /* Generic.Output */ 19 | /* Generic.Prompt */ 20 | /* Generic.Strong */ 21 | /* Generic.Subheading */ 22 | /* Generic.Traceback */ 23 | /* Keyword.Constant */ 24 | /* Keyword.Declaration */ 25 | /* Keyword.Pseudo */ 26 | /* Keyword.Reserved */ 27 | /* Keyword.Type */ 28 | /* Literal.Number */ 29 | /* Literal.String */ 30 | /* Name.Attribute */ 31 | /* Name.Builtin */ 32 | /* Name.Class */ 33 | /* Name.Constant */ 34 | /* Name.Entity */ 35 | /* Name.Exception */ 36 | /* Name.Function */ 37 | /* Name.Namespace */ 38 | /* Name.Tag */ 39 | /* Name.Variable */ 40 | /* Operator.Word */ 41 | /* Text.Whitespace */ 42 | /* Literal.Number.Float */ 43 | /* Literal.Number.Hex */ 44 | /* Literal.Number.Integer */ 45 | /* Literal.Number.Oct */ 46 | /* Literal.String.Backtick */ 47 | /* Literal.String.Char */ 48 | /* Literal.String.Doc */ 49 | /* Literal.String.Double */ 50 | /* Literal.String.Escape */ 51 | /* Literal.String.Heredoc */ 52 | /* Literal.String.Interpol */ 53 | /* Literal.String.Other */ 54 | /* Literal.String.Regex */ 55 | /* Literal.String.Single */ 56 | /* Literal.String.Symbol */ 57 | /* Name.Builtin.Pseudo */ 58 | /* Name.Variable.Class */ 59 | /* Name.Variable.Global */ 60 | /* Name.Variable.Instance */ 61 | /* Literal.Number.Integer.Long */ } 62 | .highlight .c { 63 | color: #999988; 64 | font-style: italic; } 65 | .highlight .err { 66 | color: #a61717; 67 | background-color: #e3d2d2; } 68 | .highlight .k { 69 | color: #000000; 70 | font-weight: bold; } 71 | .highlight .o { 72 | color: #000000; 73 | font-weight: bold; } 74 | .highlight .cm { 75 | color: #999988; 76 | font-style: italic; } 77 | .highlight .cp { 78 | color: #999999; 79 | font-weight: bold; } 80 | .highlight .c1 { 81 | color: #999988; 82 | font-style: italic; } 83 | .highlight .cs { 84 | color: #999999; 85 | font-weight: bold; 86 | font-style: italic; } 87 | .highlight .gd { 88 | color: #000000; 89 | background-color: #ffdddd; } 90 | .highlight .gd .x { 91 | color: #000000; 92 | background-color: #ffaaaa; } 93 | .highlight .ge { 94 | color: #000000; 95 | font-style: italic; } 96 | .highlight .gr { 97 | color: #aa0000; } 98 | .highlight .gh { 99 | color: #999999; } 100 | .highlight .gi { 101 | color: #000000; 102 | background-color: #ddffdd; } 103 | .highlight .gi .x { 104 | color: #000000; 105 | background-color: #aaffaa; } 106 | .highlight .go { 107 | color: #888888; } 108 | .highlight .gp { 109 | color: #555555; } 110 | .highlight .gs { 111 | font-weight: bold; } 112 | .highlight .gu { 113 | color: #aaaaaa; } 114 | .highlight .gt { 115 | color: #aa0000; } 116 | .highlight .kc { 117 | color: #000000; 118 | font-weight: bold; } 119 | .highlight .kd { 120 | color: #000000; 121 | font-weight: bold; } 122 | .highlight .kp { 123 | color: #000000; 124 | font-weight: bold; } 125 | .highlight .kr { 126 | color: #000000; 127 | font-weight: bold; } 128 | .highlight .kt { 129 | color: #445588; } 130 | .highlight .m { 131 | color: #009999; } 132 | .highlight .s { 133 | color: #d14; } 134 | .highlight .na { 135 | color: #008080; } 136 | .highlight .nb { 137 | color: #0086B3; } 138 | .highlight .nc { 139 | color: #445588; 140 | font-weight: bold; } 141 | .highlight .no { 142 | color: #008080; } 143 | .highlight .ni { 144 | color: #800080; } 145 | .highlight .ne { 146 | color: #990000; 147 | font-weight: bold; } 148 | .highlight .nf { 149 | color: #990000; } 150 | .highlight .nn { 151 | color: #555555; } 152 | .highlight .nt { 153 | color: #000080; } 154 | .highlight .nv { 155 | color: #008080; } 156 | .highlight .ow { 157 | color: #000000; 158 | font-weight: bold; } 159 | .highlight .w { 160 | color: #bbbbbb; } 161 | .highlight .mf { 162 | color: #009999; } 163 | .highlight .mh { 164 | color: #009999; } 165 | .highlight .mi { 166 | color: #009999; } 167 | .highlight .mo { 168 | color: #009999; } 169 | .highlight .sb { 170 | color: #d14; } 171 | .highlight .sc { 172 | color: #d14; } 173 | .highlight .sd { 174 | color: #d14; } 175 | .highlight .s2 { 176 | color: #d14; } 177 | .highlight .se { 178 | color: #d14; } 179 | .highlight .sh { 180 | color: #d14; } 181 | .highlight .si { 182 | color: #d14; } 183 | .highlight .sx { 184 | color: #d14; } 185 | .highlight .sr { 186 | color: #009926; } 187 | .highlight .s1 { 188 | color: #d14; } 189 | .highlight .ss { 190 | color: #990073; } 191 | .highlight .bp { 192 | color: #999999; } 193 | .highlight .vc { 194 | color: #008080; } 195 | .highlight .vg { 196 | color: #008080; } 197 | .highlight .vi { 198 | color: #008080; } 199 | .highlight .il { 200 | color: #009999; } 201 | -------------------------------------------------------------------------------- /docs/docsets/PayDock.docset/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleIdentifier 6 | com.jazzy.paydock 7 | CFBundleName 8 | PayDock 9 | DocSetPlatformFamily 10 | paydock 11 | isDashDocset 12 | 13 | dashIndexFilePath 14 | index.html 15 | isJavaScriptEnabled 16 | 17 | DashDocSetFamily 18 | dashtoc 19 | 20 | 21 | -------------------------------------------------------------------------------- /docs/docsets/PayDock.docset/Contents/Resources/Documents/Guides.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Guides Reference 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |

19 | 20 | PayDock Docs 21 | 22 | 23 |

24 | 25 | 26 |
27 | 28 | 33 | 34 |
35 | 121 |
122 | 123 |
124 |
125 |

Guides

126 |

The following guides are available globally.

127 | 128 |
129 |
130 | 131 |
132 |
133 |
134 |
135 | 136 |
137 |
138 | 142 | 143 | 144 | 145 | -------------------------------------------------------------------------------- /docs/docsets/PayDock.docset/Contents/Resources/Documents/css/highlight.css: -------------------------------------------------------------------------------- 1 | /* Credit to https://gist.github.com/wataru420/2048287 */ 2 | .highlight { 3 | /* Comment */ 4 | /* Error */ 5 | /* Keyword */ 6 | /* Operator */ 7 | /* Comment.Multiline */ 8 | /* Comment.Preproc */ 9 | /* Comment.Single */ 10 | /* Comment.Special */ 11 | /* Generic.Deleted */ 12 | /* Generic.Deleted.Specific */ 13 | /* Generic.Emph */ 14 | /* Generic.Error */ 15 | /* Generic.Heading */ 16 | /* Generic.Inserted */ 17 | /* Generic.Inserted.Specific */ 18 | /* Generic.Output */ 19 | /* Generic.Prompt */ 20 | /* Generic.Strong */ 21 | /* Generic.Subheading */ 22 | /* Generic.Traceback */ 23 | /* Keyword.Constant */ 24 | /* Keyword.Declaration */ 25 | /* Keyword.Pseudo */ 26 | /* Keyword.Reserved */ 27 | /* Keyword.Type */ 28 | /* Literal.Number */ 29 | /* Literal.String */ 30 | /* Name.Attribute */ 31 | /* Name.Builtin */ 32 | /* Name.Class */ 33 | /* Name.Constant */ 34 | /* Name.Entity */ 35 | /* Name.Exception */ 36 | /* Name.Function */ 37 | /* Name.Namespace */ 38 | /* Name.Tag */ 39 | /* Name.Variable */ 40 | /* Operator.Word */ 41 | /* Text.Whitespace */ 42 | /* Literal.Number.Float */ 43 | /* Literal.Number.Hex */ 44 | /* Literal.Number.Integer */ 45 | /* Literal.Number.Oct */ 46 | /* Literal.String.Backtick */ 47 | /* Literal.String.Char */ 48 | /* Literal.String.Doc */ 49 | /* Literal.String.Double */ 50 | /* Literal.String.Escape */ 51 | /* Literal.String.Heredoc */ 52 | /* Literal.String.Interpol */ 53 | /* Literal.String.Other */ 54 | /* Literal.String.Regex */ 55 | /* Literal.String.Single */ 56 | /* Literal.String.Symbol */ 57 | /* Name.Builtin.Pseudo */ 58 | /* Name.Variable.Class */ 59 | /* Name.Variable.Global */ 60 | /* Name.Variable.Instance */ 61 | /* Literal.Number.Integer.Long */ } 62 | .highlight .c { 63 | color: #999988; 64 | font-style: italic; } 65 | .highlight .err { 66 | color: #a61717; 67 | background-color: #e3d2d2; } 68 | .highlight .k { 69 | color: #000000; 70 | font-weight: bold; } 71 | .highlight .o { 72 | color: #000000; 73 | font-weight: bold; } 74 | .highlight .cm { 75 | color: #999988; 76 | font-style: italic; } 77 | .highlight .cp { 78 | color: #999999; 79 | font-weight: bold; } 80 | .highlight .c1 { 81 | color: #999988; 82 | font-style: italic; } 83 | .highlight .cs { 84 | color: #999999; 85 | font-weight: bold; 86 | font-style: italic; } 87 | .highlight .gd { 88 | color: #000000; 89 | background-color: #ffdddd; } 90 | .highlight .gd .x { 91 | color: #000000; 92 | background-color: #ffaaaa; } 93 | .highlight .ge { 94 | color: #000000; 95 | font-style: italic; } 96 | .highlight .gr { 97 | color: #aa0000; } 98 | .highlight .gh { 99 | color: #999999; } 100 | .highlight .gi { 101 | color: #000000; 102 | background-color: #ddffdd; } 103 | .highlight .gi .x { 104 | color: #000000; 105 | background-color: #aaffaa; } 106 | .highlight .go { 107 | color: #888888; } 108 | .highlight .gp { 109 | color: #555555; } 110 | .highlight .gs { 111 | font-weight: bold; } 112 | .highlight .gu { 113 | color: #aaaaaa; } 114 | .highlight .gt { 115 | color: #aa0000; } 116 | .highlight .kc { 117 | color: #000000; 118 | font-weight: bold; } 119 | .highlight .kd { 120 | color: #000000; 121 | font-weight: bold; } 122 | .highlight .kp { 123 | color: #000000; 124 | font-weight: bold; } 125 | .highlight .kr { 126 | color: #000000; 127 | font-weight: bold; } 128 | .highlight .kt { 129 | color: #445588; } 130 | .highlight .m { 131 | color: #009999; } 132 | .highlight .s { 133 | color: #d14; } 134 | .highlight .na { 135 | color: #008080; } 136 | .highlight .nb { 137 | color: #0086B3; } 138 | .highlight .nc { 139 | color: #445588; 140 | font-weight: bold; } 141 | .highlight .no { 142 | color: #008080; } 143 | .highlight .ni { 144 | color: #800080; } 145 | .highlight .ne { 146 | color: #990000; 147 | font-weight: bold; } 148 | .highlight .nf { 149 | color: #990000; } 150 | .highlight .nn { 151 | color: #555555; } 152 | .highlight .nt { 153 | color: #000080; } 154 | .highlight .nv { 155 | color: #008080; } 156 | .highlight .ow { 157 | color: #000000; 158 | font-weight: bold; } 159 | .highlight .w { 160 | color: #bbbbbb; } 161 | .highlight .mf { 162 | color: #009999; } 163 | .highlight .mh { 164 | color: #009999; } 165 | .highlight .mi { 166 | color: #009999; } 167 | .highlight .mo { 168 | color: #009999; } 169 | .highlight .sb { 170 | color: #d14; } 171 | .highlight .sc { 172 | color: #d14; } 173 | .highlight .sd { 174 | color: #d14; } 175 | .highlight .s2 { 176 | color: #d14; } 177 | .highlight .se { 178 | color: #d14; } 179 | .highlight .sh { 180 | color: #d14; } 181 | .highlight .si { 182 | color: #d14; } 183 | .highlight .sx { 184 | color: #d14; } 185 | .highlight .sr { 186 | color: #009926; } 187 | .highlight .s1 { 188 | color: #d14; } 189 | .highlight .ss { 190 | color: #990073; } 191 | .highlight .bp { 192 | color: #999999; } 193 | .highlight .vc { 194 | color: #008080; } 195 | .highlight .vg { 196 | color: #008080; } 197 | .highlight .vi { 198 | color: #008080; } 199 | .highlight .il { 200 | color: #009999; } 201 | -------------------------------------------------------------------------------- /docs/docsets/PayDock.docset/Contents/Resources/Documents/img/carat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PayDock/paydock_ios_sdk/29052dd731ddc0370da9f0da10a6665bf82d1dff/docs/docsets/PayDock.docset/Contents/Resources/Documents/img/carat.png -------------------------------------------------------------------------------- /docs/docsets/PayDock.docset/Contents/Resources/Documents/img/dash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PayDock/paydock_ios_sdk/29052dd731ddc0370da9f0da10a6665bf82d1dff/docs/docsets/PayDock.docset/Contents/Resources/Documents/img/dash.png -------------------------------------------------------------------------------- /docs/docsets/PayDock.docset/Contents/Resources/Documents/img/gh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PayDock/paydock_ios_sdk/29052dd731ddc0370da9f0da10a6665bf82d1dff/docs/docsets/PayDock.docset/Contents/Resources/Documents/img/gh.png -------------------------------------------------------------------------------- /docs/docsets/PayDock.docset/Contents/Resources/Documents/js/jazzy.js: -------------------------------------------------------------------------------- 1 | window.jazzy = {'docset': false} 2 | if (typeof window.dash != 'undefined') { 3 | document.documentElement.className += ' dash' 4 | window.jazzy.docset = true 5 | } 6 | if (navigator.userAgent.match(/xcode/i)) { 7 | document.documentElement.className += ' xcode' 8 | window.jazzy.docset = true 9 | } 10 | 11 | // On doc load, toggle the URL hash discussion if present 12 | $(document).ready(function() { 13 | if (!window.jazzy.docset) { 14 | var linkToHash = $('a[href="' + window.location.hash +'"]'); 15 | linkToHash.trigger("click"); 16 | } 17 | }); 18 | 19 | // On token click, toggle its discussion and animate token.marginLeft 20 | $(".token").click(function(event) { 21 | if (window.jazzy.docset) { 22 | return; 23 | } 24 | var link = $(this); 25 | var animationDuration = 300; 26 | $content = link.parent().parent().next(); 27 | $content.slideToggle(animationDuration); 28 | 29 | // Keeps the document from jumping to the hash. 30 | var href = $(this).attr('href'); 31 | if (history.pushState) { 32 | history.pushState({}, '', href); 33 | } else { 34 | location.hash = href; 35 | } 36 | event.preventDefault(); 37 | }); 38 | -------------------------------------------------------------------------------- /docs/docsets/PayDock.docset/Contents/Resources/docSet.dsidx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PayDock/paydock_ios_sdk/29052dd731ddc0370da9f0da10a6665bf82d1dff/docs/docsets/PayDock.docset/Contents/Resources/docSet.dsidx -------------------------------------------------------------------------------- /docs/docsets/PayDock.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PayDock/paydock_ios_sdk/29052dd731ddc0370da9f0da10a6665bf82d1dff/docs/docsets/PayDock.tgz -------------------------------------------------------------------------------- /docs/img/carat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PayDock/paydock_ios_sdk/29052dd731ddc0370da9f0da10a6665bf82d1dff/docs/img/carat.png -------------------------------------------------------------------------------- /docs/img/dash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PayDock/paydock_ios_sdk/29052dd731ddc0370da9f0da10a6665bf82d1dff/docs/img/dash.png -------------------------------------------------------------------------------- /docs/img/gh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PayDock/paydock_ios_sdk/29052dd731ddc0370da9f0da10a6665bf82d1dff/docs/img/gh.png -------------------------------------------------------------------------------- /docs/js/jazzy.js: -------------------------------------------------------------------------------- 1 | window.jazzy = {'docset': false} 2 | if (typeof window.dash != 'undefined') { 3 | document.documentElement.className += ' dash' 4 | window.jazzy.docset = true 5 | } 6 | if (navigator.userAgent.match(/xcode/i)) { 7 | document.documentElement.className += ' xcode' 8 | window.jazzy.docset = true 9 | } 10 | 11 | // On doc load, toggle the URL hash discussion if present 12 | $(document).ready(function() { 13 | if (!window.jazzy.docset) { 14 | var linkToHash = $('a[href="' + window.location.hash +'"]'); 15 | linkToHash.trigger("click"); 16 | } 17 | }); 18 | 19 | // On token click, toggle its discussion and animate token.marginLeft 20 | $(".token").click(function(event) { 21 | if (window.jazzy.docset) { 22 | return; 23 | } 24 | var link = $(this); 25 | var animationDuration = 300; 26 | $content = link.parent().parent().next(); 27 | $content.slideToggle(animationDuration); 28 | 29 | // Keeps the document from jumping to the hash. 30 | var href = $(this).attr('href'); 31 | if (history.pushState) { 32 | history.pushState({}, '', href); 33 | } else { 34 | location.hash = href; 35 | } 36 | event.preventDefault(); 37 | }); 38 | --------------------------------------------------------------------------------