php - Post variable undefined in Braintree transaction -


i setting payment processing osx desktop app in swift. since there no sdk osx, using web view via php sdk braintree. want pass post data price of product coming dynamically app, seems not recognized , underfined according php errors.
know how send post variable php script , have done many times, have feeling might not right swift code. 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 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 urlrequest) {         (data, response, error) -> void in          if let httpstatus = response as? httpurlresponse, httpstatus.statuscode != 200 {              print("statuscode should 200, \(httpstatus.statuscode)")             print("response = \(response)")          }          let responsestring = string(data: data!, encoding: .utf8)         print("responsestring = \(responsestring)")      }      task.resume()      let requesting = nsurlrequest(url: request url)      dispatchqueue.main.async(){         self.paypalwebview?.mainframe.load(requesting 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 paypal view web view being activated when user clicks on button via segue. don't know if have or not?

i ended getting 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 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 urlrequest) {         (data, response, error) -> void in          if let httpstatus = response as? httpurlresponse, httpstatus.statuscode != 200 {              print("statuscode should 200, \(httpstatus.statuscode)")             print("response = \(response)")          }          let responsestring = string(data: data!, encoding: .utf8)         print("responsestring = \(responsestring)")      }      paypalwebview?.mainframe.load(urlrequest 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')))   ?> 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -