OnrampKit 0.3.0

OnrampKit 0.3.0

Prashant Dixit 维护。



OnrampKit 0.3.0

  • Buyhatke

OnrampKit

这是 Onramp 支付网关的 iOS SDK。

示例

要运行示例项目,请克隆仓库,然后首先从 Example 目录中运行 pod install

通用要求

SDK 的最低要求是

  • iOS 15.0 或更高版本

安装

通过 CocoaPods 使用

OnrampKit 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中:

将 SDK 源添加到 Cocoapods

source 'https://github.com/Buyhatke/onramp-ios-podspec.git'
 pod 'OnrampKit'

然后,运行以下命令:

 pod install

初始化 SDK

  • 通过调用 startOnrampSDK 函数并传递基本的配置参数来初始化 SDK。
Onramp.startOnrampSDK(
  _ viewController:UIViewController, // reference to a UIViewController where the onrampKit's user interface will be presented.
  _ target: OnrampKitDelegate, //  An object conforming to the OnrampKitDelegate protocol. The delegate will receive callback and notifications.
  appId: 1, // replace this with the appID you got during onboarding process
  walletAddress: '0x495f519017eF0368e82Af52b4B64461542a5430B', // replace with user's wallet address
  flowtype: 1 // 1 -> onramp || 2 -> offramp || 3 -> Merchant checkout
  fiatType: 1 // 1 -> INR || 2 -> TRY
  paymentMethod: 1 // 1 -> Instant transafer(UPI) || 2 -> Bank transfer(IMPS/FAST)
  // ... pass other configs here
)

监听自定义事件

  • OnrampKitDelegate 接口添加到您的 ViewController 类的声明中。
class ViewController: UIViewController, OnrampKitDelegate // add this to appropriate activity based on your business logic {
  ...
} 
  • 在您的活动类中实现 onDataChanged(_ data: OnrampEventResponse) 方法。
     func onDataChanged(_ data: OnrampEventResponse) {
            // handle various sdk events based on type of event here

            //Example events usage:
        switch data.type {
             case "ONRAMP_WIDGET_TX_COMPLETED":
                 Onramp.stopOnrampSDK(self)
                // handle success code here
            case "ONRAMP_WIDGET_APP_CLOSED":
                 Onramp.stopOnrampSDK(self)
                // handle failure code here  
             default:
                 return 
         }
    }

关于 OnrampKit 生命周期

您可以在任何时候使用以下代码禁用 OnrampKit:

Onramp.stopOnrampSDK(
 _ viewController:UIViewController // reference to a UIViewController where the onrampKit's user interface will be presented.
)

事件文档

以下是所有事件的列表

  • ONRAMP_WIDGET_READY -> 当小部件准备好与用户交互时发送

  • ONRAMP_WIDGET_FAILED -> 当小部件因多种原因(如参数组合错误或缺少参数等)渲染失败时发送

  • ONRAMP_WIDGET_CLOSE_REQUEST_CONFIRMED -> 当小部件关闭时发送

  • ONRAMP_WIDGET_CONTENT_COPIED -> 当在工具栏中执行复制到剪贴板事件时发送,发送复制的内

  • ONRAMP_WIDGET_APP_CLOSED -> 当用户请求关闭小部件并取消交易时发送

  • ONRAMP_WIDGET_TX_INIT -> 当用户在屏幕上看到支付详情时发送

  • ONRAMP_WIDGET_TX_FINDING -> 当用户提交INR存款的参考号时发送

  • ONRAMP_WIDGET_TX_PURCHASING -> 当系统找到用户提交的参考/UTR对应的存款时发送

  • ONRAMP_WIDGET_TX_SENDING -> 系统购买加密货币并开始提现后发送

  • ONRAMP_WIDGET_TX_COMPLETED -> 当系统获取存款的交易哈希时发送

  • ONRAMP_WIDGET_TX_SENDING_FAILED -> 如果在获取交易哈希之前失败

  • ONRAMP_WIDGET_TX_PURCHASING_FAILED -> 如果在加密货币购买过程中失败

  • ONRAMP_WIDGET_TX_FINDING_FAILED -> 如果系统在查找参考/UTR对应的存款时失败

许可证

OnrampKit可在MIT许可证下使用。有关更多信息,请参阅LICENSE文件。