在Braintree事务中发布变量undefined

I am setting up payment processing for my OSX desktop app in swift. Since there is no SDK for OSX, I am using a Web View via the PHP SDK for Braintree. I want to pass some POST data so that the price of a product is coming dynamically from my App, but it seems to not be recognized and is underfined according to PHP errors.
I know how to send POST variable to a PHP script and have done it many times, but I have a feeling something might not be right with my swift code. My PHP error is: "Notice: Undefined variable: price"

PayPal.swift

import Cocoa
import WebKit

class PayPal: NSViewController {

@IBOutlet weak var paypalWebView: WebView?

override func viewWillAppear() {

    self.view.window!.title = "Payment"
}

override func viewDidLoad() {
    super.viewDidLoad()

    setupPP()

}

func setupPP(){

    let request: NSURL = NSURL(string: "http://")!

    let urlRequest: NSMutableURLRequest = NSMutableURLRequest(url: request as URL)

    urlRequest.httpMethod = "POST"
    let postString = "price=45"
    urlRequest.httpBody = postString.data(using: String.Encoding.utf8);

    let session = URLSession.shared
    let task = session.dataTask(with: urlRequest as URLRequest) {
        (data, response, error) -> Void in

        if let httpStatus = response as? HTTPURLResponse, httpStatus.statusCode != 200 {

            print("statusCode should be 200, but is \(httpStatus.statusCode)")
            print("response = \(response)")

        }

        let responseString = String(data: data!, encoding: .utf8)
        print("responseString = \(responseString)")

    }

    task.resume()

    let requesting = NSURLRequest(url: request as URL)

    DispatchQueue.main.async(){
        self.paypalWebView?.mainFrame.load(requesting as URLRequest)
    }

}

}

Braintree PHP Script

if(isset($_POST["price"])){

$price = $_POST["price"];

}

<?php $tr_data = Braintree_TransparentRedirect::transactionData(
                array('redirectUrl' => "http://" ,
                'transaction' => array('amount' => $price, 'type' => 'sale'))) ?>

Also the Paypal View that is essentially a web view is being activated when a user clicks on a button via a segue. I don't know if that would have anything to do with it or not?

I ended up getting it to work!

Paypal.swift

import Cocoa
import WebKit

class PayPal: NSViewController {

@IBOutlet weak var paypalWebView: WebView?

override func viewWillAppear() {

    self.view.window!.title = "Payment"
}

override func viewDidLoad() {
    super.viewDidLoad()

    setupPP()

}


func setupPP(){

    let request: NSURL = NSURL(string: "http://")!

    let urlRequest: NSMutableURLRequest = NSMutableURLRequest(url: request as URL)

    urlRequest.httpMethod = "POST"
    let postString = "amount=29.95"
    urlRequest.httpBody = postString.data(using: String.Encoding.utf8);

    let session = URLSession.shared
    let task = session.dataTask(with: urlRequest as URLRequest) {
        (data, response, error) -> Void in

        if let httpStatus = response as? HTTPURLResponse, httpStatus.statusCode != 200 {

            print("statusCode should be 200, but is \(httpStatus.statusCode)")
            print("response = \(response)")

        }

        let responseString = String(data: data!, encoding: .utf8)
        print("responseString = \(responseString)")

    }

    paypalWebView?.mainFrame.load(urlRequest as URLRequest)

    task.resume()


}

}

PHP Script

<?php
            if (isset ($_POST['amount'])) {

                    $amount = $_POST['amount'];
            }

            $tr_data = Braintree_TransparentRedirect::transactionData(
                array('redirectUrl' => "http://" . $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH),

                'transaction' => array('amount' => $amount, 'type' => 'sale'))) 

?>