text 用于保存您的payfort付款信息的枚举

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text 用于保存您的payfort付款信息的枚举相关的知识,希望对你有一定的参考价值。

enum PayFortCredintials {
    case development(udid: String)
    case production(udid: String)
    
    var merchantId: String {
        switch self {
        case .development:
            return "dfadf23"
        default:
            return "dsafq34r"
        }
    }
    
    var accessCode: String {
        switch self {
        case .development:
            return "wO5asdfasdzw57vUbYE1"
        default:
            return "adsfadsfAMIP3qewH9hrtm"
        }
    }
    
    
    var shaRequest: String {
        switch self {
        case .development:
            return "adsfajytjijht"
        default:
            return "dadsf3*4$T#^$@&g"
        }
    }
    
    var currency: String { return "SAR" }
    
    
    func signature(uid: String) -> String {
        return Encryption.sha256Hex(string: self.preSignature(uid)) ?? "Can't happen."
    }
    
    private func preSignature(_ uid: String) -> String {
        return self.shaRequest + "access_code=\(self.accessCode)" + "device_id=\(uid)" + "language=enmerchant_identifier=\(self.merchantId)" + "service_command=SDK_TOKEN\(self.shaRequest)"
    }
    
   
    
    func parameters(with udid: String) -> [String: Any] {
        return ["access_code": accessCode,
                "device_id": udid,
                "language": "en",
                "merchant_identifier": merchantId,
                "service_command": "SDK_TOKEN",
                "signature": signature(uid: udid)
        ]
    }
}

enum ServerPaths {
    case payfortSDKToken = "FortAPI/paymentApi"
}


extension PayFortCredintials: URLRequestBuilder {
    var method: HTTPMethod {
        return .post
    }
    
    var mainURL: URL {
        switch self {
        case .development:
            return URL(string: "https://sbpaymentservices.payfort.com")!
        default:
            return URL(string: "https://paymentservices.payfort.com")!
        }
    }
    var path: ServerPaths {
        return .payfortSDKToken
    }
    
    var parameters: Parameters? {
        switch self {
        case .development(let udid):
            return parameters(with: udid)
        case .production(let udid):
            return parameters(with: udid)
        }
    }

    var headers: HTTPHeaders {
        var headers = HTTPHeaders()
        headers["Content-type"] = "application/x-www-form-urlencoded; charset=utf-8"
        headers["Content-type"] = "application/json"
        headers["Accept"] = "application/json"
        return headers
    }
}

以上是关于text 用于保存您的payfort付款信息的枚举的主要内容,如果未能解决你的问题,请参考以下文章

GoDaddy用支付宝付款时出现我们无法处理这笔交易,请查看您的付款信息并重试。

付款时银行无法验证您的 VISA

无法保存您的应用信息。再试一次 - iTunesConnect [关闭]

如何保存用户卡详细信息并稍后在 PayPal 中付款?

npm安装比特币 - 接收 - 付款 - 保存

关于 PayPal Pro 付款