Getting error 400 when calling an https request to apply a charge on Stripe API









up vote
0
down vote

favorite












I am using nodejs without any library/npm to make a charge on stripe using the test api key.



However I am always getting 400 status code response, and can't understand why, can someone give me an hint?



Here is my request details:



 protocol: 'https:',
hostname: 'api.stripe.com',
method: 'POST',
path: 'v1/charges',
timeout: 5000,
headers:
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': 72 ,
auth: 'sk_test_JOXtNqPjvpFgLXMiwuWWKZxu:'


And here is my payload (using querystring.stringify):



amount=5000&currency=usd&description=Tiago_1541865841578&source=tok_amex


Thank you in advance for any help!



Here is the code, the method where I do the request it self:



helpers.sendRequest = function(protocol, port, hostname, method, path, timeoutSeconds, contentType, postData)

// Stringify the payload
var stringPayload = querystring.stringify(postData);

// Construct the request
var requestDetails =
'protocol' : protocol+':',
'hostname' : hostname,
'method' : method,
'path' : path,
'port' : port,
'auth': ('Bearer ' + Buffer.from(config.stripe.secretApiKeyTest).toString('base64') + ":"),
'timeout' : timeoutSeconds * 1000,
'headers' :
'Authorization': ('Bearer ' + Buffer.from(config.stripe.secretApiKeyTest).toString('base64') + ":"),
'teste':'ola',
"teste2":"ola2",
'Content-Type':contentType,
'Content-Length': Buffer.byteLength(stringPayload)

;

console.log("Request Details:")
console.log(requestDetails);
console.log("Payload:")
console.log(stringPayload);

// Instantiate the request object (using either the http or https module)
var _moduleToUse = protocol == 'http' ? http : https;
var req = _moduleToUse.request(requestDetails, function(res)
console.log(res.statusCode);

);

// Bind to the error event so it doesn't get thrown
req.on('error',function(e)
callback(err, e);
);

// Bind to the timeout event
req.on('timeout',function()
callback(true, 'Error': 'The request took much time and got timeout.')
);

// Add the payload
req.write(stringPayload);

// End the request
req.end();
;


And here is where I call the aux method to send the request:



var stripeRequestObject = 
amount: (totalPrice*100),
currency: 'usd',
description: userData.name+'_'+Date.now(),
source: stripeToken,
;

genericHelper.sendRequest('https',
443,
'api.stripe.com',
'POST',
'v1/charges',
5,
'application/x-www-form-urlencoded',
stripeRequestObject);









share|improve this question



















  • 1




    I really do not understand why you wouldn't just use github.com/stripe/stripe-node for this. I know you said that you "need" to do this in plain Node, buy why? I'm curious.
    – Karl Reid
    Nov 11 at 21:00











  • Just a project and to learn :) no particular reason! I know there are bunches of libraries and modules that help a lot ^^
    – TiagoM
    Nov 12 at 19:10














up vote
0
down vote

favorite












I am using nodejs without any library/npm to make a charge on stripe using the test api key.



However I am always getting 400 status code response, and can't understand why, can someone give me an hint?



Here is my request details:



 protocol: 'https:',
hostname: 'api.stripe.com',
method: 'POST',
path: 'v1/charges',
timeout: 5000,
headers:
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': 72 ,
auth: 'sk_test_JOXtNqPjvpFgLXMiwuWWKZxu:'


And here is my payload (using querystring.stringify):



amount=5000&currency=usd&description=Tiago_1541865841578&source=tok_amex


Thank you in advance for any help!



Here is the code, the method where I do the request it self:



helpers.sendRequest = function(protocol, port, hostname, method, path, timeoutSeconds, contentType, postData)

// Stringify the payload
var stringPayload = querystring.stringify(postData);

// Construct the request
var requestDetails =
'protocol' : protocol+':',
'hostname' : hostname,
'method' : method,
'path' : path,
'port' : port,
'auth': ('Bearer ' + Buffer.from(config.stripe.secretApiKeyTest).toString('base64') + ":"),
'timeout' : timeoutSeconds * 1000,
'headers' :
'Authorization': ('Bearer ' + Buffer.from(config.stripe.secretApiKeyTest).toString('base64') + ":"),
'teste':'ola',
"teste2":"ola2",
'Content-Type':contentType,
'Content-Length': Buffer.byteLength(stringPayload)

;

console.log("Request Details:")
console.log(requestDetails);
console.log("Payload:")
console.log(stringPayload);

// Instantiate the request object (using either the http or https module)
var _moduleToUse = protocol == 'http' ? http : https;
var req = _moduleToUse.request(requestDetails, function(res)
console.log(res.statusCode);

);

// Bind to the error event so it doesn't get thrown
req.on('error',function(e)
callback(err, e);
);

// Bind to the timeout event
req.on('timeout',function()
callback(true, 'Error': 'The request took much time and got timeout.')
);

// Add the payload
req.write(stringPayload);

// End the request
req.end();
;


And here is where I call the aux method to send the request:



var stripeRequestObject = 
amount: (totalPrice*100),
currency: 'usd',
description: userData.name+'_'+Date.now(),
source: stripeToken,
;

genericHelper.sendRequest('https',
443,
'api.stripe.com',
'POST',
'v1/charges',
5,
'application/x-www-form-urlencoded',
stripeRequestObject);









share|improve this question



















  • 1




    I really do not understand why you wouldn't just use github.com/stripe/stripe-node for this. I know you said that you "need" to do this in plain Node, buy why? I'm curious.
    – Karl Reid
    Nov 11 at 21:00











  • Just a project and to learn :) no particular reason! I know there are bunches of libraries and modules that help a lot ^^
    – TiagoM
    Nov 12 at 19:10












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I am using nodejs without any library/npm to make a charge on stripe using the test api key.



However I am always getting 400 status code response, and can't understand why, can someone give me an hint?



Here is my request details:



 protocol: 'https:',
hostname: 'api.stripe.com',
method: 'POST',
path: 'v1/charges',
timeout: 5000,
headers:
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': 72 ,
auth: 'sk_test_JOXtNqPjvpFgLXMiwuWWKZxu:'


And here is my payload (using querystring.stringify):



amount=5000&currency=usd&description=Tiago_1541865841578&source=tok_amex


Thank you in advance for any help!



Here is the code, the method where I do the request it self:



helpers.sendRequest = function(protocol, port, hostname, method, path, timeoutSeconds, contentType, postData)

// Stringify the payload
var stringPayload = querystring.stringify(postData);

// Construct the request
var requestDetails =
'protocol' : protocol+':',
'hostname' : hostname,
'method' : method,
'path' : path,
'port' : port,
'auth': ('Bearer ' + Buffer.from(config.stripe.secretApiKeyTest).toString('base64') + ":"),
'timeout' : timeoutSeconds * 1000,
'headers' :
'Authorization': ('Bearer ' + Buffer.from(config.stripe.secretApiKeyTest).toString('base64') + ":"),
'teste':'ola',
"teste2":"ola2",
'Content-Type':contentType,
'Content-Length': Buffer.byteLength(stringPayload)

;

console.log("Request Details:")
console.log(requestDetails);
console.log("Payload:")
console.log(stringPayload);

// Instantiate the request object (using either the http or https module)
var _moduleToUse = protocol == 'http' ? http : https;
var req = _moduleToUse.request(requestDetails, function(res)
console.log(res.statusCode);

);

// Bind to the error event so it doesn't get thrown
req.on('error',function(e)
callback(err, e);
);

// Bind to the timeout event
req.on('timeout',function()
callback(true, 'Error': 'The request took much time and got timeout.')
);

// Add the payload
req.write(stringPayload);

// End the request
req.end();
;


And here is where I call the aux method to send the request:



var stripeRequestObject = 
amount: (totalPrice*100),
currency: 'usd',
description: userData.name+'_'+Date.now(),
source: stripeToken,
;

genericHelper.sendRequest('https',
443,
'api.stripe.com',
'POST',
'v1/charges',
5,
'application/x-www-form-urlencoded',
stripeRequestObject);









share|improve this question















I am using nodejs without any library/npm to make a charge on stripe using the test api key.



However I am always getting 400 status code response, and can't understand why, can someone give me an hint?



Here is my request details:



 protocol: 'https:',
hostname: 'api.stripe.com',
method: 'POST',
path: 'v1/charges',
timeout: 5000,
headers:
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': 72 ,
auth: 'sk_test_JOXtNqPjvpFgLXMiwuWWKZxu:'


And here is my payload (using querystring.stringify):



amount=5000&currency=usd&description=Tiago_1541865841578&source=tok_amex


Thank you in advance for any help!



Here is the code, the method where I do the request it self:



helpers.sendRequest = function(protocol, port, hostname, method, path, timeoutSeconds, contentType, postData)

// Stringify the payload
var stringPayload = querystring.stringify(postData);

// Construct the request
var requestDetails =
'protocol' : protocol+':',
'hostname' : hostname,
'method' : method,
'path' : path,
'port' : port,
'auth': ('Bearer ' + Buffer.from(config.stripe.secretApiKeyTest).toString('base64') + ":"),
'timeout' : timeoutSeconds * 1000,
'headers' :
'Authorization': ('Bearer ' + Buffer.from(config.stripe.secretApiKeyTest).toString('base64') + ":"),
'teste':'ola',
"teste2":"ola2",
'Content-Type':contentType,
'Content-Length': Buffer.byteLength(stringPayload)

;

console.log("Request Details:")
console.log(requestDetails);
console.log("Payload:")
console.log(stringPayload);

// Instantiate the request object (using either the http or https module)
var _moduleToUse = protocol == 'http' ? http : https;
var req = _moduleToUse.request(requestDetails, function(res)
console.log(res.statusCode);

);

// Bind to the error event so it doesn't get thrown
req.on('error',function(e)
callback(err, e);
);

// Bind to the timeout event
req.on('timeout',function()
callback(true, 'Error': 'The request took much time and got timeout.')
);

// Add the payload
req.write(stringPayload);

// End the request
req.end();
;


And here is where I call the aux method to send the request:



var stripeRequestObject = 
amount: (totalPrice*100),
currency: 'usd',
description: userData.name+'_'+Date.now(),
source: stripeToken,
;

genericHelper.sendRequest('https',
443,
'api.stripe.com',
'POST',
'v1/charges',
5,
'application/x-www-form-urlencoded',
stripeRequestObject);






node.js https stripe-payments stringify bad-request






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 10 at 16:59

























asked Nov 10 at 16:08









TiagoM

1,43832560




1,43832560







  • 1




    I really do not understand why you wouldn't just use github.com/stripe/stripe-node for this. I know you said that you "need" to do this in plain Node, buy why? I'm curious.
    – Karl Reid
    Nov 11 at 21:00











  • Just a project and to learn :) no particular reason! I know there are bunches of libraries and modules that help a lot ^^
    – TiagoM
    Nov 12 at 19:10












  • 1




    I really do not understand why you wouldn't just use github.com/stripe/stripe-node for this. I know you said that you "need" to do this in plain Node, buy why? I'm curious.
    – Karl Reid
    Nov 11 at 21:00











  • Just a project and to learn :) no particular reason! I know there are bunches of libraries and modules that help a lot ^^
    – TiagoM
    Nov 12 at 19:10







1




1




I really do not understand why you wouldn't just use github.com/stripe/stripe-node for this. I know you said that you "need" to do this in plain Node, buy why? I'm curious.
– Karl Reid
Nov 11 at 21:00





I really do not understand why you wouldn't just use github.com/stripe/stripe-node for this. I know you said that you "need" to do this in plain Node, buy why? I'm curious.
– Karl Reid
Nov 11 at 21:00













Just a project and to learn :) no particular reason! I know there are bunches of libraries and modules that help a lot ^^
– TiagoM
Nov 12 at 19:10




Just a project and to learn :) no particular reason! I know there are bunches of libraries and modules that help a lot ^^
– TiagoM
Nov 12 at 19:10












2 Answers
2






active

oldest

votes

















up vote
1
down vote



accepted










In the auth you need to add Bearer before the token, that's how you send tokens to API. I tried to do the request on postman and it works, you can use axios or superagent to perform the request in you js file
enter image description hereenter image description here






share|improve this answer




















  • Hi @Pedro Silva thanks for your reply, I added the Bearer tag on the Authorization but still the request doesnt go though :(
    – TiagoM
    Nov 10 at 16:48






  • 1




    Can you send me the full code you are using? In meantime, I will do a small script to try the request
    – Pedro Silva
    Nov 10 at 16:55










  • Hey Pedro just updated the question with the code detailed, I hope it helps, I will keep searching and try to find out a solution... thanks
    – TiagoM
    Nov 10 at 17:00










  • After analyzing your code, I realized it was too much complicated. So I created a simple script that you can adapt to your code that uses superagent to do the request pass all data you want as arguments and prints the results pastebin.com/tJCJTx3r In this link, there is an example script with the code. Feel free to adapt it to your needs, if you need more help let me know. In case it solves you problems, mark the answer as correct pls :D
    – Pedro Silva
    Nov 10 at 17:15






  • 1




    I will try to use it them, if I can I will post it here
    – Pedro Silva
    Nov 10 at 17:26

















up vote
2
down vote













That is how I did it.



const requestDetails = 
protocol: 'https:',
hostname: 'api.stripe.com',
port: 443,
method: 'POST',
path: '/v1/charges',
headers:
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(stringPayload),
Authorization: `Bearer $config.stripe.testAPIkey.Secret`

;


There is a typo in your code



'v1/charges'


should be



'/v1/charges'





share|improve this answer




















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53240809%2fgetting-error-400-when-calling-an-https-request-to-apply-a-charge-on-stripe-api%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote



    accepted










    In the auth you need to add Bearer before the token, that's how you send tokens to API. I tried to do the request on postman and it works, you can use axios or superagent to perform the request in you js file
    enter image description hereenter image description here






    share|improve this answer




















    • Hi @Pedro Silva thanks for your reply, I added the Bearer tag on the Authorization but still the request doesnt go though :(
      – TiagoM
      Nov 10 at 16:48






    • 1




      Can you send me the full code you are using? In meantime, I will do a small script to try the request
      – Pedro Silva
      Nov 10 at 16:55










    • Hey Pedro just updated the question with the code detailed, I hope it helps, I will keep searching and try to find out a solution... thanks
      – TiagoM
      Nov 10 at 17:00










    • After analyzing your code, I realized it was too much complicated. So I created a simple script that you can adapt to your code that uses superagent to do the request pass all data you want as arguments and prints the results pastebin.com/tJCJTx3r In this link, there is an example script with the code. Feel free to adapt it to your needs, if you need more help let me know. In case it solves you problems, mark the answer as correct pls :D
      – Pedro Silva
      Nov 10 at 17:15






    • 1




      I will try to use it them, if I can I will post it here
      – Pedro Silva
      Nov 10 at 17:26














    up vote
    1
    down vote



    accepted










    In the auth you need to add Bearer before the token, that's how you send tokens to API. I tried to do the request on postman and it works, you can use axios or superagent to perform the request in you js file
    enter image description hereenter image description here






    share|improve this answer




















    • Hi @Pedro Silva thanks for your reply, I added the Bearer tag on the Authorization but still the request doesnt go though :(
      – TiagoM
      Nov 10 at 16:48






    • 1




      Can you send me the full code you are using? In meantime, I will do a small script to try the request
      – Pedro Silva
      Nov 10 at 16:55










    • Hey Pedro just updated the question with the code detailed, I hope it helps, I will keep searching and try to find out a solution... thanks
      – TiagoM
      Nov 10 at 17:00










    • After analyzing your code, I realized it was too much complicated. So I created a simple script that you can adapt to your code that uses superagent to do the request pass all data you want as arguments and prints the results pastebin.com/tJCJTx3r In this link, there is an example script with the code. Feel free to adapt it to your needs, if you need more help let me know. In case it solves you problems, mark the answer as correct pls :D
      – Pedro Silva
      Nov 10 at 17:15






    • 1




      I will try to use it them, if I can I will post it here
      – Pedro Silva
      Nov 10 at 17:26












    up vote
    1
    down vote



    accepted







    up vote
    1
    down vote



    accepted






    In the auth you need to add Bearer before the token, that's how you send tokens to API. I tried to do the request on postman and it works, you can use axios or superagent to perform the request in you js file
    enter image description hereenter image description here






    share|improve this answer












    In the auth you need to add Bearer before the token, that's how you send tokens to API. I tried to do the request on postman and it works, you can use axios or superagent to perform the request in you js file
    enter image description hereenter image description here







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 10 at 16:17









    Pedro Silva

    37410




    37410











    • Hi @Pedro Silva thanks for your reply, I added the Bearer tag on the Authorization but still the request doesnt go though :(
      – TiagoM
      Nov 10 at 16:48






    • 1




      Can you send me the full code you are using? In meantime, I will do a small script to try the request
      – Pedro Silva
      Nov 10 at 16:55










    • Hey Pedro just updated the question with the code detailed, I hope it helps, I will keep searching and try to find out a solution... thanks
      – TiagoM
      Nov 10 at 17:00










    • After analyzing your code, I realized it was too much complicated. So I created a simple script that you can adapt to your code that uses superagent to do the request pass all data you want as arguments and prints the results pastebin.com/tJCJTx3r In this link, there is an example script with the code. Feel free to adapt it to your needs, if you need more help let me know. In case it solves you problems, mark the answer as correct pls :D
      – Pedro Silva
      Nov 10 at 17:15






    • 1




      I will try to use it them, if I can I will post it here
      – Pedro Silva
      Nov 10 at 17:26
















    • Hi @Pedro Silva thanks for your reply, I added the Bearer tag on the Authorization but still the request doesnt go though :(
      – TiagoM
      Nov 10 at 16:48






    • 1




      Can you send me the full code you are using? In meantime, I will do a small script to try the request
      – Pedro Silva
      Nov 10 at 16:55










    • Hey Pedro just updated the question with the code detailed, I hope it helps, I will keep searching and try to find out a solution... thanks
      – TiagoM
      Nov 10 at 17:00










    • After analyzing your code, I realized it was too much complicated. So I created a simple script that you can adapt to your code that uses superagent to do the request pass all data you want as arguments and prints the results pastebin.com/tJCJTx3r In this link, there is an example script with the code. Feel free to adapt it to your needs, if you need more help let me know. In case it solves you problems, mark the answer as correct pls :D
      – Pedro Silva
      Nov 10 at 17:15






    • 1




      I will try to use it them, if I can I will post it here
      – Pedro Silva
      Nov 10 at 17:26















    Hi @Pedro Silva thanks for your reply, I added the Bearer tag on the Authorization but still the request doesnt go though :(
    – TiagoM
    Nov 10 at 16:48




    Hi @Pedro Silva thanks for your reply, I added the Bearer tag on the Authorization but still the request doesnt go though :(
    – TiagoM
    Nov 10 at 16:48




    1




    1




    Can you send me the full code you are using? In meantime, I will do a small script to try the request
    – Pedro Silva
    Nov 10 at 16:55




    Can you send me the full code you are using? In meantime, I will do a small script to try the request
    – Pedro Silva
    Nov 10 at 16:55












    Hey Pedro just updated the question with the code detailed, I hope it helps, I will keep searching and try to find out a solution... thanks
    – TiagoM
    Nov 10 at 17:00




    Hey Pedro just updated the question with the code detailed, I hope it helps, I will keep searching and try to find out a solution... thanks
    – TiagoM
    Nov 10 at 17:00












    After analyzing your code, I realized it was too much complicated. So I created a simple script that you can adapt to your code that uses superagent to do the request pass all data you want as arguments and prints the results pastebin.com/tJCJTx3r In this link, there is an example script with the code. Feel free to adapt it to your needs, if you need more help let me know. In case it solves you problems, mark the answer as correct pls :D
    – Pedro Silva
    Nov 10 at 17:15




    After analyzing your code, I realized it was too much complicated. So I created a simple script that you can adapt to your code that uses superagent to do the request pass all data you want as arguments and prints the results pastebin.com/tJCJTx3r In this link, there is an example script with the code. Feel free to adapt it to your needs, if you need more help let me know. In case it solves you problems, mark the answer as correct pls :D
    – Pedro Silva
    Nov 10 at 17:15




    1




    1




    I will try to use it them, if I can I will post it here
    – Pedro Silva
    Nov 10 at 17:26




    I will try to use it them, if I can I will post it here
    – Pedro Silva
    Nov 10 at 17:26












    up vote
    2
    down vote













    That is how I did it.



    const requestDetails = 
    protocol: 'https:',
    hostname: 'api.stripe.com',
    port: 443,
    method: 'POST',
    path: '/v1/charges',
    headers:
    'Content-Type': 'application/x-www-form-urlencoded',
    'Content-Length': Buffer.byteLength(stringPayload),
    Authorization: `Bearer $config.stripe.testAPIkey.Secret`

    ;


    There is a typo in your code



    'v1/charges'


    should be



    '/v1/charges'





    share|improve this answer
























      up vote
      2
      down vote













      That is how I did it.



      const requestDetails = 
      protocol: 'https:',
      hostname: 'api.stripe.com',
      port: 443,
      method: 'POST',
      path: '/v1/charges',
      headers:
      'Content-Type': 'application/x-www-form-urlencoded',
      'Content-Length': Buffer.byteLength(stringPayload),
      Authorization: `Bearer $config.stripe.testAPIkey.Secret`

      ;


      There is a typo in your code



      'v1/charges'


      should be



      '/v1/charges'





      share|improve this answer






















        up vote
        2
        down vote










        up vote
        2
        down vote









        That is how I did it.



        const requestDetails = 
        protocol: 'https:',
        hostname: 'api.stripe.com',
        port: 443,
        method: 'POST',
        path: '/v1/charges',
        headers:
        'Content-Type': 'application/x-www-form-urlencoded',
        'Content-Length': Buffer.byteLength(stringPayload),
        Authorization: `Bearer $config.stripe.testAPIkey.Secret`

        ;


        There is a typo in your code



        'v1/charges'


        should be



        '/v1/charges'





        share|improve this answer












        That is how I did it.



        const requestDetails = 
        protocol: 'https:',
        hostname: 'api.stripe.com',
        port: 443,
        method: 'POST',
        path: '/v1/charges',
        headers:
        'Content-Type': 'application/x-www-form-urlencoded',
        'Content-Length': Buffer.byteLength(stringPayload),
        Authorization: `Bearer $config.stripe.testAPIkey.Secret`

        ;


        There is a typo in your code



        'v1/charges'


        should be



        '/v1/charges'






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 10 at 18:23









        gkont

        1039




        1039



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53240809%2fgetting-error-400-when-calling-an-https-request-to-apply-a-charge-on-stripe-api%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            How to read a connectionString WITH PROVIDER in .NET Core?

            Museum of Modern and Contemporary Art of Trento and Rovereto

            In R, how to develop a multiplot heatmap.2 figure showing key labels successfully