Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.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
Authentication 条带认证_Authentication_Stripe Payments - Fatal编程技术网

Authentication 条带认证

Authentication 条带认证,authentication,stripe-payments,Authentication,Stripe Payments,我无法在stripe.com中进行身份验证-使用基本身份验证 public class Str extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter pw=response.getWriter(); pw.

我无法在stripe.com中进行身份验证-使用基本身份验证

public class Str extends HttpServlet {


    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        PrintWriter pw=response.getWriter();
        pw.println("Hello World");
        HttpClient client= new HttpClient();
        String req="https://api.stripe.com/";
        client.getParams().setAuthenticationPreemptive(true);
        client.getState().setCredentials(new AuthScope(req, 443, null),  new UsernamePasswordCredentials("<api-key>"));
        client.getHostConfiguration().setHost(req, 443, "https");

        PostMethod post= new PostMethod("https://api.stripe.com/v1/charges/");
        //post.addParameter("id", "<id>");
        int status=client.executeMethod(post);
        pw.println(status);



    }


}
public类Str扩展了HttpServlet{
受保护的void doGet(HttpServletRequest请求,HttpServletResponse响应)抛出ServletException,IOException{
PrintWriter pw=response.getWriter();
println(“你好世界”);
HttpClient=新的HttpClient();
字符串请求=”https://api.stripe.com/";
client.getParams().setAuthenticationPreemptive(true);
client.getState().setCredentials(新的AuthScope(req,443,null),新的UsernamePasswordCredentials(“”);
client.getHostConfiguration().setHost(req,443,“https”);
PostMethod post=新的PostMethod(“https://api.stripe.com/v1/charges/");
//post.addParameter(“id”,”);
int status=client.executeMethod(post);
pw.println(状态);
}
}

我正在演示我的代码…我使用HTTP Basic Auth向stripe.com提供用户凭据

尝试:
新用户名密码凭据(“,”)
希望这对您有所帮助

这里的API_密钥意味着秘密密钥

HttpResponse httpResponse;
String request ='card[number]='+card_name+'&card[exp_year]='+card_exp_year+'&card[exp_month]='+card_exp_month+'&card[cvc]='+card_cvv+'&amount='+amount+ '&currency='+currency;
Http httpObject = new Http();
HttpRequest httpRequest = new HttpRequest();
httpRequest.setEndpoint(sHttpEndPoint);
httpRequest.setMethod('POST');
Blob headerValue = Blob.valueOf(API_KEY + ':');
String authorizationHeader = 'BASIC ' +
EncodingUtil.base64Encode(headerValue);
httpRequest.setHeader('Authorization', authorizationHeader);
httpRequest.setBody(request);  
httpResponse = httpObject.send(httpRequest);

当您尝试时会发生什么呢?它说找不到默认凭据..并且身份验证失败为什么不使用条带Java绑定?