Skip to content

Commit

Permalink
Merge pull request #2 from TrustlyInc/DEV-140990-available-from-swp
Browse files Browse the repository at this point in the history
[Dev 140990] Available from swp
  • Loading branch information
marcosrivereto authored Jun 9, 2023
2 parents 7440f40 + 44e93cd commit 3a17e6f
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 90 deletions.
2 changes: 1 addition & 1 deletion Example/TrustlySDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

/* Begin PBXFileReference section */
15987B0829DEF79D00D7A395 /* TrustlyLightBoxViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrustlyLightBoxViewController.swift; sourceTree = "<group>"; };
2416E32056EECA07B4C86E1B /* TrustlySDK.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = TrustlySDK.podspec; path = ../TrustlySDK.podspec; sourceTree = "<group>"; };
2416E32056EECA07B4C86E1B /* TrustlySDK.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = TrustlySDK.podspec; path = ../TrustlySDK.podspec; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
24C6055BF6640A73038BF66E /* Pods_TrustlySDK_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_TrustlySDK_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; };
38845E178FF73A019452105E /* Pods-TrustlySDK_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TrustlySDK_Tests.debug.xcconfig"; path = "Target Support Files/Pods-TrustlySDK_Tests/Pods-TrustlySDK_Tests.debug.xcconfig"; sourceTree = "<group>"; };
4374DB88B53812152BC15F73 /* Pods-TrustlySDK_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TrustlySDK_Tests.release.xcconfig"; path = "Target Support Files/Pods-TrustlySDK_Tests/Pods-TrustlySDK_Tests.release.xcconfig"; sourceTree = "<group>"; };
Expand Down
4 changes: 1 addition & 3 deletions Example/TrustlySDK/TrustlyLightBoxViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
// TrustlyLightBoxViewController.swift
// TrustlySDK_Example
//
// Created by Marcos Rivereto on 06/04/23.
// Copyright © 2023 CocoaPods. All rights reserved.
//


import Foundation
import TrustlySDK
Expand Down
34 changes: 16 additions & 18 deletions Example/TrustlySDK/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
// ViewController.swift
// TrustlySDK
//
// Created by Marcos Rivereto on 04/06/2023.
// Copyright (c) 2023 Marcos Rivereto. All rights reserved.
//


import UIKit
import TrustlySDK
Expand All @@ -21,21 +19,21 @@ class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()

self.establishData = ["accessId": "A48B73F694C4C8EE6306",
"merchantId" : "110005514",
"currency" : "USD",
"amount" : "1.00",
"merchantReference" : "cac73df7-52b4-47d7-89d3-9628d4cfb65e",
"paymentType" : "Retrieval",
"returnUrl": "/returnUrl",
"cancelUrl": "/cancelUrl",
"requestSignature": "HT5mVOqBXa8ZlvgX2USmPeLns5o=",
"customer.name": "John",
"customer.address.country": "US",
"metadata.urlScheme": "demoapp://",
"description": "First Data Mobile Test",
"env": "sandbox",
"localUrl": "192.168.0.13:8000"]
self.establishData = ["accessId": "<ACCESS_ID>",
"merchantId" : "<MERCHANT_ID>",
"currency" : "USD",
"amount" : "1.00",
"merchantReference" : "<MERCHANT_REFERENCE>",
"paymentType" : "Retrieval",
"returnUrl": "/returnUrl",
"cancelUrl": "/cancelUrl",
"requestSignature": "<REQUEST_SIGNATURE>",
"customer.name": "John",
"customer.address.country": "US",
"metadata.urlScheme": "demoapp://",
"description": "First Data Mobile Test",
"env": "<[int, sandbox, local]>",
"localUrl": "<YOUR LOCAL URL WHEN `ENV` PROPERTY IS `LOCAL` (ex: https://192.168.0.30:8000)>"]

self.trustlyView.onChangeListener { (eventName, attributes) in
print("onChangeListener: \(eventName) \(attributes)")
Expand Down
21 changes: 21 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "TrustlySDK",
platforms: [.iOS(.v12)],
products: [


.library(
name: "TrustlySDK",
targets: ["TrustlySDK"]),
],
targets: [
.target(
name: "TrustlySDK",
dependencies: []),
]
)
99 changes: 33 additions & 66 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[![Platform](https://badgen.net/badge/iOS/v12/green?icon=swift)](https://cocoapods.org/pods/TrustlySDK)
[![Cocoapods Version](https://badgen.net/badge/cocoapods/v1.12.0/blue?icon=swift)](https://cocoapods.org/pods/TrustlySDK)
[![Pod Version](https://badgen.net/badge/pod/v3.0.0/yellow?icon=swift)](https://cocoapods.org/pods/TrustlySDK)
[![Swift Package Maager](https://badgen.net/badge/spm/available/green?icon=swift)](https://cocoapods.org/pods/TrustlySDK)

## Example App
---
Expand All @@ -16,80 +17,48 @@ To run the example project, clone the repo, and run `pod install` from the Examp

## Installation
---
- ### Cocoapods
TrustlySDK is available through [CocoaPods](https://cocoapods.org). To install
it, simply add the following line to your Podfile:
<details open>
<summary>Cocoapods</summary>
<br />

TrustlySDK is available through [CocoaPods](https://cocoapods.org). To install
it, simply add the following line to your Podfile:

```ruby
pod 'TrustlySDK'
```

For development and test reasons, you can install the pod from a branch in github:
```ruby
pod 'TrustlySDK', :git => 'https://github.com/TrustlyInc/trustly-ios.git', :branch => '<BRANCH_NAME>'
```
</details>

<details open>
<summary>Swift Package Manager - SPM</summary>
<br />
TrustlySDK is available through [Swift Package Manager](https://cocoapods.org). To install
it, simply click on File -> Add packages -> Search or Enter Package URL, paste the github url about this package `https://github.com/TrustlyInc/trustly-ios.git`:

```ruby
pod 'TrustlySDK'
```
![Add package url](docs/images/swift_package_manager.png)

For development and test reasons, you can install the pod from a branch in github:
```ruby
pod 'TrustlySDK', :git => 'https://github.com/TrustlyInc/trustly-ios.git', :branch => '<BRANCH_NAME>'
```
For production reason choose the `main` branch, but for test or validation choose the branch described in the [release version table](#versions).
</details>
<br />

## Usage

```swift
import TrustlySDK
class ViewController: UIViewController {
...
override func viewDidLoad() {
super.viewDidLoad()
self.establishData = ["accessId": "<ACCESS_ID>",
"merchantId" : "<MERCHANT_ID>",
"currency" : "USD",
"amount" : "1.00",
"merchantReference" : "<MERCHANT_REFERENCE>",
"paymentType" : "Retrieval",
"returnUrl": "/returnUrl",
"cancelUrl": "/cancelUrl",
"requestSignature": "<REQUEST_SIGNATURE>",
"customer.name": "John",
"customer.address.country": "US",
"metadata.urlScheme": "demoapp://",
"description": "First Data Mobile Test",
"env": "<[int, sandbox, local]>",
"localUrl": "<YOUR LOCAL URL WHEN `ENV` PROPERTY IS `LOCAL` (ex: https://192.168.0.30:8000)>"]
self.trustlyView.onChangeListener { (eventName, attributes) in
print("onChangeListener: \(eventName) \(attributes)")
}
self.trustlyView.selectBankWidget(establishData: establishData) { (view, data) in
print("returnParameters:\(data)")
self.establishData = data
}
self.view = trustlyLightboxPanel.establish(establishData: establishData,
onReturn: {(payWithMyBank, returnParameters)->Void in
let response = returnParameters as! [String:String]
//TODO: implement your success behavior here
}, onCancel: {(payWithMyBank, returnParameters)->Void in
let response = returnParameters as! [String:String]
//TODO: implement your cancel or failure behavior here
})
}
...
}
```
To quickly get up and running with this SDK see the [iOS Quickstart](https://amer.developers.trustly.com/payments/docs/ios-quickstart) in the Trustly Developer Documentation.


<br />

## Versions
___

| VERSION | DESCRIPTION |
| :-------: | :----------- |
3.0.0 | Add cocoapods, and swift package manager support
| VERSION | DESCRIPTION | BRANCH |
| :-------: | :----------- | :----------- |
3.0.0 | Add cocoapods, and swift package manager support | *main*


<br />
Expand All @@ -98,5 +67,3 @@ ___
___

TrustlySDK is available under the MIT license. See the LICENSE file for more info.


3 changes: 1 addition & 2 deletions Sources/TrustlySDK/TrustlySDK.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
// TrustlySDK.swift
// Pods
//
// Created by Marcos Rivereto on 30/03/23.
//

import Foundation
import UIKit

public typealias TrustlyCallback = (_ trustlyView: UIView, _ returnParameters: [AnyHashable : Any]) -> Void;
public typealias ExternalUrlCallback = (_ request: NSURLRequest?) -> Void?;
Expand Down
Binary file added docs/images/swift_package_manager.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3a17e6f

Please sign in to comment.