博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Stripe文档(部分翻译)
阅读量:4292 次
发布时间:2019-05-27

本文共 6598 字,大约阅读时间需要 21 分钟。

        Stipe 是一个坐落于美国旧金山的一家公司,聚焦做互联网的在线支付和移动支付,每年有百万美元的流水,目前支持25个国家的商业伙伴。国内做这种东西的比较多,例如聚合支付,财付通,银联等等,把各种银行卡引用卡或者googlePay,ApplePay,Alipay,weChatPay等做到一个平台上,方便商家和开发者。并且在中间拿自己的服务费用。

        在我的概念中,Strip不一定是最好的支付服务商。但是你懂得,坐落于美国,拥有更好的全球视野。对世界上非常多的银行的支持等是非常多的,而且产品的文档和支持也非常完善。分公司办事处目前有美国,新西兰,澳大利亚没有中国,没有汉语。这个是非常让人生气的。

 , 本人使用了一点时间,翻译了客户端常用的几个操作实例和对应的代码。详尽的业务场景和实例,可以看官方文档。或者官方Api...

        这里我看到了一个android集成的中文客户端文档,需要的,可以点击看看,写得不错:

创建支付:

            你一旦安全地使用Checkout或者Element收集信息和获取token,你就可以立即去支付或者为了以后保存它。
不同于发生在浏览器的tokenization,支付是从服务器端发起的。通常情况下,使用客户端库。
在服务端,通过post参数获取StripeToken。
String token = request.getParameter("stripeToken");
//一次性支付
Map<String, Object> params = new HashMap<>();
params.put("amount", 999);
params.put("currency", "usd");
params.put("description", "Example charge");
params.put("source", token);
Charge charge = Charge.create(params);
// Charging cards with Stripe is a synchronous process. Your code will immediately receive the result of the request: 
// either a Charge object upon success or an exception upon failure. No asynchronous webhook or IPN script is required.
//
String token = request.getParameter("stripeToken");
Map<String, Object> params = new HashMap<>();
params.put("amount", 999);
params.put("currency", "usd");
params.put("description", "Example charge");
params.put("source", token);
params.put("statement_descriptor", "Custom descriptor");//出现在客户状态里,限定22个字符。

Charge charge = Charge.create(params);

Auth and capture

            stripe支持两步卡支付,你可以第一次授权一个交易,然后等待settle(capture)它。当一个交易被授权,资金可以被CardIssur担保,持有在客户的卡片上
长达7天,如果交易没有被captured,授权会被取消,资金会被释放。
授权一个不capture的支付,capture字段为false,
String token = request.getParameter("stripeToken");
Map<String, Object> params = new HashMap<>();
params.put("amount", 999);
params.put("currency", "usd");
params.put("description", "Example charge");
params.put("source", token);
params.put("capture", false);
Charge charge = Charge.create(params);
//
Charge charge = Charge.retrieve("ch_heCQmwBejap7yeYNwjnS");

charge.capture();

保存卡片:

            当你手机用户的支付方式的信息时,一个StripeToken就需要创建。这个StripeToken只能使用一次,但是这并不意味着你每次支付的时候都使用
用户的卡片信息。
Stipe提供 Customer类,用来保存卡片和其他信息。可以使用 Customer对象来创建 订阅或者以后离线支付。
// Create a Customer:
Map<String, Object> chargeParams = new HashMap<>();
chargeParams.put("source", "tok_mastercard");
chargeParams.put("email", "paying.user@example.com");
Customer customer = Customer.create(chargeParams);
// Charge the Customer instead of the card:
Map<String, Object> customerParams = new HashMap<>();
customerParams.put("amount", 1000);
customerParams.put("currency", "usd");
customerParams.put("customer", customer.getId());
Charge charge = Charge.create(customerParams);
// YOUR CODE: Save the customer ID and other info in a database for later.
// When it's time to charge the customer again, retrieve the customer ID.
Map<String, Object> params = new HashMap<>();
params.put("amount", 1500); // $15.00 this time
params.put("currency", "usd");
params.put("customer", customerId); // Previously stored, then retrieved
Charge charge = Charge.create(params);

争议与欺诈:

当持卡人对他们卡的支付发生争议时,例如扣押等。

货币兑换:

Stripe支持处理135+个货币兑换成客户当地的货币。

退款:

https://stripe.com/docs/refunds
Stripe支持来自于你账户的退款,无论是整体,还是部分。如果你原始的订单正在进行货币兑换,退款的数额使用相同的处理返回。
我们提交一个你的客户的银行或者卡信息的退款请求,你的客户会在信用卡5-10个工作日之后看到退款的数额,这个取决于银行。一旦提交,一个
退款的请求不能被取消。
我们同样会发送一个email给你的客户,通知他们退款,取决于下列的设置:
原始订单是使用 Customer 对象创建的,Customer对象保存有email,你已经打开emailForrefunds功能。
Map<String, Object> params = new HashMap<>();
params.put("charge", "ch_TgizFvKWMUNh6BextBaj");//The identifier of the charge to refund
Refund refund = Refund.create(params);
//
Map<String, Object> params = new HashMap<>();
params.put("charge", "ch_QOVPoF0iSBnNnIEHj94b");
params.put("amount", 1000);//部分退款,使用amount字段。
Refund refund = Refund.create(params);

Stripe.js and Element:

https://stripe.com/docs/stripe-js
Stripe.js是我们建设支付流程的基本javaScript库。使用它,可以从用户收集敏感信息,和创建有代表性的Token用来传送到你的服务器。
Stripe.js使得敏感信息的处理变得更加简单:
包括:卡片信息,银行账户详情,个人标识信息(PII),各种种类的支付方式代码。
Stripe.js同时也提供了简单的applePlay,GooglePlay的接口和支付请求的API.

Stripe Elements:

StripeElements是一组预置的UI组件,用来开发支付流程。同样可以作为Stripe.js的功能提供。提供了现成的UI组件例如输入用户信息和按钮。
Stripe.js在内置的element标签中会加密敏感信息,而且不需要连接你的服务器。
功能包括:自动格式化用户卡号,自动翻译用户所在的语言环境,自动适配用户的屏幕或者移动设备,可自定义样式。

接收支付:

Stripe会存入可用的账户额度到你的银行卡账户。这个账户额度可以是支付,也可以是退款等。
当开始使用Stripe处理时,第一笔账单会在成功支付的7-10天后到账。之后的账单支付,会在你账户设定的payout schedule设定周期进行。这
允许Stripe减轻处理银行卡事务的压力。
你可以在Dashboard里面,查看所有账单数据,和已经银行卡体现的数据。

Billing:发票:

https://stripe.com/docs/billing/quickstart
你可以使用Stripe很容易给客户做账单。你可以在需要的时候给客户提供发票,也可以配置自定的订阅。
自动建立用户的账单,遵循下列三步走:
1,定义一个服务产品和定价计划,确定应该计入多少,在什么时间间隔
2,使用Stripe账户创建一个Customer.
3,订阅一个用户计划
创建你想给你客户提供的服务,两种产品product:goods和services。
goods:用来提供ordersAPI的订阅。
Stripe.apiKey = "sk_test_rbOdAvYTZsHZvWEobu5sz3LM";
Map<String, Object> params = new HashMap<String, Object>();
params.put("name", "My SaaS Platform");
params.put("type", "service");
Product.create(params);//返回一个ID.用来配置计划。
plan:
用来代表每次花费,金额和计费周期等。每一个计划,附属在product内。你可以创建一个,或者几百个。
Stripe.apiKey = "sk_test_rbOdAvYTZsHZvWEobu5sz3LM";
Map<String, Object> params = new HashMap<String, Object>();
params.put("product", "prod_CbvTFuXWh7BPJH");
params.put("nickname", "SaaS Platform USD");
params.put("interval", "month");
params.put("currency", "usd");
params.put("amount", 10000);
Plan plan = Plan.create(params);
//
Customer,你可以不使用支付方式创建客户,用来后来的订单。
//
使客户订阅到你的计划中。

测试:

https://stripe.com/docs/testing#cards

4242424242424242
Visa
4000056655665556
Visa (debit)
5555555555554444
Mastercard
2223003122003222
Mastercard (2-series)
5200828282828210
Mastercard (debit)
5105105105105100
Mastercard (prepaid)
378282246310005
American Express
371449635398431
American Express
6011111111111117
Discover
6011000990139424
Discover
30569309025904
Diners Club
38520000023237
Diners Club
3566002020360505
JCB
6200000000000005
UnionPay
tok_visa
Visa
tok_visa_debit
Visa (debit)
tok_mastercard
Mastercard
tok_mastercard_debit
Mastercard (debit)
tok_mastercard_prepaid
Mastercard (prepaid)
tok_amex
American Express
tok_discover
Discover
tok_diners
Diners Club

测试:

https://stripe.com/docs/testing#cards

4242424242424242
Visa
4000056655665556
Visa (debit)
5555555555554444
Mastercard
2223003122003222
Mastercard (2-series)
5200828282828210
Mastercard (debit)
5105105105105100
Mastercard (prepaid)
378282246310005
American Express
371449635398431
American Express
6011111111111117
Discover
6011000990139424
Discover
30569309025904
Diners Club
38520000023237
Diners Club
3566002020360505
JCB
6200000000000005
UnionPay
tok_visa
Visa
tok_visa_debit
Visa (debit)
tok_mastercard
Mastercard
tok_mastercard_debit
Mastercard (debit)
tok_mastercard_prepaid
Mastercard (prepaid)
tok_amex
American Express
tok_discover
Discover
tok_diners
Diners Club

转载地址:http://vjegi.baihongyu.com/

你可能感兴趣的文章
让数据库不再成为业务发展瓶颈——分布式数据库架构设计
查看>>
java多线程有哪些实际的应用场景?
查看>>
分布式集群Session共享~多个tomcat7+redis的session共享实现
查看>>
实例|如何从两个List中筛选出相同的值
查看>>
搭建ECS云服务器(5)设置nginx+fastdfs+tomcat+redis开启自启动
查看>>
SSO单点登录的发展由来以及实现原理
查看>>
阿里巴巴,排行前10的开源项目,第一不是Dubbo!
查看>>
手把手教你新装的linux之后的必要配置(9)
查看>>
Java互联网架构-Spring分布式事务
查看>>
持久化框架:轻量级的关系型数据库中间件 Sharding-JDBC
查看>>
Java中如何实现分页功能
查看>>
简述架构演变过程中对session存储以及权限校验的不同的解决方案
查看>>
Spring Cloud是什么,和Dubbo对比如何?
查看>>
【Lucene】Apache Lucene全文检索引擎架构之入门实战
查看>>
【Lucene】Apache Lucene全文检索引擎架构之构建索引
查看>>
Apache Lucene全文检索引擎架构之搜索功能
查看>>
【Lucene】Apache Lucene全文检索引擎架构之中文分词和高亮显示
查看>>
搜索服务Solr集群搭建 使用ZooKeeper作为代理层
查看>>
Java互联网架构-MyCat介绍与基本使用
查看>>
网易云基础服务郭忆:谈谈数据库的跨机房容灾
查看>>