Stripe Payment(1)Introduction Of Payments and Docs
Test Card Number
https://stripe.com/docs/testing#cards
1. Checkout form
https://stripe.com/docs/tutorials/checkout
The data will be sent to Stripe and Stripe will auto post a token to our server side.
<form action="http://requestb.in/w8djhzw8" method="POST">
<script
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="pk_test_rRej93hjdXTW9TaWUGSv1odD"
data-amount="2000"
data-name="Demo Site"
data-description="2 widgets ($20.00)"
data-image="/128x128.png"
data-locale="auto">
</script>
2. Charge the Customer
https://stripe.com/docs/tutorials/charges
https://stripe.com/docs/api#create_charge
Try with Java API in Scala
The Dependency
"com.stripe" % "stripe-java" % "1.37.0", //MIT
The JAVA Codes
package com.sillycat.stripe
import java.util
import com.stripe.Stripe
import com.stripe.model.Charge
object StripeApp extends App{
Stripe.apiKey = "sk_test_xxxxxxx"
val token = "tok_xxxxxxxxxxx"
val chargeParams = new util.HashMap[String, Object]()
chargeParams.put("amount", new Integer(400))
chargeParams.put("currency", "usd")
chargeParams.put("source", token)
chargeParams.put("description", "Charge for test@example.com")
val charge:Charge = Charge.create(chargeParams)
println(charge)
}
Stripe tokens can only be used once.
All the APIs are here.
https://stripe.com/docs/api/java#capture_charge
3. Creating Subscription
https://stripe.com/docs/tutorials/subscriptions
We first create plan, and the plan can be day, week, month or year.
https://stripe.com/docs/api/java#create_plan
Then we subscribe a customer to a plan.
https://stripe.com/docs/api/java#create_customer
4. Share Charges
https://stripe.com/docs/connect/payments-fees
https://stripe.com/docs/api#create_account
First of all, Go to [Connect] and Register my Platform Settings.
The flow I tried:
1. Step 1. Create platform account for Sillycat. (platform)
2. Step 2. Use API to create connect account in Sillycat for Kiko. (third party application name)
3. Step 3. End user Carl post payment 20$ to Kiko in browser(Can be our iOS or Android application)
4. Step 4. There is a web hook that once the payment is sent, our HTTP API Server side will receive a token from Stripe.
5. Step 5. Using that payment token, we will create a user account for the end user Carl and receiving a customer token.
6. Step 6. In the web hook HTTP Server, we will call stripe JAVA API with the customer token to split the payment 20$ into 10$ to customer account Kiko (No transaction fee from stripe), 0.88$ into stripe(Transaction fee), 9.12$ into platform account Sillycat.
Some Notes:
1. We can create many other connect accounts, like Kiko2, Kiko3 and etc.
2. We can save the customer token for future payment. We can charge the customer any time we need.
Here is the core codes in sillycat-stripe
package com.sillycat.stripe
import java.util
import com.stripe.Stripe
import com.stripe.model.{Customer, Account, Charge}
object StripeApp extends App{
Stripe.apiKey = "sk_test_M1rxxxxx" // luohuazju
//Stripe.apiKey = "sk_test_35ffxxxxxx" //cluo
val token = "tok_16qnxxxxxx"
// //Creating an account
// val accountParams = new util.HashMap[String, Object]()
// accountParams.put("managed", java.lang.Boolean.FALSE)
// accountParams.put("country", "US")
// accountParams.put("email", "cluo@jobs2careers.com")
//
// Account.create(accountParams)
// //fetch Account
// val result = Account.retrieve()
// println(result)
//create customer
// val customerParams = new util.HashMap[String, Object]()
// customerParams.put("description", "Customer for test@example.com")
// customerParams.put("source", token)
//
// Customer.create(customerParams)
//list Customers
// val customerParams = new util.HashMap[String, Object]()
// customerParams.put("limit", new Integer(3))
//
// val results = Customer.all(customerParams)
// println(results)
//Charge
val chargeParams = new util.HashMap[String, Object]()
chargeParams.put("amount", new Integer(1000))
chargeParams.put("currency", "usd")
//chargeParams.put("source", token)
chargeParams.put("customer", "cus_74xxxxxx")
chargeParams.put("description", "Charge for cluo@example.com")
chargeParams.put("destination", "acct_16qmbxxxxx")
chargeParams.put("application_fee", new Integer(500))
val charge:Charge = Charge.create(chargeParams)
println(charge)
}
References:
http://www.kuqin.com/shuoit/20150728/347262.html stripe with swift
official document
https://stripe.com/docs
https://stripe.com/docs/api#create_charge
Test Card Number
https://stripe.com/docs/testing#cards
1. Checkout form
https://stripe.com/docs/tutorials/checkout
The data will be sent to Stripe and Stripe will auto post a token to our server side.
<form action="http://requestb.in/w8djhzw8" method="POST">
<script
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="pk_test_rRej93hjdXTW9TaWUGSv1odD"
data-amount="2000"
data-name="Demo Site"
data-description="2 widgets ($20.00)"
data-image="/128x128.png"
data-locale="auto">
</script>
2. Charge the Customer
https://stripe.com/docs/tutorials/charges
https://stripe.com/docs/api#create_charge
Try with Java API in Scala
The Dependency
"com.stripe" % "stripe-java" % "1.37.0", //MIT
The JAVA Codes
package com.sillycat.stripe
import java.util
import com.stripe.Stripe
import com.stripe.model.Charge
object StripeApp extends App{
Stripe.apiKey = "sk_test_xxxxxxx"
val token = "tok_xxxxxxxxxxx"
val chargeParams = new util.HashMap[String, Object]()
chargeParams.put("amount", new Integer(400))
chargeParams.put("currency", "usd")
chargeParams.put("source", token)
chargeParams.put("description", "Charge for test@example.com")
val charge:Charge = Charge.create(chargeParams)
println(charge)
}
Stripe tokens can only be used once.
All the APIs are here.
https://stripe.com/docs/api/java#capture_charge
3. Creating Subscription
https://stripe.com/docs/tutorials/subscriptions
We first create plan, and the plan can be day, week, month or year.
https://stripe.com/docs/api/java#create_plan
Then we subscribe a customer to a plan.
https://stripe.com/docs/api/java#create_customer
4. Share Charges
https://stripe.com/docs/connect/payments-fees
https://stripe.com/docs/api#create_account
First of all, Go to [Connect] and Register my Platform Settings.
The flow I tried:
1. Step 1. Create platform account for Sillycat. (platform)
2. Step 2. Use API to create connect account in Sillycat for Kiko. (third party application name)
3. Step 3. End user Carl post payment 20$ to Kiko in browser(Can be our iOS or Android application)
4. Step 4. There is a web hook that once the payment is sent, our HTTP API Server side will receive a token from Stripe.
5. Step 5. Using that payment token, we will create a user account for the end user Carl and receiving a customer token.
6. Step 6. In the web hook HTTP Server, we will call stripe JAVA API with the customer token to split the payment 20$ into 10$ to customer account Kiko (No transaction fee from stripe), 0.88$ into stripe(Transaction fee), 9.12$ into platform account Sillycat.
Some Notes:
1. We can create many other connect accounts, like Kiko2, Kiko3 and etc.
2. We can save the customer token for future payment. We can charge the customer any time we need.
Here is the core codes in sillycat-stripe
package com.sillycat.stripe
import java.util
import com.stripe.Stripe
import com.stripe.model.{Customer, Account, Charge}
object StripeApp extends App{
Stripe.apiKey = "sk_test_M1rxxxxx" // luohuazju
//Stripe.apiKey = "sk_test_35ffxxxxxx" //cluo
val token = "tok_16qnxxxxxx"
// //Creating an account
// val accountParams = new util.HashMap[String, Object]()
// accountParams.put("managed", java.lang.Boolean.FALSE)
// accountParams.put("country", "US")
// accountParams.put("email", "cluo@jobs2careers.com")
//
// Account.create(accountParams)
// //fetch Account
// val result = Account.retrieve()
// println(result)
//create customer
// val customerParams = new util.HashMap[String, Object]()
// customerParams.put("description", "Customer for test@example.com")
// customerParams.put("source", token)
//
// Customer.create(customerParams)
//list Customers
// val customerParams = new util.HashMap[String, Object]()
// customerParams.put("limit", new Integer(3))
//
// val results = Customer.all(customerParams)
// println(results)
//Charge
val chargeParams = new util.HashMap[String, Object]()
chargeParams.put("amount", new Integer(1000))
chargeParams.put("currency", "usd")
//chargeParams.put("source", token)
chargeParams.put("customer", "cus_74xxxxxx")
chargeParams.put("description", "Charge for cluo@example.com")
chargeParams.put("destination", "acct_16qmbxxxxx")
chargeParams.put("application_fee", new Integer(500))
val charge:Charge = Charge.create(chargeParams)
println(charge)
}
References:
http://www.kuqin.com/shuoit/20150728/347262.html stripe with swift
official document
https://stripe.com/docs
https://stripe.com/docs/api#create_charge