Хотя это и не прямое преобразование кода Java, который вы предоставили выше, было бы довольно просто сделать это с cfscript
, используя http service функции. Например:
<cfscript>
secKey = "sk_test_xxxx";
/* create new http service */
httpService = new http();
httpService.setMethod("post");
httpService.setCharset("utf-8");
httpService.setUrl("https://api.stripe.com/v1/checkout/sessions");
/* add header */
httpService.addParam(type="header", name="Authorization", value="Bearer " & secKey);
/* add params */
httpService.addParam(type="formfield",name="success_url",value="https://example.com/success");
httpService.addParam(type="formfield",name="cancel_url",value="https://example.com/fail");
httpService.addParam(type="formfield",name="payment_method_types[]",value="card");
httpService.addParam(type="formfield",name="line_items[0][amount]",value="1000");
httpService.addParam(type="formfield",name="line_items[0][currency]",value="usd");
httpService.addParam(type="formfield",name="line_items[0][quantity]",value="1");
httpService.addParam(type="formfield",name="line_items[0][name]",value="widget");
/* make the http call */
result = httpService.send().getPrefix();
/* parse json and print id */
chkSession = DeserializeJSON(result.fileContent);
writeoutput(chkSession.id)
</cfscript>