WeChat payment IOS integration process

1. Official help document: https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=11_1

2. Download SDK

3. Modify the IOS configuration: In the Link Binary With Libraries of the Build Phases tab, add the following dependencies

        libz.tbd
        libsqlite3.0.tbd
        SystemConfiguration.framework
        CoreTelephony.framework
        QuartzCore.framework
        libWeChatSDK.a

 

 4. Register APP: modify the AppDelegate file

class AppDelegate: UIResponder, UIApplicationDelegate, WXApiDelegate {

    ......

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        self.initWeixinPay()
        return true
    }

    func onResp (_ resp: BaseResp!) {
        var strMsg = "\(resp.errCode)"
        Logger.debug(strMsg)
        if resp.isKind(of: PayResp.self) {
            switch resp.errCode {
            case 0 :
                NotificationCenter.default.post(name: PayHelper.Notification_WX_Result, object: nil)
            case -2:
                strMsg = "You have cancelled the payment, please complete the payment as soon as possible"
            default:
                strMsg = "Payment failed: \(resp.errStr)"
                Logger.debug("retcode = \(resp.errCode), retstr = \(resp.errStr)")
            }
        }
        if resp.errCode != 0{
            let alert = UIAlertView(title: nil, message: strMsg, delegate: nil, cancelButtonTitle: "好的")
            alert.show()
        }
    }
    
    func initWeixinPay () {
        WXApi.registerApp(GlobalConstant.WX_APP_ID, withDescription: "APP描述")
    }

 

 5. Register Schema: Image source WeChat official website


 

 

Alipay IOS integration

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326060378&siteId=291194637