DappMX 1.1.0

DappMX 1.1.0

Dapp payments 维护。



DappMX 1.1.0

  • Dapp Payments

Dapp iOS SDK

Dapp 是一个专注于用户安全的支付平台。此 SDK 是将 Dapp 集成到您的 iOS 开发中最简单的方式,具有两个功能:对卡片进行令牌化进行支付

安装

我们建议使用 CocoaPods 集成 Dapp iOS SDK

platform :ios, '9.0'
pod 'DappMX'

配置

要获取您的 merchant_idapi_key,请登录您的 仪表板 并从侧边菜单选择“开发者”。以下是这样添加您密钥的方式

  1. 添加以下导入指令
import DappMX
  1. 在 Dapp 对象中初始化密钥,用您自己的 your-dapp-merchant-idyour-dapp-api-key 替换
Dapp.shared.merchantId = "your-dapp-merchant-id"
Dapp.shared.apiKey = "your-dapp-api-key"
  1. 您可以将环境更改为 sandbox 来进行不涉及真实的支付测试
Dapp.shared.enviroment = .sandbox

进行支付

通过 Dapp 的 iOS 应用 进行支付。

  1. AppDelegate 中添加 application(_:open:options) 方法。
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
	let handled = Dapp.application(app, open: url, options: options)
	return handled
}
  1. 配置文件 info.plist。右键单击 info.plist 文件并选择 以源代码打开。将以下代码片段复制并粘贴到文件中。用你应用的相关唯一值替换 uniqueappidYourAppName
<key>LSApplicationQueriesSchemes</key>
    <array>
        <string>dappmx</string>
    </array>
    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>uniqueappid</string>
            </array>
            <key>CFBundleURLName</key>
            <string>YourAppName</string>
        </dict>
    </array>
  1. 分配一个支付代理并实现其方法。
import DappMX

class ViewController: UIViewController, DappPaymentDelegate {

override func viewDidLoad() {
	super.viewDidLoad()
	Dapp.shared.paymentDelegate = self
}

func dappPaymentFailure(error: DappError) {
	//your code to handle the error
	print(error.localizedDescription)
	switch error {
	default:
		break
	}
}
    
func dappPaymentSuccess(payment: DappPayment) {
	//your code to handle the success
}
  1. 实现支付方法。
let vc: UIViewController = self
let price: Double: 100
let desc: String = "Payment description"
let ref: String = "MyCompanyInnerReference"

Dapp.requestPayment(viewController: vc, amount: price, description: desc, reference: ref)
  1. 如果用户设备上未安装 Dapp,则该方法会打开 AppStore 以让用户下载应用程序。如果想使用不同的流程,请使用 isDappInstalled() 函数。
if Dapp.isDappInstalled() {
	//call Dapp.requestPayment(viewController: UIViewController, amount: Double, description: String, reference: String?)
}
else {
	//your alternate flow
}

TOKENIZAR TARJETAS

对卡片进行标记化,在数据库中保存引用,并在需要时使用这张卡片进行支付。

  1. 分配代理并实现其方法。
import DappMX

class ViewController: UIViewController, DappPaymentDelegate {

override func viewDidLoad() {
	super.viewDidLoad()
	Dapp.shared.cardDelegate = self
}

func dappCardSuccess(card: DappCard) {
	//your code to handle success
	print(card.token)
}
 
func dappCardFailure(error: DappError) {
	//your code to handle the error
	print(error.localizedDescription)
	switch error {
	default:
		break
	}
}
  1. 使用以下方法标记化客户的卡片。
let card: String = "5515150180013278"
let name: String = "Daenerys Targaryen"
let cvv: String = "123"
let month: String = "01"
let year: String = "2030"
let mail: String = "[email protected]"
let phone: String = "5512345678"

Dapp.addCard(cardNumber: card, cardholder: name, cvv: cvv, expMonth: month, expYear: year, email: mail, phoneNumber: phone)

LICENCIA

MIT