-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5eb18e2
Showing
17 changed files
with
600 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.DS_Store | ||
/.build | ||
/Packages | ||
/*.xcodeproj | ||
xcuserdata/ | ||
.swiftpm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"object": { | ||
"pins": [ | ||
{ | ||
"package": "SwiftExtensionsPack", | ||
"repositoryURL": "https://github.com/nerzh/swift-extensions-pack.git", | ||
"state": { | ||
"branch": null, | ||
"revision": "b77864367a0a75ddf1fb0dd2daf472e0163888fa", | ||
"version": "0.3.0" | ||
} | ||
} | ||
] | ||
}, | ||
"version": 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// swift-tools-version:5.2 | ||
// The swift-tools-version declares the minimum version of Swift required to build this package. | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "WFPClient", | ||
platforms: [.iOS(.v11)], | ||
products: [ | ||
.library( | ||
name: "WFPClient", | ||
targets: ["WFPClient"]), | ||
], | ||
dependencies: [ | ||
.package(name: "SwiftExtensionsPack", url: "https://github.com/nerzh/swift-extensions-pack.git", from: "0.3.0"), | ||
], | ||
targets: [ | ||
.target( | ||
name: "WFPClient", | ||
dependencies: [ | ||
.product(name: "SwiftExtensionsPack", package: "SwiftExtensionsPack"), | ||
] | ||
) | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# WayForPay-Swift-Client | ||
|
||
A description of this package. |
85 changes: 85 additions & 0 deletions
85
Sources/WFPClient/ApplePay/Models/Request/WFPCharge+Request.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// | ||
// WFPCharge+Request.swift | ||
// PetsProjectApp | ||
// | ||
// Created by Oleh Hudeichuk on 04.04.2020. | ||
// Copyright © 2020 Oleh Hudeichuk. All rights reserved. | ||
// | ||
|
||
public struct WFPChargeRequest: Codable { | ||
|
||
public var apiVersion: Int | ||
public var transactionType: WFPTransactionType | ||
public var merchantAccount: String | ||
public var merchantDomainName: String | ||
public var orderReference: String | ||
public var orderDate: Int64 | ||
public var amount: Int | ||
public var currency: WFPCurrency | ||
public var productName: [String] | ||
public var productPrice: [Int] | ||
public var productCount: [Int] | ||
public var clientFirstName: String | ||
public var clientLastName: String | ||
public var clientCountry: String | ||
public var clientEmail: String | ||
public var clientPhone: String | ||
public var clientIpAddress: String | ||
public var merchantSignature: String | ||
public var merchantTransactionType: WFPMerchantTransactionType | ||
public var merchantTransactionSecureType: WFPMerchantTransactionSecureType | ||
public var applePayString: String | ||
public var socialUri: String | ||
/// max 1728000 sec; min 60 sec | ||
public var holdTimeout: Int | ||
|
||
public init(apiVersion: Int = 1, | ||
transactionType: WFPTransactionType, | ||
merchantAccount: String, | ||
merchantDomainName: String, | ||
orderReference: String, | ||
orderDate: Int64, | ||
amount: Int = 0, | ||
currency: WFPCurrency, | ||
productName: [String] = [], | ||
productPrice: [Int] = [], | ||
productCount: [Int] = [], | ||
clientFirstName: String, | ||
clientLastName: String, | ||
clientCountry: String, | ||
clientEmail: String, | ||
clientPhone: String, | ||
clientIpAddress: String = "127.0.0.1", | ||
merchantSignature: String = "", | ||
merchantTransactionType: WFPMerchantTransactionType, | ||
merchantTransactionSecureType: WFPMerchantTransactionSecureType, | ||
applePayString: String = "", | ||
socialUri: String = "", | ||
holdTimeout: Int = 1_728_000 | ||
) { | ||
self.apiVersion = apiVersion | ||
self.transactionType = transactionType | ||
self.merchantAccount = merchantAccount | ||
self.merchantDomainName = merchantDomainName | ||
self.orderReference = orderReference | ||
self.orderDate = orderDate | ||
self.amount = amount | ||
self.currency = currency | ||
self.productName = productName | ||
self.productPrice = productPrice | ||
self.productCount = productCount | ||
self.clientFirstName = clientFirstName | ||
self.clientLastName = clientLastName | ||
self.clientCountry = clientCountry | ||
self.clientEmail = clientEmail | ||
self.clientPhone = clientPhone | ||
self.clientIpAddress = clientIpAddress | ||
self.merchantSignature = merchantSignature | ||
self.merchantTransactionType = merchantTransactionType | ||
self.merchantTransactionSecureType = merchantTransactionSecureType | ||
self.applePayString = applePayString | ||
self.socialUri = socialUri | ||
self.holdTimeout = holdTimeout | ||
} | ||
} | ||
|
37 changes: 37 additions & 0 deletions
37
Sources/WFPClient/ApplePay/Models/Response/WFPCharge+Response.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// WFPCharge+Response.swift | ||
// PetsProjectApp | ||
// | ||
// Created by Oleh Hudeichuk on 04.04.2020. | ||
// Copyright © 2020 Oleh Hudeichuk. All rights reserved. | ||
// | ||
|
||
public struct WFPChargeResponse: Codable { | ||
|
||
public var reason: String | ||
public var reasonCode: WFPReasonCode | ||
public var merchantAccount: String? | ||
public var authTicket: String? | ||
public var orderReference: String? | ||
public var merchantSignature: String? | ||
public var amount: Double? | ||
public var currency: WFPCurrency? | ||
public var authCode: String? | ||
public var email: String? | ||
public var phone: String? | ||
public var createdDate: Int? | ||
public var processingDate: Int? | ||
public var cardPan: String? | ||
public var cardType: String? | ||
public var issuerBankCountry: String? | ||
public var issuerBankName: String? | ||
public var recToken: String? | ||
public var transactionStatus: WFPTransactionStatus? | ||
public var fee: Double? | ||
public var paymentSystem: String? | ||
public var merchantTransactionType: WFPMerchantTransactionType? | ||
public var d3AcsUrl: String? | ||
public var d3Md: String? | ||
public var d3Pareq: String? | ||
public var returnUrl: String? | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Oleh Hudeichuk on 05.04.2020. | ||
// | ||
|
||
import Foundation | ||
import SwiftExtensionsPack | ||
|
||
open class WFPHttpClient: WFPHttpClientPrtcl { | ||
|
||
public init() {} | ||
|
||
public func sendRequest(url: URL, | ||
method: WFPHttpMethod, | ||
body: Data, | ||
_ handler: @escaping (Result<Data, Error>) -> Void | ||
) throws { | ||
try Net.sendRequest(url: url.absoluteString, | ||
method: method.rawValue, | ||
body: body | ||
) { (data, response, error) in | ||
if let data = data { | ||
handler(.success(data)) | ||
} else if let error = error { | ||
handler(.failure(error)) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// WFPHttpClientPrtcl.swift | ||
// | ||
// | ||
// Created by Oleh Hudeichuk on 05.04.2020. | ||
// | ||
|
||
import Foundation | ||
|
||
public protocol WFPHttpClientPrtcl { | ||
|
||
func sendRequest(url: URL, method: WFPHttpMethod, body: Data, _ handler: @escaping (Result<Data, Error>) -> Void) throws | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// WFPHttpMethod.swift | ||
// | ||
// | ||
// Created by Oleh Hudeichuk on 05.04.2020. | ||
// | ||
|
||
import Foundation | ||
|
||
public enum WFPHttpMethod: String { | ||
case GET | ||
case POST | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// WFPCurrency.swift | ||
// PetsProjectApp | ||
// | ||
// Created by Oleh Hudeichuk on 04.04.2020. | ||
// Copyright © 2020 Oleh Hudeichuk. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public enum WFPCurrency: String, Codable { | ||
case UAH | ||
case USD | ||
case EUR | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Oleh Hudeichuk on 05.04.2020. | ||
// | ||
|
||
import Foundation | ||
|
||
public enum WFPError: Error, CustomStringConvertible { | ||
case codableError | ||
|
||
public var description: String { | ||
switch self { | ||
case .codableError: | ||
return "Can't convert to codable model" | ||
} | ||
} | ||
|
||
public var localizedDescription: String { description } | ||
} |
14 changes: 14 additions & 0 deletions
14
Sources/WFPClient/Helpers/WFPMerchantTransactionSecureType.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// WFPMerchantTransactionSecureType.swift | ||
// | ||
// | ||
// Created by Oleh Hudeichuk on 05.04.2020. | ||
// | ||
|
||
import Foundation | ||
|
||
public enum WFPMerchantTransactionSecureType: String, Codable { | ||
case AUTO = "AUTO" | ||
case ThreeDS = "3DS" | ||
case NON3DS = "NON3DS" | ||
} |
13 changes: 13 additions & 0 deletions
13
Sources/WFPClient/Helpers/WFPMerchantTransactionType.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// WFPMerchantTransactionType.swift | ||
// | ||
// | ||
// Created by Oleh Hudeichuk on 05.04.2020. | ||
// | ||
|
||
import Foundation | ||
|
||
public enum WFPMerchantTransactionType: String, Codable { | ||
case SALE | ||
case AUTH | ||
} |
Oops, something went wrong.