Skip to content

Commit

Permalink
init ~ 0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
nerzh committed Apr 5, 2020
0 parents commit 5eb18e2
Show file tree
Hide file tree
Showing 17 changed files with 600 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.DS_Store
/.build
/Packages
/*.xcodeproj
xcuserdata/
.swiftpm
16 changes: 16 additions & 0 deletions Package.resolved
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
}
25 changes: 25 additions & 0 deletions Package.swift
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"),
]
)
]
)
3 changes: 3 additions & 0 deletions README.md
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 Sources/WFPClient/ApplePay/Models/Request/WFPCharge+Request.swift
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
}
}

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?
}
31 changes: 31 additions & 0 deletions Sources/WFPClient/HTTP/WFPHttpClient.swift
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))
}
}
}
}
13 changes: 13 additions & 0 deletions Sources/WFPClient/HTTP/WFPHttpClientPrtcl.swift
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
}
13 changes: 13 additions & 0 deletions Sources/WFPClient/HTTP/WFPHttpMethod.swift
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
}
15 changes: 15 additions & 0 deletions Sources/WFPClient/Helpers/WFPCurrency.swift
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
}
21 changes: 21 additions & 0 deletions Sources/WFPClient/Helpers/WFPError.swift
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 Sources/WFPClient/Helpers/WFPMerchantTransactionSecureType.swift
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 Sources/WFPClient/Helpers/WFPMerchantTransactionType.swift
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
}
Loading

0 comments on commit 5eb18e2

Please sign in to comment.