{"id":27151399,"url":"https://github.com/checkout/checkout-risk-sdk-ios","last_synced_at":"2025-04-08T14:40:21.381Z","repository":{"id":212062392,"uuid":"703532212","full_name":"checkout/checkout-risk-sdk-ios","owner":"checkout","description":"The Risk iOS package helps collect device data for merchants with direct integration (standalone) with the package and those using Checkout's Frames iOS package.","archived":false,"fork":false,"pushed_at":"2024-05-22T14:41:00.000Z","size":1436,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-05-22T15:00:09.173Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/checkout.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS.md","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-11T12:20:43.000Z","updated_at":"2024-05-29T16:10:37.213Z","dependencies_parsed_at":"2023-12-15T16:28:41.579Z","dependency_job_id":"e492268d-4f95-4bca-9ed9-9e5bb5c97bbb","html_url":"https://github.com/checkout/checkout-risk-sdk-ios","commit_stats":null,"previous_names":["checkout/checkout-risk-sdk-ios"],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/checkout%2Fcheckout-risk-sdk-ios","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/checkout%2Fcheckout-risk-sdk-ios/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/checkout%2Fcheckout-risk-sdk-ios/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/checkout%2Fcheckout-risk-sdk-ios/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/checkout","download_url":"https://codeload.github.com/checkout/checkout-risk-sdk-ios/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247547524,"owners_count":20956571,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-04-08T14:40:20.759Z","updated_at":"2025-04-08T14:40:21.375Z","avatar_url":"https://github.com/checkout.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"#  Risk iOS package\n[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/Risk.svg)](https://img.shields.io/cocoapods/v/Risk)\n![GitHub release (latest by date)](https://img.shields.io/github/v/release/checkout/checkout-risk-sdk-ios?label=spm)\n[![Platform](https://img.shields.io/cocoapods/p/Risk.svg?style=flat)]()\n![license](https://img.shields.io/github/license/checkout/checkout-risk-sdk-ios.svg)\n\nThe package helps collect device data for merchants with direct integration (standalone) with the package and those using [Checkout's Frames iOS package](https://github.com/checkout/frames-ios).\n\n## Table of contents\n- [Risk iOS package](#risk-ios-package)\n  - [Table of contents](#table-of-contents)\n  - [Requirements](#requirements)\n  - [Documentation](#documentation)\n    - [Usage guide](#usage-guide)\n    - [Public API](#public-api)\n    - [Additional Resources](#additional-resources)\n  - [Demo projects](#demo-projects)\n  - [Changelog](#changelog)\n  - [Contributing](#contributing)\n  - [License](#license)\n\n\n## Requirements\n- iOS 13.0+\n- Xcode 12.4+\n- Swift 5.3+\n\n## Documentation\n### Usage guide\n  1. Add `Risk` as a package dependency - _see [Installation guide](https://github.com/checkout/checkout-risk-sdk-ios/blob/main/.github/partial-readmes/Installation.md) on how to add our SDK in your iOS app via SPM or Cocoapods._\n  2. Obtain a public API key from [Checkout Dashboard](https://dashboard.checkout.com/developers/keys).\n  3. Initialise the package Risk with the public API key and environment `Risk.init(config: yourConfig)` early-on.\n        \u003cdetails\u003e\n        \u003csummary\u003eType definitions\u003c/summary\u003e\n\n        ```swift\n        public struct RiskConfig {\n            let publicKey: String\n            let environment: RiskEnvironment\n            let framesMode: Bool\n            \n            public init(publicKey: String, environment: RiskEnvironment, framesMode: Bool = false) {\n                self.publicKey = publicKey\n                self.environment = environment\n                self.framesMode = framesMode\n            }\n        }\n\n        public enum RiskEnvironment {\n            case qa\n            case sandbox\n            case production\n        }\n        ```\n        \u003c/details\u003e\n  4. Use the `configure` to complete your setup, then publish the device data within the closure with the `publishData` method. \n\n        \u003cdetails\u003e\n        \u003csummary\u003eType definitions\u003c/summary\u003e\n\n        ```swift\n        public struct PublishRiskData {\n            public let deviceSessionId: String\n        }\n\n        public enum RiskError: LocalizedError, Equatable {\n            case configuration(Configuration)\n            case publish(Publish)\n        }\n\n        public enum RiskError {\n            case configuration(Configuration)\n            case publish(Publish)\n        }\n\n        public extension RiskError {\n            enum Configuration: LocalizedError {\n                case integrationDisabled\n                case couldNotRetrieveConfiguration\n                \n                public var errorDescription: String? {\n                    switch self {\n                    case .integrationDisabled:\n                        return \"Integration disabled\"\n                        \n                    case .couldNotRetrieveConfiguration:\n                        return \"Error retrieving configuration\"\n                    }\n                }\n            }\n            \n            enum Publish: LocalizedError {\n                case couldNotPublishRiskData\n                case couldNotPersisRiskData\n                case fingerprintServiceIsNotConfigured\n                \n                public var errorDescription: String? {\n                    switch self {\n                    case .couldNotPublishRiskData:\n                        return \"Error publishing risk data\"\n                        \n                    case .couldNotPersisRiskData:\n                        return \"Error persisting risk data\"\n                        \n                    case .fingerprintServiceIsNotConfigured:\n                        return \"Fingerprint service is not configured. Please call configure() method first.\"\n                    }\n                }\n            }\n        }\n        ```\n        \u003c/details\u003e\n\nSee example below:\n```swift\nimport RiskSDK\n\n// Example usage of package\nlet yourConfig = RiskConfig(publicKey: \"pk_qa_xxx\", environment: RiskEnvironment.qa)\n\nself.riskSDK = Risk.init(config: yourConfig)  \n\nself.riskSDK.configure { configurationResult in\n\n\tswitch configurationResult {\n\tcase .failure(let errorResponse):\n\t\tprint(errorResponse.localizedDescription)\n\tcase .success():\n\t\tself.riskSDK.publishData { result in\n\t\t\t\n\t\t\tswitch result {\n\t\t\tcase .success(let response):\n\t\t\t\tprint(response.deviceSessionId)\n\t\t\tcase .failure(let errorResponse):\n\t\t\t\tprint(errorResponse.localizedDescription)\n\t\t\t}\n\t\t}\n\t}\n\t\n}   \n ```\n\n### Public API\nAside the instantiation via the `init` method, the package exposes two methods:\n1. `configure` - This method completes your setup after initialisation. When the method is called, preliminary checks are made to Checkout's internal API(s) that retrieves other configurations required for collecting device data, if the checks fail or the merchant is disabled, the error is returned and logged, you can also see more information on your Xcode console while in development mode.\n    \u003cdetails\u003e\n    \u003csummary\u003eType definitions\u003c/summary\u003e\n\n    ```swift\n    public func configure(completion: @escaping (Result\u003cVoid, RiskError.Configuration\u003e) -\u003e Void) {\n        ...\n    }\n    ```\n    \u003c/details\u003e\n\n\n2. `publishData` - This is used to publish and persist the device data.\n\n    \u003cdetails\u003e\n    \u003csummary\u003eType definitions\u003c/summary\u003e\n\n    ```swift\n    public func publishData (cardToken: String? = nil, completion: @escaping (Result\u003cPublishRiskData, RiskError.Publish\u003e) -\u003e Void) {\n            ...\n    }\n    ```\n    \u003c/details\u003e\n\n\n### Additional Resources\n\u003c!-- TODO: Add website documentation link here - [Risk iOS SDK documentation](https://docs.checkout.com/risk/overview) --\u003e\n- [Frames iOS SDK documentation](https://www.checkout.com/docs/developer-resources/sdks/frames-ios-sdk)\n\n## Demo projects\nOur sample application showcases our prebuilt UIs and how our SDK works. You can run this locally once you clone the repository (whether directly via git or with suggested integration methods).\n\nOur demo apps also test the supported integration methods (SPM, Cocoapods), so if you're having any problems there, they should offer a working example. You will find them in the root of the repository, inside respective folders:\n- iOSExampleRiskCocoapods - (Cocoapods distribution)\n- iOSExampleRiskSPM - (SPM distribution)\n \n## Changelog\nFind our CHANGELOG.md [here](https://github.com/checkout/checkout-risk-sdk-ios/blob/main/.github/CHANGELOG.md).\n\n## Contributing\nFind our guide to start contributing [here](https://github.com/checkout/checkout-risk-sdk-ios/blob/main/.github/CONTRIBUTING.md).\n\n## License\nRisk iOS is released under the MIT license. [See LICENSE](https://github.com/checkout/checkout-risk-sdk-ios/blob/main/LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcheckout%2Fcheckout-risk-sdk-ios","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcheckout%2Fcheckout-risk-sdk-ios","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcheckout%2Fcheckout-risk-sdk-ios/lists"}