【问题标题】:How to get nonce from Braintree iOs SDK如何从 Braintree iOs SDK 中获取 nonce
【发布时间】:2016-05-13 23:02:53
【问题描述】:

我正在尝试从 Braintree 获取 nonce。我没有在以下文档中找到 Braintree 提供的有关如何从 Braintree SDK 获取 nonce 的任何文档。

https://developers.braintreepayments.com/start/hello-client/ios/v4

请告诉我如何从 Braintree iOs SDK 中获取 nonce

【问题讨论】:

    标签: ios paypal braintree paypal-rest-sdk


    【解决方案1】:

    全面披露:我在 Braintree 工作。如果您还有任何问题,请随时联系support

    获取随机数记录在您链接的页面的Presenting Drop-in UI section 中。一旦你激活了 Drop-in,你需要实现一个委托,以便 Drop-in 可以找到将它产生的 nonce 发送到哪里。如果没有指定的代表,您将不会从 Drop-in 收到随机数: ​

    然后实现 BTDropInViewControllerDelegate 以在成功时获取付款方式随机数,并在任一情况下关闭 Drop In UI:

    - (void)dropInViewController:(BTDropInViewController *)viewController   
      didSucceedWithTokenization:(BTPaymentMethodNonce *)paymentMethodNonce {
        // Send payment method nonce to your server for processing
        [self postNonceToServer:paymentMethodNonce.nonce];
        [self dismissViewControllerAnimated:YES completion:nil];
    }
    
     - (void)dropInViewControllerDidCancel:(__unused BTDropInViewController *)viewController {
         [self dismissViewControllerAnimated:YES completion:nil];
    }
    

    ​ 如果您查看第一个函数,您可以看到变量paymentMethodNonce(类型:BTPaymentMethodNonce)被传递到您的应用程序中。此示例代码希望您有另一个函数 (postNonceToServer) 来实际处理得到的 nonce。

    【讨论】:

    • 对于版本 4?没有代表的地方。
    • @Pedro.Alonso 新的 Braintree iOS Drop-in 接受一个完成回调,该回调返回一个 BTDropInResult 对象,其中包含付款方式 nonce。 (披露:我在 Braintree 工作)
    • 如何将付款方式nonce转换为nssting? @Richard Shin
    • @Jason BTPaymentMethodNoncenonce 属性是 NSString
    • @Raymond Berg : BTDropInViewControllerDelegate 在最新的 SDK 中获取未解析的标识符
    【解决方案2】:

    您可以使用 drop in 方法获取 Payment nonce 让 nonce = result.paymentMethod!.nonce

    示例:-

    func showDropIn(clientTokenOrTokenizationKey: String) {
        let request =  BTDropInRequest()
        let dropIn = BTDropInController(authorization: clientTokenOrTokenizationKey, request: request)
        { (controller, result, error) in
            if (error != nil) {
                print("ERROR")
            } else if (result?.isCancelled == true) {
                print("CANCELLED")
            } else if let result = result {
    
                let nonce = result.paymentMethod!.nonce
    
                print( nonce)
    
            }
            controller.dismiss(animated: true, completion: nil)
        }
        self.present(dropIn!, animated: true, completion: nil)
    }
    

    【讨论】:

      猜你喜欢
      • 2016-07-20
      • 2016-12-15
      • 2020-12-16
      • 2019-04-09
      • 1970-01-01
      • 1970-01-01
      • 2014-05-16
      • 2021-10-23
      • 1970-01-01
      相关资源
      最近更新 更多