天穹支付链客户端 1.0.1

天穹支付链客户端 1.0.1

CieloZeroAuthCielo维护。



  • 作者
  • Paulo Fernandes

Link-de-Pagamento-iOS

适用于iOS的Link de Pagamento SDK,使用Swift编写

主要特性

  • OAuth身份验证
  • 生成支付链接
    • 包含所有类型的产品
    • 包含所有类型的配送方式
    • 支持周期性支付

安装

为了安装,请向您的内容管理系统中添加以下行

pod "CieloPaymentLinkApiClient"

使用

要使用SDK,需要导入

CieloPaymentLinkClient

模块,然后按照以下示例使用

PaymentLinkClient

import UIKit
import CieloPaymentLinkClient

class ViewController: UIViewController {

    ...

    @IBAction func createLinkTouched(_ sender: Any) {
        let credentials = Credentials(
            clientId: "ClientId",
            clientSecret: "ClientSecret")
        
        let product = ProductModel(
            name: "Teste Product",
            description: "The incredible test product",
            showDescription: true,
            price: 39999,
            weight: 400,
            type: ProductType.asset,
            shipping: Shipping(type: ShippingType.free)
        )
        
        let client = PaymentLinkClient(credentials: credentials, environment: Environment.sandbox)
        
        client.CreateLink(product: product){ result in
            switch result{
            case .success(let product):
                DispatchQueue.main.async {
                    self.linkLabel.text = product.shortUrl
                }
                
            case .failure(.BadRequest(let error)):
                print(error ?? "No body for badrequest")
                
            default:
                print("Something bad happened!")
            }
            
        }
    }
}

错误枚举有以下选项

  • HttpStatusError(status: Int)
  • BadRequest(error: String?)
  • InternalError
  • Unauthorized
  • DecodingError
  • EncodingError
  • EmptyResponseBody

手册

有关与付款 API 集成的更多信息,请参阅如下手册:[付款链接] (https://developercielo.github.io/manual/linkdepagamentos5)