Swirepay_IOS 1.0.1

Swirepay_IOS 1.0.1

Swirepay维护。



 
依赖关系
Alamofire~> 4.0
SwiftyJSON~> 4.0
 

  • Swirepay

Swirepay_IOS_SDK

CI Status Version License Platform

Swirepay IOS SDK

Swirepay iOS SDK 帮助开发者在其 iOS 应用中实现原生支付体验。SDK 初始化设置简单,帮助开发者处理支付,整个过程在 30 秒内完成,同时符合 PCI 规范。

示例

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

AppDelegate.swift

import Swirepay_IOS

将以下代码添加到 didFinishLaunchingWithOptions 函数的开始部分

SwirepaySDK.shared.initSDK(publishKey:"api_key")

使用 Swirepay_IOS_SDK

1.支付

示例代码

let paymentList = ["CARD"]

let paymentRequestParam = [
"amount":String(amount),
"currencyCode":"INR",
"paymentMethodType":paymentList,
"redirectUri":"https://ios.sdk.redirect"
] as [String : Any]

SwirepaySDK.shared.doPayment(parentView:self,requestParam:paymentRequestParam)

代理方法

SwirePaymentListener

SwirepaySDK.shared.paymentListenerDelegate = self

// MARK: - Payment response listeners

public protocol SwirePaymentListener {
    
    // MARK: - it will return the payment response after successfull payment.
    
    func didFinishPayment(responseData:[String:Any])
    
    // MARK: - it will return the payment failed response.

    func onPaymentFailed(responseData:[String:Any],errorMessage:String)
    
    // MARK: - it will return failed response when the payment sdk is not intialized yet.

    func onPaymentConfigurationFailed(errorMessage:String)
    
    //  MARK: ; it will return when the payment view canceled by user
    func didCanceled()
}
  1. 订阅

示例代码

let swplan = SWPlan(currencyCode:CurrencyType.INR, name: "Test Plan IOS", amount: 40000, description: "Test Plan IOS", note: "Test", billingPeriod:1, billingFrequency:BillingFrequency.MONTH)

SwirepaySDK.shared.subscription(context:self,plan:swplan)

委托

SwirepaySDK.shared.subscriptionListenerDelegate = self

// MARK: - Subscription response listeners

public protocol SWSubscriptionListener {
    
    func didFinishSubscription(responseData:[String:Any])
    
    func didFailedSubscription(error:String)
    
    func didCanceled()
}

3.支付方式

just call SwirepaySDK.shared.createPaymentMethod(parentContext:self)

委托

SwirepaySDK.shared.paymentMethodListenerDelegate = self

/ MARK: - SWPaymentMethod response listeners

public protocol SWPaymentMethodListener {
    
    func didFinishPaymentMethod(responseData:[String:Any])
    
    func didFailedPaymentMethod(error:String)
    
    func didCanceled()

}
  1. 连接账户

     just call  SwirepaySDK.shared.createAccount(parentContext:self)
    

委托

SwirepaySDK.shared.accountListenerDelegate = self

// MARK: - SWAccountListener response listeners

public protocol SWAccountListener {
    
    func didFinishConnectAccount(responseData:[String:Any])
    
    func didFailedConnectAccount(error:String)
    
    func didCanceled()

}

要取消支付视图的调用,请调用以下方法

SwirepaySDK.shared.cancel()

需求

安装

Swirepay_IOS_SDK可以通过CocoaPods获取。要安装它,只需将以下行添加到您的Podfile中

pod 'Swirepay_IOS','1.0.beta'

作者

Swirepay,[email protected]

许可

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