🐻 Paybear iOS
示例
要运行示例项目,请克隆仓库,然后从 Example 目录运行 pod install
。
使用方法
设置 Paybear API 密钥
Paybear.shared.setToken("your-api-key")
获取当前市场价格
Paybear.shared.getCurrencies(completion: { (currencies, error) in
if let currencies = currencies, error == nil {
// Array of currency. Nice
}
})
获取所有加密货币的市场汇率
Paybear.shared.getMarketRates(fiat: .usd) { (rates, error) in
if let rates = rates, error == nil {
// ...
}
}
获取加密货币的单市场汇率
Paybear.shared.getSingleMarketRate(fiat: .usd, crypto: .btc) { (rate, error) in
if let rate = rate, error == nil {
// ...
}
}
在指定的加密货币中创建支付请求
Paybear.shared.createPaymentRequest(crypto: .btc, callbackURL: "http://ryans.online") { (request, error) in
if let request = request, error == nil {
// ...
}
}
以二维码图片形式创建支付请求
Paybear.shared.getPaymentRequestQR(crypto: .btc, amount: 1.0, address: "123", message: "Free money", size: nil) { (image) in
if let image = image {
// QR code image containing a payment URL
}
}
登录用户
Paybear.shared.login(email: "[email protected]", password: "password", twoFactorDelegate: nil) { (token, error) in
if let token = token, error == nil {
// We can now make user-based requests with our stored token!
}
}
另一种登录用户的方法
使用 TwoFactorAuthProtocol
接收请求2FA码时的回调。
Paybear.shared.login(email: "[email protected]", password: "password", twoFactorDelegate: self) { (token, error) in
if let token = token, error == nil {
// We can now make user-based requests with our stored token!
}
}
func paybearDidRequestTwoFactorAuthentication() {
// Prompt for 2FA code here
Paybear.shared.loginTwoFactor(code: "123456") { (success) in
if success {
// We have completed the login process
}
}
}
登录后的双因素认证
Paybear.shared.loginTwoFactor(code: "123456") { (success) in
if success {
// We have completed the login process
// Best to call this function on login completion
}
}
获取用户属性
Paybear.shared.getUser(completion: { (user, error) in
if let user = user, error == nil {
// We've got a valid user object!
}
})
在仪表板中启用或禁用货币
Paybear.shared.enableCurrency(.btc, enable: true, address: "123", completion: { (success) in
if success {
// Enabled BTC with wallet address 123
}
})
需求
- Alamofire
- Quick/Nimble(仅运行测试)
安装
paybear-ios可通过CocoaPods获取。要安装,只需在Podfile中添加以下行
pod 'paybear-ios'
作者
Ryan Cohen,[email protected]
许可
paybear-ios采用MIT许可。有关更多信息,请参阅LICENSE文件。