我目前使用 Braintree 付款。我能够使用我的 iOS 在仪表板中创建成功的付款问题是我正在尝试将响应返回给客户端(iOS),现在它返回“”,提前感谢您的帮助。
我现在的 php
<?php
require_once("../includes/braintree_init.php");
//$amount = $_POST["amount"];
//$nonce = $_POST["payment_method_nonce"];
$nonce = "fake-valid-nonce";
$amount = "10";
$result = Braintree\Transaction::sale([
'amount' => $amount,
'paymentMethodNonce' => $nonce
]);
我的客户
URLSession.shared.dataTask(with: request as URLRequest) { (data, response, error) -> Void in
// TODO: Handle success or failure
let responseData = String(data: data!, encoding: String.Encoding.utf8)
// Log the response in console
print(responseData);
// Display the result in an alert view
DispatchQueue.main.async(execute: {
let alertResponse = UIAlertController(title: "Result", message: "\(responseData)", preferredStyle: UIAlertControllerStyle.alert)
// add an action to the alert (button)
alertResponse.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))
// show the alert
self.present(alertResponse, animated: true, completion: nil)
})
} .resume()