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 Stripe Dashboard

4. php 代码:

官方发起支付请求示例:https://stripe.com/docs/checkout/quickstart

/*** stripe支付*/
public function actionStripe()
{$_key = 'sk_test_51Jyo2iHnJH***********************************';// stripe 生成订单$url = 'https://www.baidu.com';\Stripe\Stripe::setApiKey($_key);$checkout_session = \Stripe\Checkout\Session::create(['line_items' => [['price' => {{PRICE_ID}}, // 产品id'quantity' => 1,]],'mode' => 'payment','success_url' => $url . '/success.html','cancel_url' => $url . '/cancel.html','automatic_tax' => ['enabled' => true,],]);$arrGoodsInfo['payment_intent'] = $checkout_session->payment_intent;// 创建本地订单操作,并payment_intent保留
//    ......//$checkout_session->url stripe跳转支付url// $checkout_session->payment_intent是识别支付与通知关系的唯一凭证return ['url' => $checkout_session->url, 'id' => $checkout_session->id, 'payment_intent' => $checkout_session->payment_intent];
}

出现tax_behavior 相关问题时需查看产品是否配置税务信息

var_dump($checkout_session);
结果:

array('id'                          => 'cs_test_a1SsLDn1NtwTzLa0JlOqH5Xr3nEUGvC2iQui0EFyedgTkpSrQhJDowfZ0E','object'                      => 'checkout.session','after_expiration'            => NULL,'allow_promotion_codes'       => NULL,'amount_subtotal'             => 400,'amount_total'                => 400,'automatic_tax'               =>array('enabled' => false,'status'  => NULL,),'billing_address_collection'  => NULL,'cancel_url'                  => 'https://www.baidu.com/cancel.html','client_reference_id'         => NULL,'consent'                     => NULL,'consent_collection'          => NULL,'currency'                    => 'hkd','customer'                    => NULL,'customer_creation'           => 'always','customer_details'            => NULL,'customer_email'              => NULL,'expires_at'                  => 1654681622,'livemode'                    => false,'locale'                      => NULL,'metadata'                    =>array(),'mode'                        => 'payment','payment_intent'              => 'pi_3L7z07IUnSe35qBJ0VC7FqLy','payment_link'                => NULL,'payment_method_options'      =>array(),'payment_method_types'        =>array(0 => 'card',),'payment_status'              => 'unpaid','phone_number_collection'     =>array('enabled' => false,),'recovered_from'              => NULL,'setup_intent'                => NULL,'shipping'                    => NULL,'shipping_address_collection' => NULL,'shipping_options'            =>array(),'shipping_rate'               => NULL,'status'                      => 'open','submit_type'                 => NULL,'subscription'                => NULL,'success_url'                 => 'https://www.baidu.com/success.html','total_details'               =>array('amount_discount' => 0,'amount_shipping' => 0,'amount_tax'      => 0,),'url'                         => 'https://checkout.stripe.com/pay/cs_test_a1SsLDn1NtwTzLa0JlOqH5Xr3nEUGvC2iQui0EFyedgTkpSrQhJDowfZ0E#fidkdWxOYHwnPyd1blpxYHZxWjA0STJfUkFMUGtWYDYwdEdPdWRrfUo9a3xNZndOYVJfTGxwdE5ATHdPfEAxaVA3Q1xNbnFMVUt2bzZQYGpvYHBmf11BPGRtZ2cyRFNHSGxBYl9jakNDSDU1NTV9aXNRPWNdXycpJ2N3amhWYHdzYHcnP3F3cGApJ2lkfGpwcVF8dWAnPyd2bGtiaWBabHFgaCcpJ2BrZGdpYFVpZGZgbWppYWB3dic%2FcXdwYHgl',
);

官方提供得测试账号:Testing | Stripe Documentation

支付成功会自动跳转到success.html

回调:

<?php
/*** 支付回调*/
namespace api\controllers;use yii\web\Controller;
use Yii;class PayNotifyController extends Controller
{/*** stripe支付回调*/public function actionStripe(){$_key = 'sk_test_51Jyo2iHnJH***********************************';\Stripe\Stripe::setApiKey($_key);$payload = @file_get_contents('php://input');$event = null;try {$event = \Stripe\Event::constructFrom(json_decode($payload, true));} catch(\UnexpectedValueException $e) {// Invalid payloadhttp_response_code(400);exit();}// Handle the eventswitch ($event->type) {case 'charge.succeeded':$succeeded = $event->data->object;$content = "=========".date('Y-m-d H:i:s',time())."==========\r\n";$content .= json_encode($succeeded);file_put_contents(dirname(__DIR__).'/runtime/logs/stripe_success.log',$content . "\r\n",FILE_APPEND);if ($succeeded->status == 'succeeded'){$payment_intent = $succeeded->payment_intent;}break;default:echo 'Received unknown event type ' . $event->type;break;}return true;}
}

我已成功接入ecshop。
转自:php实现Stripe支付_阿阿阿阿强的博客-CSDN博客_php stripe支付Stripe支付 :https://dashboard.stripe.com/dashboard1. 安装Stripe:composerrequirestripe/stripe-php2. 获取密钥:https://dashboard.stripe.com/test/apikeys3. 创建产品:https://dashboard.stripe.com/test/products4. php 代码:官方发起支付请求示例:https://stripe.com...https://blog.csdn.net/weixin_39461487/article/details/123260107

php实现Stripe支付 | ecshop stripe支付相关推荐

  1. Stripe一家神奇的支付公司

    Stripe:一家成立仅仅7年但估值已达350亿美金的金融科技支付公司! KlipC前段时间参加金融科技展时统计了2019年最成功的Fintech(金融科技)公司,发现虽然每年Fintech公司都很多 ...

  2. Stripe支付,国外支付Stripe、跨境支付

    好记星不如烂笔头,这里记录平时工作中用到的东西,不喜可以留言. 美国跨境支付stripe 测试说明,你需要办理至少一张国际信用卡, 比如visa.master.AE(American Express ...

  3. Stripe/PayPal轮询支付系统

    AB站跳转,我们以最低的价格和最好的服务为客户服务,我们提供不同种类的租售方案 1.年租[单商户1500元,多商户2300元]提供实时的技术支持 2.月租[单商户150元,多商户230元]提供实时的技 ...

  4. ecshop paypal支付_ecshop商城paypal支付插件下载

    简介: ecshop paypal支付_ecshop商城paypal支付插件,ecshop paypal支付,ecshop海外境外收款paypal支付接口,ecshop paypal ecshop商城 ...

  5. 企业号微信支付 公众号支付 H5调起支付API示例代码 JSSDK C# .NET

    企业号微信支付 公众号支付 H5调起支付API示例代码 JSSDK C# .NET 原文:企业号微信支付 公众号支付 H5调起支付API示例代码 JSSDK C# .NET 先看效果 1.本文演示的是 ...

  6. java 银联支付反馈,微信支付/支付宝支付/银联支付,对比加总结(Java服务端)

    今天来说讲支付.前端 工做到如今,接入过好几个项目的支付,其中涉及到了微信支付.支付宝支付.银联支付.服务器 三种支付的对接感觉其实总体上大同小异.都遵循同一个流程:微信 1).商户APP向商户服务器 ...

  7. 个人开发者微信支付和支付宝支付

    个人开发者是不能申请微信支付和支付宝支付的 很多第三方使用添加二维码监听转账操作来实现是否功能

  8. 第三方支付——微信app支付

    微信App支付 前言 本篇文章将结合自己实际开发经验,从一下几个方面介绍微信app支付,什么是微信app支付?支付流程是什么样的? 前期需要准备些什么?结合官方文档和实际代码带大家走流程. 正文 微信 ...

  9. 微信jsapi支付获取code_微信支付(公众号支付JSAPI)

    微信公众号支付/微信浏览器支付(JSAPI) 一:获取微信支付四大参数 步骤二:平台配置 配置支付目录:商户平台. 配置此目录是代码中"微信支付"所在页面的地址,一级域名需ICP备 ...

最新文章

  1. 微服务小范围发布影响小
  2. 第7周项目实践 1 队列算法库的建立
  3. CSS 实现三角形、梯形、等腰梯形
  4. 编写一个简单的assert宏
  5. Saber2016安装包和安装详细安装步骤
  6. POJ3751 时间日期格式转换【日期计算】
  7. Spring Cloud Eureka 入门 (二)服务提供者详解
  8. MariaDB数据库5-password、galera
  9. jQuery.Form.js 异步提交表单使用总结
  10. 把数据库中的数据制作成Excel数据
  11. html 图片 把绝对路径改为相对路径,html中想把图片绝对路径 改成相对路径怎么操作?...
  12. [软件] 装机员 Ghost Win7 Sp1 32位纯净10月版
  13. java中mergesort函数怎么用,由mergeSort引发的一些思考
  14. RecyclerView、Adapter、ViewHolder的关系
  15. 闰秒问题的全面解读与防范
  16. 你所不知的有趣投影方法
  17. Android如何计算View的深度
  18. 表单设计器—HTML元素操作
  19. GPIO的寄存器BSRR和BRR使用摘抄汇总
  20. 计算机科学视角,从计算机科学家的视角学习阅读与写作(七):科幻之美

热门文章

  1. (js)三位用逗号隔开,保留指定位小数(or 四舍五入取整)
  2. Redis实战篇--优惠券秒杀
  3. 高精四则运算及求模运算(五)
  4. ArrayBlockingQueue的put和take过程详解
  5. STL中vector、list、deque和map的区别
  6. python怎么输入空行_python输入空行
  7. webstorm ‘npm‘ 不是内部或外部命令,也不是可运行的程序 或批处理文件。
  8. 黑马程序员Python教程的代码--摆放游戏
  9. 古文入门 Introduction to Classical Chinese
  10. 消费金融罚单最全梳理:10家被罚1800万元,北银最多、海尔最特殊