Php HTTP条带请求未通过[Swift]

Php HTTP条带请求未通过[Swift],php,ios,swift,filezilla,Php,Ios,Swift,Filezilla,我目前正在将我的IOS应用程序与后端链接,以处理条带支付。我使用FileZilla来托管文件,使用cSpan来托管服务器。这是我的swift代码: let task = session.dataTask(with: request as URLRequest, completionHandler: {data, response, errorD -> Void in if errorD == nil { print("got response")

我目前正在将我的IOS应用程序与后端链接,以处理条带支付。我使用FileZilla来托管文件,使用cSpan来托管服务器。这是我的swift代码:

 let task = session.dataTask(with: request as URLRequest, completionHandler: {data, response, errorD -> Void in
        if errorD == nil {
            print("got response")

            do {
                let jsonResult: NSDictionary? = try JSONSerialization.jsonObject(with: data!, options: .mutableContainers) as? NSDictionary



                let jsonComp = jsonResult?.value(forKey: "completion") as! String
                print(jsonComp)
            } catch {
                print(errorD?.localizedDescription)
                // ERROR OCCURS HERE 
            }



            //let jsonResult: Any! = JSONSerialization.jsonObject(with: data!, options: .mutableContainers)
           // print(jsonResult)

            } else {
            print("error")
        }
    }) task.resume()
下面是我的FileZilla目录的屏幕截图:

(我刚刚意识到,这张图片实际上没有显示Payments目录中的文件'token.php',但它就在那里。)

如您所见,我正确地进入正确的目录以访问该文件,并执行正确的方法来完成HTTP请求。然而,奇怪的是,它总是在“catch”之后导致错误,但是当我试图打印错误的本地化描述时,它将显示nil。下面是token.php中的php代码

<?php

require_once('stripe-php/init.php');

\Stripe\Stripe::setApiKey("sk_test_eRFc0VoIi7mo7zBuArrznB5a");

// Get the credit card details submitted by the form

$token = $_POST['stripeToken'];

$amount = $_POST['amount'];

$type = $_POST['type'];

$name = $_POST['name'];

// Create the charge on Stripe's servers - this will charge the user's card

try {

$charge = \Stripe\Charge::create(array(

"amount" => $amount,

"currency" => "usd",

"source" => $token,)

);



//email the purcahse and code info to your email

mail("willcohen2000@gmail.com","Purchase done","amount: $amount , type: $type, name: $name");

// create a json output with completion variable, (this will be read from the ios app as response)

$json = array(

'completion' => 'done'

);

echo json_encode($json);

} catch(\Stripe\Error\Card $e) {

// The card has been declined

$errorMessage = $e->getMessage();

$json = array(

'completion' => $getMessage()

);

echo json_encode($json);

}

?>

可能有点明显,我在后端工作方面相对缺乏经验,因此任何正确方向的解释或观点都将受到高度赞赏。谢谢