Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/266.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 服务器未将条带客户id返回到android应用程序_Java_Php_Android_Client Server_Web Hosting - Fatal编程技术网

Java 服务器未将条带客户id返回到android应用程序

Java 服务器未将条带客户id返回到android应用程序,java,php,android,client-server,web-hosting,Java,Php,Android,Client Server,Web Hosting,现在我所要做的就是使用我在下面的android活动中创建的条带令牌,将其发送到我的服务器(参见下面的php脚本),然后将客户id返回给我,并在alertdialogue框中打印 现在,当我插入正确且有效的VISA测试卡号4242,带有未来的exp日期和cvc 991时,应用程序所做的只是在Toast对话中显示我创建的条带标记,然后在alertdialogue中显示标题“Customer ID” 我使用backgroundWorker类与我的服务器通信,并且相信问题一定在那里。有什么奇怪的吗 即使

现在我所要做的就是使用我在下面的android活动中创建的条带令牌,将其发送到我的服务器(参见下面的php脚本),然后将客户id返回给我,并在alertdialogue框中打印

现在,当我插入正确且有效的VISA测试卡号4242,带有未来的exp日期和cvc 991时,应用程序所做的只是在Toast对话中显示我创建的条带标记,然后在alertdialogue中显示标题“Customer ID”

我使用backgroundWorker类与我的服务器通信,并且相信问题一定在那里。有什么奇怪的吗

即使当我有php文件时,alertdialogue中也不会显示“Hello”,我与服务器的通信方式是否有问题

我是GoDaddy上的网络主机,今天购买了zeuspower.xyz,并在/home/zeuspower/public_html文件夹中创建了createCus.php文件:

以下是错误:

02-04 18:21:16.147 10854-11059/com.zeuspwr.zeuspower W/System.err: java.io.FileNotFoundException: http://zeuspower.xyz/createCus.php
02-04 18:21:16.147 10854-11059/com.zeuspwr.zeuspower W/System.err:     at com.android.okhttp.internal.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:186)
02-04 18:21:16.147 10854-11059/com.zeuspwr.zeuspower W/System.err:     at com.zeuspwr.zeuspower.backgroundWorker.doInBackground(backgroundWorker.java:52)
02-04 18:21:16.147 10854-11059/com.zeuspwr.zeuspower W/System.err:     at com.zeuspwr.zeuspower.backgroundWorker.doInBackground(backgroundWorker.java:22)
02-04 18:21:16.147 10854-11059/com.zeuspwr.zeuspower W/System.err:     at android.os.AsyncTask$2.call(AsyncTask.java:288)
02-04 18:21:16.147 10854-11059/com.zeuspwr.zeuspower W/System.err:     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
02-04 18:21:16.147 10854-11059/com.zeuspwr.zeuspower W/System.err:     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
02-04 18:21:16.147 10854-11059/com.zeuspwr.zeuspower W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
02-04 18:21:16.147 10854-11059/com.zeuspwr.zeuspower W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
02-04 18:21:16.147 10854-11059/com.zeuspwr.zeuspower W/System.err:     at java.lang.Thread.run(Thread.java:841)
backgroundWorker类:

public class backgroundWorker extends AsyncTask<String,Void,String>{

    Context context;
    AlertDialog alertDialog;
    backgroundWorker(Context ctx){
        context = ctx;
    }

    @Override
    protected String doInBackground(String... params) {

        String type = params[0];
        String createCus_url = "http://zeuspower.xyz/createCus.php";
        if(type.equals("createCustomer")){
            try {
                String email = params[2];
                String stripeToken = params[1];
                URL url = new URL(createCus_url);
                HttpURLConnection httpURLConnection = (HttpURLConnection)url.openConnection();
                httpURLConnection.setRequestMethod("POST");
                httpURLConnection.setDoOutput(true);
                httpURLConnection.setDoInput(true);
                OutputStream outputStream = httpURLConnection.getOutputStream();
                BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
                String post_data = URLEncoder.encode("email","UTF-8")+"="+URLEncoder.encode(email,"UTF-8")+"&"+
                        URLEncoder.encode("stripeToken","UTF-8")+"="+URLEncoder.encode(stripeToken,"UTF-8");
                bufferedWriter.write(post_data);
                bufferedWriter.flush();
                bufferedWriter.close();
                outputStream.close();
                InputStream inputStream = httpURLConnection.getInputStream();
                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream,"iso-8859-1"));
                String result="";
                String line="";
                while ((line=bufferedReader.readLine())!=null){
                    result+=line;
                }
                bufferedReader.close();
                inputStream.close();
                httpURLConnection.disconnect();
                return result;
            } catch (MalformedURLException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return null;
    }

    @Override
    protected void onPreExecute() {
        alertDialog = new AlertDialog.Builder(context).create();
        alertDialog.setTitle("Customer ID");
    }

    @Override
    protected void onPostExecute(String result) {
        alertDialog.setMessage(result);
        alertDialog.show();
    }

    @Override
    protected void onProgressUpdate(Void... values) {
        super.onProgressUpdate(values);
    }
}
PHP代码:
// Set your secret key: remember to change this to your live secret key in production
// See your keys here: https://dashboard.stripe.com/account/apikeys
\Stripe\Stripe::setApiKey("My Secret API");

// Token is created using Stripe.js or Checkout!
// Get the payment token submitted by the form:
$token = $_POST['stripeToken'];

// Create a Customer:
$customer = \Stripe\Customer::create(array(
  "email" => $email,
  "source" => $token,
));

// Charge the Customer instead of the card:
$charge = \Stripe\Charge::create(array(
  "amount" => 1000,
  "currency" => "usd",
  "customer" => $customer->id
));

// YOUR CODE: Save the customer ID and other info in a database for later.
$newCustID = $customer->id;
echo .$newCustID;
//echo "Hi";
?>

可能是因为我的网站还没有启动和运行吗?比如当你转到zeuspower.xyz时,实际上什么都没有加载,因为我还没有完成这个站点。现在我所要做的就是看看如何创建客户。这可能是因为我的网站还没有启动和运行吗?比如当你转到zeuspower.xyz时,实际上什么都没有加载,因为我还没有完成这个站点。现在我要做的就是看看如何创造客户。
// Set your secret key: remember to change this to your live secret key in production
// See your keys here: https://dashboard.stripe.com/account/apikeys
\Stripe\Stripe::setApiKey("My Secret API");

// Token is created using Stripe.js or Checkout!
// Get the payment token submitted by the form:
$token = $_POST['stripeToken'];

// Create a Customer:
$customer = \Stripe\Customer::create(array(
  "email" => $email,
  "source" => $token,
));

// Charge the Customer instead of the card:
$charge = \Stripe\Charge::create(array(
  "amount" => 1000,
  "currency" => "usd",
  "customer" => $customer->id
));

// YOUR CODE: Save the customer ID and other info in a database for later.
$newCustID = $customer->id;
echo .$newCustID;
//echo "Hi";
?>