Stripe Payment(1)Introduction Of Payments and Docs

本文详细介绍Stripe支付系统的使用方法,包括测试卡号、收费流程、订阅创建等核心功能,并通过Java API示例展示如何进行收费及分配。此外还介绍了如何利用Stripe Connect实现平台与第三方账户之间的支付分享。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值