前端对接stripe支付,创建测试session_is

article/2025/4/20 0:59:58

第一次搞 stripe支付,国外的文档全英文


接stripe支付,根据官方文档,首先就是先跟服务端交互,创建session会话,获取id,当服务端不做这个功能时,就需要前端去掉stripe最底层的api,拿到session_id,这时候懵逼了,找吧文档都有


官网正常对接服务端的接支付流程:点击


创建session会话最底层的api,服务端不对接,需要前端去自己对接,点击


这里只是我接触过的,有错误指出来,一起学习,第一次搞这玩意,记录下来,也为后期别的童鞋,让他们少走点弯路


接通后是这样,拿这个id
在这里插入图片描述

调用 https://api.stripe.com/v1/checkout/sessions 这个底层接口,它是 post application/x-www-form-urlencoded请求,所以在传参数的时候,需要处理一下参数,我用的qs处理了一下,它是curl请求,第一个-u 参数,我理解的是加密需要权限,需要在请求头里添加Authorization,它的格式要求加Bearer 你的秘钥

 headers: {"Content-Type": "application/x-www-form-urlencoded",Authorization:"Bearer  sk_testxxxx秘钥",},

只传文档的参数,是不行的,格式必须要按照它的格式,这里是我最终的参数和格式

 var params = {success_url: "https://example.com/success",cancel_url: "https://example.com/cancel","line_items[0][amount]": 999,"line_items[0][currency]": "usd","payment_method_types[0]": "card","line_items[0][name]": "你的用户名",//这里你需要去后台关联一个用户名"line_items[0][quantity]": 2,mode: "payment",};

完整的一个请求创建session会话

   onClick_test() {const stripe = Stripe("pk_test_xxxx你的其中一个秘钥");var params = {success_url: "https://example.com/success",cancel_url: "https://example.com/cancel","line_items[0][amount]": 999,"line_items[0][currency]": "usd","payment_method_types[0]": "card","line_items[0][name]": "你的用户名","line_items[0][quantity]": 2,mode: "payment",};Axios.post("https://api.stripe.com/v1/checkout/sessions",qs.stringify(params),{headers: {"Content-Type": "application/x-www-form-urlencoded",Authorization:"Bearer sk_test_xxxxxx",},}).then((res) => {let {data,status}=res;console.log(res, "返回值===========");});},

http://chatgpt.dhexx.cn/article/nUYeOO8t.shtml

相关文章

Stripe支付简介和前端js调用

最近公司正在做一个国际版APP,涉及到海外支付,调研过Paypal、Skrill、BrainTree、Stripe(可参考海外移动支付方案对比),最终 选择了Stripe支付。Stripe特点如下: 收费规则简单透明,手续费就是收…

laravel 对接stripe支付

参考文档 : stripe文档 stripe/stripe-php stripe api 文档 目录 一 获取关键参数二 安装Stripe库三 代码示例 一 获取关键参数 SCRIPE_SECRET_KEY (调用api秘钥) NOTIFY_SIGN (签名 支付回调使用) 二 安装Stripe库 # Install the PHP libr…

Stripe支付配置

开通支付 首先,你需要在 Stripe 官网开通你自己的支付账号信息: https://stripe.com/ 注册好以后,你即可获取 Stripe 的密钥信息: 密钥主要包含两部分,可发布的密钥 密钥 同时,你需要找到你交易的对应的货…

php实现Stripe支付 | ecshop stripe支付

Stripe支付 :Stripe Login | Sign in to the Stripe Dashboard 1. 安装Stripe: composer require stripe/stripe-php 2. 获取密钥:https://dashboard.stripe.com/test/apikeys 3. 创建产品:Stripe Login | Sign in to the Stri…

php实现Stripe支付

Stripe支付 :https://dashboard.stripe.com/dashboard 1. 安装Stripe: composer require stripe/stripe-php 2. 获取密钥: https://dashboard.stripe.com/test/apikeys 3. 创建产品: https://dashboard.stripe.com/test/product…

stripe 支付

stripe 支付整理 1、创建账号 官方网址 中文版 https://stripe.com/zh-cn-us/payments 2、激活你的账号 填写信息只支持国外与香港的哦 3、开发者秘钥 如果不激活的话,只能用测试api秘钥 4、配置你的回调地址 配置秘钥,选择webhook事件 事件一定要选择…

java 对接 stripe支付

stripe 支付跟国内的 支付宝 、微信、等第三方支付平台不一样 码字不易,开源更不易,点赞收藏关注,多多支持 开源地址 https://gitee.com/J-LJJ/stripe-demo 支付方式一 先看效果 支付方式2(需要配合回调) 2023-04…

Stripe支付流程简要描述

在国外,除了Paypal支付之外,Stripe支付也占有很大一部分市场份额,Stripe支付官网 https://stripe.com/ 下面简单介绍一下Stripe的支付流程。 1、用户页面输入充值金额,点击确定跳转到支付页面(页面的样式由stripe提供…

stripe支付集成

最近公司要做一下Stripe支付的集成,浅浅地谈一下自己的一点理解 1、stripe是什么? stripe是第三方的支付平台,就像国内的支付宝、微信支付。。。 stripe官方文档:Developer tools | Stripe Documentation 关于stripe支付&…

初步认识 Stripe 支付

前言 这段时间在做支付相关的工作,由于业务主要是面向国外的用户,因而就接触了部分国外的支付支付相关的平台。接下来的内容主要是初步看了 Stripe 平台的文档所了解到的基本内容,后面会在使用的过程中不断地进行完善。 基本介绍和与其他支…

Stripe支付流程

近几天因为公司的项目中遇到了需要支持给国外本土支付提供支持,经过调研了市面上几款的产品后选择了stripe支付 由于资料比较少没有太多讨论,慢慢查看官方文档以下是我对官方文档梳理和对接过程中的一些经验和理解记录了下来 关于Stripe Stripe是一家提…

Stripe国际支付简介及API对接

文章目录 一、了解Stripe支付二、Stripe注册流程三、Stripe API 特点3.1 Apikey3.2 Idempotent Requests 幂等请求3.3 两种付款方式 四、Stripe 支付核心API4.1 Token4.2 Customer4.3 Card4.4 Source4.5 charge4.6 PaymentIntents4.7 PaymentMethod 五、完整Stripe支付代码 一、…

mingw(msys2)编译ffmpeg

mingw(msys2)编译ffmpeg 首先要确保pacman环境是最新的,否则会出现莫名其妙的问题,可以执行“pacman -Syu”更新包 安装mingw: pacman -S gcc mingw-w64-i686-toolchain yasm mingw-w64-i686-SDL2 //mingw32 pacman -S gcc mingw-w64-x86_64-toolchai…

Hyperscan Windows 编译指南

Hyperscan Windows 编译指南 Hyperscan 源码下载:https://www.hyperscan.io/准备环境: Windows 10 X64 Cygwin : https://www.cygwin.com/ CMake:https://cmake.org/ Visual Studio 2017 Python (2.7 版本) Boost : https://www.boost…

Hyperscan 5.4.0 安装教程 (CentOS7环境)

参考:Getting Started — Hyperscan 5.4.0 documentationhttp://intel.github.io/hyperscan/dev-reference/getting_started.html 目录 1.下载 2.安装环境配置 2.1 硬件需求 2.2 软件需求 3.安装 3.1 创建构建目录 3.2 设置编译选项 3.3 构建hyperscan 4.安…

Hyperscan 安装

源码下载 Ragel :http://www.colm.net/files/ragel/ragel-6.9.tar.gz boost :http://downloads.sourceforge.net/project/boost/boost/1.60.0/boost_1_60_0.tar.gz hyperscan : https://download.csdn.net/download/u014608280/12745509 第…

centos 8 编译安装hyperscan

一、编译安装环境配置 官方文档: http://intel.github.io/hyperscan/dev-reference/getting_started.html 1.1硬件配置 配置参数CPUIntel Xeon Gold 5218R CPU 2.10GHzCPU核数8核 注:需要满足以下条件 1、X86架构 2、Supplemental Streaming SIMD E…

ubuntu20.04下源码安装hyperscan库安装记录

安装测试环境: vmware-ubuntu20.04,gcc 4.8.5,ragel-6.10.tar.gz,boost_1_69_0.tar.gz,hyperscan-5.1.0.tar.gz 1.安装ragel(必须的依赖包)1MB: 下载地址:http://www.…

基于CentOS 8 系统环境下的 Snort 3 安装指南

O、 阅读要求 本教程并不适合初学者,大家在阅读本文之前,需具备CentOS 8 Linux、Snort 2.9的成功安装经验。本次安装对网络依赖很大,所以大家一定要将网络状态调节好,本指南介绍的内容,仅在测试环境中使用。 一、环境…

msys2+mingw64+ragel安装

[msys2mingw64ragel安装] [简介] 这几天部门老大让解析几个东西,要求用ragel编写,在Windows环境下,要运用到mingw64,安装时发现mingw里没有pacman,需要现安装,然后发现Wget也没有。。。,所以改…