Stripe 银行卡支付(Java)

一:概述

参考博客:https://blog.csdn.net/Sunshine_Moon/article/details/113867159?utm_medium=distribute.pc_relevant.none-task-blog-2defaultBlogCommendFromMachineLearnPai2default-10.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2defaultBlogCommendFromMachineLearnPai2default-10.control

官方文档:https://stripe.com/docs/api/payment_methods/object

二:代码示例

import com.stripe.Stripe;
import com.stripe.exception.StripeException;
import com.stripe.model.*;import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;public class StripTest {private static String key="按官方文档获得key";public static void main(String[] args) throws Exception {//1.创建顾客 将生成 customerId 用以 strip用户
//        String customer = createCustomer();//2. 根据卡号创建 tokenIdtokenId();//3.//根据tokenId创建card 绑定 customer
//        card();//4.支付
//        stripePay();// 5.退款
//        stripeRefund(null);}//退款public static Boolean stripeRefund(String chargeId) throws StripeException {Stripe.apiKey = key;Map<String, Object> params = new HashMap<>();params.put("charge","chargeId");params.put("amount",100);//属于int类型,金额为分Refund refund = Refund.create(params);if ("succeeded".equalsIgnoreCase(refund.getStatus())) {System.out.println("true");return true;}else{System.out.println("false");return false;}}//支付public static void stripePay() throws StripeException {Stripe.apiKey =  key;Map<String, Object> params = new HashMap<>();//金额,实际金额*100,最小支付金额是0.5params.put("amount", 2000);//货币单位,小写,银行卡扣费货币换算stripe内部自行转换,我们不需要关心params.put("currency", "aud");
//        params.put("customer", "Customers对应id");params.put("customer", "customerId");params.put("description","My First Test Charge (created for API docs hf)");//是否立即捕获费用。默认为true。如果为false,则费用会发出授权(或预授权),以后需要捕获。未捕获的费用将在7天内到期。params.put("capture", true);Charge charge = Charge.create(params);//可以实时获取支付状态if ("succeeded".equals(charge.getStatus())) {//交易成功后,需要更新我们的订单表,修改业务参数,此处省略System.out.println("pay success");String id = charge.getId();System.out.println(id);} else {System.out.println("pay failure");}}//创建card 绑定 customerpublic static String card() throws StripeException {Stripe.apiKey =  key;Map<String, Object> retrieveParams = new HashMap<>();List<String> expandList = new ArrayList<>();expandList.add("sources");retrieveParams.put("expand", expandList);Customer customer =Customer.retrieve("customerId",retrieveParams,null);Map<String, Object> params = new HashMap<>();params.put("source", "tokenId");Card card =(Card) customer.getSources().create(params);//建议将卡号保存下来String cardId = card.getId();System.out.println(cardId);return cardId;}//创建tokenIdpublic static String tokenId() throws StripeException {Stripe.apiKey =  key;Map<String, Object> card = new HashMap<>();card.put("number", "4242424242424242");card.put("exp_month", "2");card.put("exp_year", "2022");card.put("cvc", "314");Map<String, Object> params = new HashMap<>();params.put("card", card);Token token = Token.create(params);//在后面创建银行卡时可以使用,传参过程无需再填写银行卡相关信息String tokenId = token.getId();System.out.println(tokenId);return tokenId;}//创建customerIdpublic static String createCustomer() throws StripeException {Stripe.apiKey = key;//创建客户时的参数,方便后面识别,具体参数详见api,这里的话推荐description参数必传,这里的值会展示在stripe平台上方便后面观察Map<String, Object> params = new HashMap<>();params.put("description","My First Test Customer (created for API docs hf)");Customer customer = Customer.create(params);//stripe平台Customers的唯一标识String customerId = customer.getId();System.out.println(customerId);return customerId;}
}

Stripe 银行卡支付(Java)相关推荐

  1. Stripe 银行卡支付功能初步指南(Java)

    Stripe 国外银行卡支付功能指南(Java) 简介 编写这篇文章的目的就是~~没有什么目的.网上关于stripe银行卡支付代码很多,有写得很好的,但是太多太杂了,不系统.所以我就结合项目中实际应用 ...

  2. 现代生活已经离不开的银行卡支付,背后原理其实没你想象的那么难!

    虽然现在我们主流的支付方式是使用支付宝/微信支付,但是当我们余额不足,或者选择从银行卡扣款时,将就会使用到银行卡支付. 所以今天我们就来来讲讲银行卡支付的相关原理,科普一下银行卡支付整个流程. 银行卡 ...

  3. stripe国际支付(对接支付宝、微信)

    前言:stripe国际支付现在网上资料很少,且不支持中国,所以如果要用需要去支持的国家注册商户,官网的java demo是用的spark框架,我这里用的spring,验签需要手动验签,且不能用官网的方 ...

  4. 银行卡支付的背后原理你了解吗?

    点击上方蓝色"程序猿DD",选择"设为星标" 回复"资源"获取独家整理的学习资料! 作者 | 楼下小黑哥 来源 | 程序通事 虽然现在我们主 ...

  5. 如何快速对接Stripe国际支付系统

    Stripe国际支付介绍 Stripe是由20多岁的两兄弟Patrick Collison和John Collison创办的Stripe为公司提供网上支付的解决方案.Stripe向服务的公司收取每笔交 ...

  6. java微信web支付开发_微信支付java开发详细第三方支付功能开发之支付宝web端支...

    这段时间把支付基本搞完了,因为做的过程中遇到许多问题,特地记录下来,同时方便其他java coder,废话少说,下面开始. 整体思路:在后台,根据参数创建支付宝客户端AlipayClient,发送参数 ...

  7. 支付系统设计:银行卡支付

    作者: 凤凰牌老熊 公众号:凤凰牌老熊 (转载已取得作者授权) 支付和交易 说到支付就不得不提交易.这两个概念在不同公司中是不一样的.我们的定义是,交易是生成订单:支付是对订单进行付款.订单生成过程我 ...

  8. 银行卡支付之连连支付

    项目中使用到银行卡支付,然后对接了连连支付.这里记录一下. 项目中用到连连支付的功能:实现绑卡,获取已绑定卡的信息,修改卡信息, 银行卡代扣,认证支付. 项目从开始到后来迭代,陆续使用了代扣功能,认证 ...

  9. 【支付】银行卡支付的行为主体介绍

    如果想研究银行卡支付,就得从行为主体研究,包括发卡机构,持卡人,特约商户,收单机构,银行卡组织等. 发卡机构 向持卡人发行各种银行卡,并通过提供各类相关的银行卡服务收取一定费用,是银行卡市场的发起者和 ...

最新文章

  1. 【Linux开发】linux设备驱动归纳总结(四):5.多处理器下的竞态和并发
  2. python 跳过_python-pytest学习(九)-跳过用例skip
  3. vbs脚本延时_Wincc的脚本进程执行问题
  4. linux cd 命令案例,15个关于Linux的‘cd’命令的练习例子
  5. linux内核那些事之buddy(慢速申请内存__alloc_pages_slowpath)(5)
  6. 微信游戏脑力大乱斗92一个计算机,微信脑力大乱斗答案大全_全关卡图文攻略_软吧...
  7. Bootstrap class快捷笔记
  8. 2021半年度博客总结
  9. git 中 A C D M R T U X 分别解释
  10. android 远程视频监控程序源码,详解基于Android已开放源代码的远程视频监控系统教程...
  11. Linux系统部署wordpress@林
  12. 基于Arduino的烟雾传感实验
  13. c51中sbit/sfr 用法
  14. iQunix F60机械键盘使用评价(精准踩雷)
  15. SpringBoot+Maven 多模块项目的构建、运行、打包实战
  16. Kali、Ubuntu、银河、Uos、deepin、Centos7(8) 等 Linux 如何使用 蓝牙
  17. mybatis中的驼峰转换
  18. matlab 图像隐藏,将Matlab下隐藏的图形保存为相同大小的图像
  19. matlab课程报告锅炉水温在10,基于matlab的锅炉水温
  20. mysql MDL锁如何解决_MYSQL METADATA LOCK(MDL LOCK)MDL锁问题分析

热门文章

  1. 浪擎科技SQLServer数据库同步准实时方案
  2. python安装(python3)与卸载
  3. mysql压力写入测试_mysql 压力测试
  4. 完全搞定iframe(框架)里的滚动条!(一)
  5. java 之break用法
  6. 线性卷积、周期卷积和循环卷积
  7. java jqgrid_jqgrid 前后端交互实例
  8. linux 定时任务关机,使用linux的crontab定时关机
  9. beatsx 蓝牙耳机连接windows 10 音质不好的问题
  10. 关于谢尔宾斯基地毯的讲解