1
我是Stripe整合和Java的新手,我想要做的第一件事是收取信用卡。我正在使用java。這是充電卡的代碼。使用java在條紋中充電卡
enter code here
//CHARGING THE CARD
Stripe.apiKey = "cgchhcchv";
// Get the credit card details submitted by the form
String token = request.getParameter("stripeToken");
// Create the charge on Stripe's servers - this will charge the user's card
try {
Map<String, Object> chargeParams = new HashMap<String, Object>();
chargeParams.put("amount", 1000); // amount in cents, again
chargeParams.put("currency", "usd");
chargeParams.put("source", token);
chargeParams.put("description", "Example charge");
Charge charge = Charge.create(chargeParams);
} catch (CardException e) {
// The card has been declined
}
我加入了條紋庫,他們似乎很好地工作,但試圖執行該代碼這些錯誤輸出時:「HashMap中不能被解析爲一個類型」,「請求不能得到解決」。我不明白爲什麼這些錯誤輸出,即使當我創建這些無法解決的變量。有人可以解釋這一點嗎?問候!
你需要在你的代碼的類,如果你想使用它們。像'import java.util.HashMap;'在你的文件的頂部能夠使用HashMap的例子 – koopajah
感謝它的工作。請求var怎麼樣? –
我想你需要一個允許你從請求中檢索POST參數的包。根據您構建集成的方式,有很多包可以在Java中爲您執行此操作。例如:http://docs.oracle.com/javaee/5/api/javax/servlet/ServletRequest.html#getParameter%28java.lang.String%29 – koopajah