2017-07-26 42 views
2

新的客戶記錄我有一個新的客戶是誰退房,並希望他們的存儲卡以備將來使用。如果我正確閱讀documentation,我需要分別撥打電話給Stripe,一個用卡創建客戶,另一個用來爲卡充電。安卓:創建帶區API

的問題是..有一種方式來創建新的客戶記錄成條紋由剛剛使用Android/Java的代碼不使用任何後端服務器大小碼,如PHP,Node.js的,等等?我在與文檔的麻煩

原因說明here爲Java。我試圖按照文檔,但可悲的是,代碼將無法在我的Android項目中工作(即使我將它添加到build.gradle等)

我是新來的條紋,所以我不是那麼有知識。

這是我試圖跟隨並適用於我的項目中的代碼。

// 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.apiKey = "sk_test_ejKNr41rD0SbiNVxkZOcneG0"; 

// Token is created using Stripe.js or Checkout! 
// Get the payment token submitted by the form: 
String token = request.getParameter("stripeToken"); 

// Create a Customer: 
Map<String, Object> customerParams = new HashMap<String, Object>(); 
customerParams.put("email", "[email protected]"); 
customerParams.put("source", token); 
Customer customer = Customer.create(customerParams); 

// Charge the Customer instead of the card: 
Map<String, Object> chargeParams = new HashMap<String, Object>(); 
chargeParams.put("amount", 1000); 
chargeParams.put("currency", "eur"); 
chargeParams.put("customer", customer.getId()); 
Charge charge = Charge.create(chargeParams); 

// YOUR CODE: Save the customer ID and other info in a database for later. 

// YOUR CODE (LATER): When it's time to charge the customer again, retrieve the customer ID. 
Map<String, Object> chargeParams = new HashMap<String, Object>(); 
chargeParams.put("amount", 1500); // $15.00 this time 
chargeParams.put("currency", "eur"); 
chargeParams.put("customer", customerId); 
Charge charge = Charge.create(chargeParams); 

回答

1

有沒有一種方法來創建一個新的客戶記錄成條紋由剛剛使用Android/Java的代碼不使用任何後端服務器大小碼,如PHP,Node.js的,等等?

否Stripe的Android SDK只能用於收集和標記客戶付款信息。該操作使用可發佈的API密鑰完成。

所有其它操作(例如,使用令牌create a customer objecta charge)使用你的密鑰,這絕不能共享或嵌入在移動應用程序爲攻擊者可隨後檢索它並使用它來發出API請求完成代表你。

條紋確實提供了一個Java library,但它是爲服務器端使用,而不是被從Android移動應用使用。

+0

我看到..感謝製作這一點。我只是想知道是否有一個Android選項。那麼,我需要訴諸Node.js -_- –