HyperwalletSDK 1.0.0-beta20

HyperwalletSDK 1.0.0-beta20

由以下人员维护: Peter OlamitBlair OlynykJaspreet SainiDebojit DharFlavio Ferreira de MattosGustavo MeyerMaximilian Was Damji



HyperwalletSDK 1.0.0-beta20

  • Hyperwallet Systems Inc

Hyperwallet iOS Core SDK

Platforms Build Status Coverage Status

CocoaPods Carthage compatible

注意:这是一个beta产品,可用于您的移动应用程序。如果您对使用此产品感兴趣,请通知您的客户经理和/或项目经理,以便在集成过程中支持您。

欢迎使用Hyperwallet的iOS SDK。此库将帮助您在iOS应用程序中创建转账方式,如银行账户、PayPal账户等。查看我们的iOS集成指南开始使用!

请注意,此SDK面向仅需要后端数据的用户,这意味着您将需要自己构建用户界面。

如果您决定不构建自己的UI,我们还提供即用的Hyperwallet iOS UI SDK

先决条件

  • Hyperwallet商家账户
  • 设置您的服务器以管理用户在Hyperwallet平台上的认证过程。请参阅认证部分以获取更多信息。
  • iOS 13.0+
  • Xcode 10.2+
  • Swift 5.0

安装

使用CarthageCocoaPods集成HyperwalletSDK。

Carthage

在Cartfile中指定它

github "hyperwallet/hyperwallet-ios-sdk" "1.0.0-beta17"

CocoaPods

在Podfile中指定它

pod 'HyperwalletSDK', '~> 1.0.0-beta17'

初始化

安装SDK后,您需要初始化一个实例,以便使用核心SDK功能。还需要提供一个HyperwalletAuthenticationTokenProvider对象来检索身份验证令牌。

添加到头文件中

import HyperwalletSDK

使用一个HyperwalletAuthenticationTokenProvider实现实例初始化HyperwalletSDK

Hyperwallet.setup(authenticationTokenProvider :HyperwalletAuthenticationTokenProvider)

身份验证

您的服务器端应能够向 Hyperwallet 端点 /rest/v3/users/{用户令牌}/authentication-token 发送 POST 请求以获取 身份验证令牌。然后,您需要提供一个类(身份验证提供程序),该类实现 HyperwalletAuthenticationTokenProvider 从您的服务器获取身份验证令牌。

使用 Swift Foundation 的 URLRequest 的示例实现

import Foundation
import HyperwalletSDK

public class AuthenticationTokenProvider: HyperwalletAuthenticationTokenProvider {
    private let url = URL(string: "http://your/server/to/retrieve/authenticationToken")!

    public func retrieveAuthenticationToken(
        completionHandler: @escaping HyperwalletAuthenticationTokenProvider.CompletionHandler) {

        var request = URLRequest(url: url)
        request.httpMethod = "POST"
        request.addValue("application/json", forHTTPHeaderField: "Content-Type")

        let defaultSession = URLSession(configuration: .default)
        let task = defaultSession.dataTask(with: request) {(data, response, error) in
            DispatchQueue.main.async {
                    guard let data = data,
                        let clientToken = String(data: data, encoding: .utf8),
                        let response = response as? HTTPURLResponse else {
                            completionHandler(nil, HyperwalletAuthenticationErrorType.unexpected(error?.localizedDescription ??
                                "authentication token cannot be retrieved"))
                            return
                    }

                    switch response.statusCode {
                        case 200 ..< 300:
                            completionHandler(clientToken, nil)

                        default:
                            completionHandler(nil, HyperwalletAuthenticationErrorType
                                .unexpected("authentication token cannot be retrieved"))
                }
            }
        }
        task.resume()
    }
}

使用方法

完成身份验证后,核心 SDK 中的功能即可使用。

获取用户

Hyperwallet.shared.getUser { (user, error) in
    guard error == nil else {
        print(error?.getHyperwalletErrors()?.errorList?)
        return
    }

    print(user?.firstName)
    print(user?.lastName)
}

创建 PayPal 账户

let payPalAccount = HyperwalletPayPalAccount.Builder(transferMethodCountry: "US", transferMethodCurrency: "USD")
    .email("[email protected]")
    .build()

Hyperwallet.shared.createPayPalAccount(account: payPalAccount, completion: { (result, error) in
    // Code to handle successful response or error
    // On successful creation, response (HyperwalletPayPalAccount in this case) will contain information about the user’s PayPal account
    // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure of PayPal account creation
})

获取 PayPal 账户

Hyperwallet.shared.getPayPalAccount(transferMethodToken: "123123", completion: { (result, error) in
    // On success, response (HyperwalletPayPalAccount? in this case) will contain information about the user’s PayPal account or nil if not exist.
    // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure
})

更新 PayPal 账户

let payPalAccount = HyperwalletPayPalAccount.Builder(token: "trm-12345")
    .email("[email protected]")
    .build()

Hyperwallet.shared.updatePayPalAccount(account: payPalAccount, completion: { (result, error) in
    // Code to handle successful response or error
    // On successful update, response (HyperwalletPayPalAccount in this case) will contain information about the user’s PayPal account
    // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure of PayPal account updating
})

禁用PayPal账户

Hyperwallet.shared.deactivatePayPalAccount(transferMethodToken: "trm-12345", notes: "deactivate PayPal account", completion: { (result, error) in
    // Code to handle successful response or error
    // On successful deactivation, response (HyperwalletStatusTransition in this case) will contain information about the status transition
    // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure of PayPal account deactivation
})

列出PayPal账户

let payPalQueryParam = HyperwalletPayPalAccountQueryParam()
payPalQueryParam.status = HyperwalletPayPalAccountQueryParam.QueryStatus.activated.rawValue
payPalQueryParam.sortBy = HyperwalletTransferMethodQueryParam.QuerySortable.ascendantCreatedOn.rawValue

Hyperwallet.shared.listPayPalAccounts(queryParam: payPalQueryParam) { (result, error) in
    // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure
    guard error == nil else {
        print(error?.getHyperwalletErrors()?.errorList?)
        return
    }

    // On success, response (HyperwalletPageList<HyperwalletPayPalAccount>? in this case) will contain information about or nil if not exist.
    if let payPalAccounts = result?.data {
        for payPalAccount in payPalAccounts {
        print(payPalAccount.getField(fieldName: .token) ?? "")
        }
    }
}

创建Venmo账户

let venmoAccount = HyperwalletVenmoAccount.Builder(transferMethodCountry: "US", transferMethodCurrency: "USD")
    .accountId("9876543210")
    .build()

Hyperwallet.shared.createVenmoAccount(account: venmoAccount, completion: { (result, error) in
    // Code to handle successful response or error
    // On successful creation, response (HyperwalletVenmoAccount in this case) will contain information about the user’s Venmo account
    // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure of Venmo account creation
})

获取Venmo账户

Hyperwallet.shared.getVenmoAccount(transferMethodToken: "123123", completion: { (result, error) in
    // On success, response (HyperwalletVenmoAccount? in this case) will contain information about the user’s Venmo account or nil if not exist.
    // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure
})

更新Venmo账户

let venmoAccount = HyperwalletVenmoAccount.Builder(token: "trm-12345")
    .accountId("9876543210")
    .build()

Hyperwallet.shared.updateVenmoAccount(account: venmoAccount, completion: { (result, error) in
    // Code to handle successful response or error
    // On successful update, response (HyperwalletVenmoAccount in this case) will contain information about the user’s Venmo account
    // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure of Venmo account updating
})

停用Venmo账户

Hyperwallet.shared.deactivateVenmoAccount(transferMethodToken: "trm-12345", notes: "deactivate Venmo account", completion: { (result, error) in
    // Code to handle successful response or error
    // On successful deactivation, response (HyperwalletStatusTransition in this case) will contain information about the status transition
    // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure of Venmo account deactivation
})

列出Venmo账户

let venmoQueryParam = HyperwalletVenmoQueryParam()
venmoQueryParam.status = HyperwalletVenmoQueryParam.QueryStatus.activated.rawValue
venmoQueryParam.sortBy = HyperwalletVenmoQueryParam.QuerySortable.ascendantCreatedOn.rawValue

Hyperwallet.shared.listVenmoAccounts(queryParam: venmoQueryParam) { (result, error) in
    // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure
    guard error == nil else {
        print(error?.getHyperwalletErrors()?.errorList?)
        return
    }

    // On success, response (HyperwalletPageList<HyperwalletVenmoAccount>? in this case) will contain information about or nil if not exist.
    if let venmoAccounts = result?.data {
        for venmoAccount in venmoAccounts {
           print(venmoAccount.getField(fieldName: .token) ?? "")
        }
    }
}

创建银行账户

let bankAccount = HyperwalletBankAccount.Builder(transferMethodCountry: "US",   
                                                 transferMethodCurrency: "USD",
                                                 transferMethodProfileType: "INDIVIDUAL")
.bankAccountId("12345")
.branchId("123456")
.bankAccountPurpose(.checking)
.build()

Hyperwallet.shared.createBankAccount(account: bankAccount, completion: { (result, error) in
    // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure of account creation
    guard error == nil else {
        print(error?.getHyperwalletErrors()?.errorList?)
        return
    }   

    // On successful creation, response (HyperwalletBankAccount in this case) payload will contain information about the account created
    print(result)
})

获取银行账户信息

Hyperwallet.shared.getBankAccount(transferMethodToken: "123123", completion: { (result, error) in
    // On success, response (HyperwalletBankCard? in this case) will contain information about the user’s bank account or nil if not exist.
    // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure
})

更新银行账户信息

let bankAccount = HyperwalletBankAccount
.Builder(token: "12345")
.branchId("026009593")
.build()

Hyperwallet.shared.updateBankAccount(account: bankAccount, completion: { (response, error) in
    // Code to handle successful response or error
    // On successful update, response (HyperwalletBankAccount in this case) payload will contain information about the account updated
    // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure of account updating
})

停用银行账户

Hyperwallet.shared.deactivateBankAccount(transferMethodToken: "trm-12345", notes: "deactivate bank account", completion: { (result, error) in
    // Code to handle successful response or error
    // On successful deactivation, response (HyperwalletStatusTransition in this case) will contain information about the status transition
    // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure of account deactivation
})

列出银行账户

let bankAccountQueryParam = HyperwalletBankAccountQueryParam()
bankAccountQueryParam.status = HyperwalletBankAccountQueryParam.QueryStatus.activated.rawValue
bankAccountQueryParam.sortBy = HyperwalletBankAccountQueryParam.QuerySortable.ascendantCreatedOn.rawValue

Hyperwallet.shared.listBankAccounts(queryParam: bankAccountQueryParam) { (result, error) in
    // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure
    guard error == nil else {
        print(error?.getHyperwalletErrors()?.errorList?)
        return
    }

    // On success, response (HyperwalletPageList<HyperwalletBankAccount>? in this case) will contain information about or nil if not exist.
    if let bankAccounts = result?.data {
        for bankAccount in bankAccounts {
            print(bankAccount.token ?? "")
        }
    }
}

创建纸质支票

let paperCheck = HyperwalletPaperCheck.Builder(transferMethodCountry: "US",   
                                               transferMethodCurrency: "USD",
                                               transferMethodProfileType: "INDIVIDUAL")
.shippingMethod("STANDARD")
.build()

Hyperwallet.shared.createPaperCheck(account: paperCheck, completion: { (result, error) in
    // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure of account creation
    guard error == nil else {
        print(error?.getHyperwalletErrors()?.errorList?)
        return
    }   

    // On successful creation, response (HyperwalletPaperCheck in this case) payload will contain information about the paper check created
    print(result)
})

获取纸质支票

Hyperwallet.shared.getPaperCheck(transferMethodToken: "123123", completion: { (result, error) in
    // On success, response (HyperwalletPaperCheck? in this case) will contain information about the user’s paper check or nil if not exist.
    // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure
})

更新纸质支票

let paperCheck = HyperwalletPaperCheck
.Builder(token: "12345")
.shippingMethod("STANDARD")
.build()

Hyperwallet.shared.updatePaperCheck(account: paperCheck, completion: { (response, error) in
    // Code to handle successful response or error
    // On successful update, response (HyperwalletPaperCheck in this case) payload will contain information about the paper check updated
    // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure while updating
})

停用纸质支票

Hyperwallet.shared.deactivatePaperCheck(transferMethodToken: "trm-12345", notes: "deactivate paper check", completion: { (result, error) in
    // Code to handle successful response or error
    // On successful deactivation, response (HyperwalletStatusTransition in this case) will contain information about the status transition
    // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure
})

列出纸质支票

let paperCheckQueryParam = HyperwalletPaperCheckQueryParam()
paperCheckQueryParam.status = HyperwalletPaperCheckQueryParam.QueryStatus.activated.rawValue
paperCheckQueryParam.sortBy = HyperwalletPaperCheckQueryParam.QuerySortable.ascendantCreatedOn.rawValue

Hyperwallet.shared.listPaperChecks(queryParam: paperCheckQueryParam) { (result, error) in
    // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure
    guard error == nil else {
        print(error?.getHyperwalletErrors()?.errorList?)
        return
    }

    // On success, response (HyperwalletPageList<HyperwalletPaperCheck>? in this case) will contain information about or nil if not exist.
    if let paperChecks = result?.data {
        for paperCheck in paperChecks {
            print(paperCheck.token ?? "")
        }
    }
}

创建银行卡

let bankCard = HyperwalletBankCard.Builder(transferMethodCountry: "US",
                                           transferMethodCurrency: "USD",
                                           transferMethodProfileType: "INDIVIDUAL")
.cardNumber("1234123412341234")
.dateOfExpiry("2022-12")
.cvv("123")
.build()

Hyperwallet.shared.createBankCard(account: bankCard, completion: { (result, error) in
    // Code to handle successful response or error
    // On successful creation, response (HyperwalletBankCard in this case) will contain information about the user’s bank card
    // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure of bank card creation
})

获取银行卡

Hyperwallet.shared.getBankCard(transferMethodToken: "123123", completion: { (result, error) in
    // On success, response (HyperwalletBankCard? in this case) will contain information about the user’s bank card or nil if not exist.
    // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure
})

更新银行卡

let bankCard = HyperwalletBankCard
.Builder(token: "trm-12345")
.dateOfExpiry("2022-12")
.build()

Hyperwallet.shared.updateBankCard(account: bankCard, completion: { (result, error) in
    // Code to handle successful response or error
    // On successful update, response (HyperwalletBankCard in this case) will contain information about the user’s bank card
    // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure of bank card updating
})

停用银行卡

Hyperwallet.shared.deactivateBankCard(transferMethodToken: "trm-12345", notes: "deactivate bank card", completion: { (result, error) in
    // Code to handle successful response or error
    // On successful deactivation, response (HyperwalletStatusTransition in this case) will contain information about the status transition
    // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure of bank card deactivation
})

列出银行卡

let bankCardQueryParam = HyperwalletBankCardQueryParam()
bankCardQueryParam.status = HyperwalletBankCardQueryParam.QueryStatus.activated.rawValue
bankCardQueryParam.sortBy = HyperwalletBankCardQueryParam.QuerySortable.ascendantCreatedOn.rawValue

Hyperwallet.shared.listBankCards(queryParam: bankCardQueryParam) { (result, error) in
    // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure
    guard error == nil else {
        print(error?.getHyperwalletErrors()?.errorList?)
        return
    }

    // On success, response (HyperwalletPageList<HyperwalletBankCard>? in this case) will contain information about or nil if not exist.
    if let bankCards = result?.data {
        for bankCard in bankCards {
            print(bankCard.token ?? "")
        }
    }
}

获取预付卡

Hyperwallet.shared.getPrepaidCard(transferMethodToken: "123123", completion: { (result, error) in
    // On success, response (HyperwalletPrepaidCard? in this case) will contain information about the user’s prepaid card or nil if not exist.
    // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure
})

列出预付卡

let prepaidCardQueryParam = HyperwalletPrepaidCardQueryParam()
prepaidCardQueryParam.status = HyperwalletPrepaidCardQueryParam.QueryStatus.activated.rawValue
prepaidCardQueryParam.sortBy = HyperwalletPrepaidCardQueryParam.QuerySortable.ascendantCreatedOn.rawValue

Hyperwallet.shared.listPrepaidCards(queryParam: prepaidCardQueryParam) { (result, error) in
    // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure
    guard error == nil else {
        print(error?.getHyperwalletErrors()?.errorList?)
        return
    }

    // On success, response (HyperwalletPageList<HyperwalletPrepaidCard>? in this case) will contain information about or nil if not exist.
    if let prepaidCards = result?.data {
        for prepaidCard in prepaidCards {
            print(prepaidCard.token)
        }
    }
}

列出预付卡收据

let receiptQueryParam = HyperwalletReceiptQueryParam()
receiptQueryParam.createdAfter = ISO8601DateFormatter.ignoreTimeZone.date(from: "2016-12-01T00:00:00")

Hyperwallet.shared.listPrepaidCardReceipts(prepaidCardToken: prepaidCardToken,
                                           queryParam: receiptQueryParam,
                                           completion: { (result, error) in
    // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure
    guard error == nil else {
        print(error?.getHyperwalletErrors()?.errorList?)
        return
    }

    // On success, response (HyperwalletPageList<HyperwalletReceipt>? in this case) will contain information about or nil if not exist.
    if let receipts = result?.data {
        for receipt in receipts {
            print(receipt.destinationToken ?? "")
        }
    }
}

用户收据列表

let receiptQueryParam = HyperwalletReceiptQueryParam()
receiptQueryParam.createdAfter = ISO8601DateFormatter.ignoreTimeZone.date(from: "2018-12-01T00:00:00")
receiptQueryParam.currency = "USD"
receiptQueryParam.sortBy = HyperwalletReceiptQueryParam.QuerySortable.descendantAmount.rawValue

Hyperwallet.shared.listUserReceipts(queryParam: receiptQueryParam) { (result, error) in
    // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure
    guard error == nil else {
        print(error?.getHyperwalletErrors()?.errorList?)
        return
        }

    // On success, response (HyperwalletPageList<HyperwalletReceipt>? in this case) will contain information about or nil if not exist.
    if let receipts = result?.data {
        for receipt in receipts {
            print(receipt.destinationToken ?? "")
        }
    }
}

转账方式列表

let transferMethodQueryParam = HyperwalletTransferMethodQueryParam()
transferMethodQueryParam.sortBy = HyperwalletTransferMethodQueryParam.QuerySortable.ascendantCreatedOn.rawValue

Hyperwallet.shared.listTransferMethods(queryParam: transferMethodQueryParam) { (result, error) in
    // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure
    guard error == nil else {
        print(error?.getHyperwalletErrors()?.errorList?)
        return
    }

    // On success, response (HyperwalletPageList<HyperwalletTransferMethod>? in this case) will contain information about or nil if not exist.
    if let transferMethods = result?.data {
        for transferMethod in transferMethods {
            print(transferMethod.token ?? "")
        }
    }
}

创建转账

let transfer = HyperwalletTransfer.Builder(clientTransferId: "6712348070812",
                                           sourceToken: "source-token",
                                           destinationToken: "destination-token")
    .sourceAmount("100")
    .sourceCurrency("CAD")
    .destinationAmount("62.29")
    .destinationCurrency("USD")
    .memo("TransferClientId56387")
    .notes("Partial-Balance Transfer")
    .build()

Hyperwallet.shared.createTransfer(transfer: transfer, completion: { (result, error) in
    //Code to handle successful response or error
    //On successfull creation, response (HyperwalletTransfer in this case) will contain information about the transfer
    //in case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure of transfer creation
})

安排转账

Hyperwallet.shared.scheduleTransfer(transferToken: "trf-123456", completion: { (result, error) in
    //Code to handle successful response or error
    // On successful scheduling, response (HyperwalletStatusTransition in this case) will contain information about the status transition
    //in case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure of transfer creation
})

获取转账

Hyperwallet.shared.getTransfer(transferToken: "trf-123456", completion: { (result, error) in
    // On success, response (HyperwalletTransfer? in this case) will contain information about the transfer or nil if not exist.
    // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure
})

转账记录列表

Hyperwallet.shared.listTransfers { (result, error) in
    // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure
    guard error == nil else {
        print(error?.getHyperwalletErrors()?.errorList?)
        return
    }

    // On success, response (HyperwalletPageList<HyperwalletTransfer>? in this case) will contain information about or nil if not exist.
    if let transfers = result?.data {
        for transfer in transfers {
            print(transfer.token ?? "")
        }
    }
})

用户余额列表

let balanceQueryParam = HyperwalletBalanceQueryParam()
balanceQueryParam.currency = "USD"
balanceQueryParam.sortBy = HyperwalletBalanceQueryParam.QuerySortable.descendantAmount.rawValue

Hyperwallet.shared.listUserBalances(queryParam: balanceQueryParam) { (result, error) in
    // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure
    guard error == nil else {
    print(error?.getHyperwalletErrors()?.errorList?)
    return
    }

    // On success, response (HyperwalletPageList<HyperwalletBalance>? in this case) will contain information about or nil if not exist.
    if let balances = result?.data {
        for balance in balances {
            print(balance.amount ?? "")
        }
    }
}

预付费卡余额列表

let prepaidCardBalanceQueryParam = HyperwalletPrepaidCardBalanceQueryParam()
prepaidCardBalanceQueryParam.sortBy = HyperwalletPrepaidCardBalanceQueryParam.QuerySortable.descendantAmount.rawValue

Hyperwallet.shared.listPrepaidCardBalances(prepaidCardToken: "trm-1234", queryParam: prepaidCardBalanceQueryParam) { (result, error) in
    // In case of failure, error (HyperwalletErrorType) will contain HyperwalletErrors containing information about what caused the failure
    guard error == nil else {
    print(error?.getHyperwalletErrors()?.errorList?)
    return
    }

    // On success, response (HyperwalletPageList<HyperwalletBalance>? in this case) will contain information about or nil if not exist.
    if let balances = result?.data {
        for balance in balances {
            print(balance.amount ?? "")
        }
    }
}

转账方法配置

获取国家,货币

let keysQuery = HyperwalletTransferMethodConfigurationKeysQuery()

Hyperwallet.shared.retrieveTransferMethodConfigurationKeys(request: keysQuery) { (result, error) in

    guard error == nil else {
        print(error?.getHyperwalletErrors()?.errorList?)
        return
    }

    guard let result = result else { return }
    // Get countries
    let countries = result.countries()

    // Get currencies based on the first available country code
    var currencies: [HyperwalletCurrency]?
    if let countries = result.countries(), !countries.isEmpty {
        currencies = result.currencies(from: countries.first!.code)
    }

    print(countries)
    print(currencies)
}

获取国家和货币的转账方式类型、费用以及处理时间

let country = "CA"
let currency = "CAD"
let keysQuery = HyperwalletTransferMethodTypesFeesAndProcessingTimesQuery(country: country, currency: currency)

Hyperwallet
    .shared
    .retrieveTransferMethodTypesFeesAndProcessingTimes(request: keysQuery) { (result, error) in
    guard error == nil else {
        print(error?.getHyperwalletErrors()?.errorList?)
        return
    }

    guard let result = result else { return }

    // Get transfer method types based on the first country code and its first currency code
    transferMethodTypes = result.transferMethodTypes(countryCode: country, currencyCode: currency)
    print(transferMethodTypes)
    print(transferMethodTypes?.first?.fees)
    print(transferMethodTypes?.first?.processingTimes)
}

获取转账方式类型的字段

let fieldQuery = HyperwalletTransferMethodConfigurationFieldQuery(country: "CA",
                                                                  currency: "USD",
                                                                  transferMethodType: "BANK_ACCOUNT",
                                                                  profile: "INDIVIDUAL")

Hyperwallet.shared.retrieveTransferMethodConfigurationFields(request: fieldQuery) { (result, error) in

    guard error == nil else {
        print(error?.getHyperwalletErrors()?.errorList?)
        return
    }

    guard let result = result else { return }

    print(result.transferMethodType()))
    print(result.fieldGroups()?.fields))
}

获取更新转账方式的字段

let fieldQuery = HyperwalletTransferMethodUpdateConfigurationFieldQuery(transferMethodToken: "trm-0000001")

Hyperwallet.shared.retrieveTransferMethodUpdateConfigurationFields(request: fieldQuery) { (result, error) in
    guard error == nil else {
        print(error?.getHyperwalletErrors()?.errorList)
        return
    }

    guard let result = result else { return }

    print(result.transferMethodUpdateConfiguration()?.fieldGroups?.nodes)
    print(result.transferMethodUpdateConfiguration()?.transferMethodType)
}

许可证

Hyperwallet iOS SDK 是开源的,遵循 MIT 许可协议