易宝网上支付平台的PHP接口代码
本代码参照自韩顺平149讲视频后5讲,需要学习的朋友可以参考本代码
这是测试图片:
以下是代码部分:


<span> 1</span> <span>php </span><span> 2</span><span> 3</span><span> 4</span><span>function</span> HmacMd5(<span>$data</span>, <span>$key</span><span>) </span><span> 5</span><span>{ </span><span> 6</span><span> 7</span><span>//</span><span>需要配置环境支撑iconv,否则中文参数不能正常处理</span><span> 8</span><span>$key</span> = <span>iconv</span>("GB2312", "UTF-8", <span>$key</span><span>); </span><span> 9</span><span>$data</span> = <span>iconv</span>("GB2312", "UTF-8", <span>$data</span><span>); </span><span>10</span><span>$b</span> = 64<span>; </span><span>11</span><span>if</span> (<span>strlen</span>(<span>$key</span>) > <span>$b</span><span>) { </span><span>12</span><span>$key</span> = <span>pack</span>("H*", <span>md5</span>(<span>$key</span><span>)); </span><span>13</span><span> } </span><span>14</span><span>$key</span> = <span>str_pad</span>(<span>$key</span>, <span>$b</span>, <span>chr</span>(0x00<span>)); </span><span>15</span><span>$ipad</span> = <span>str_pad</span>('', <span>$b</span>, <span>chr</span>(0x36<span>)); </span><span>16</span><span>$opad</span> = <span>str_pad</span>('', <span>$b</span>, <span>chr</span>(0x5c<span>)); </span><span>17</span><span>$k_ipad</span> = <span>$key</span> ^ <span>$ipad</span><span>; </span><span>18</span><span>$k_opad</span> = <span>$key</span> ^ <span>$opad</span><span>; </span><span>19</span><span>return</span><span>md5</span>(<span>$k_opad</span> . <span>pack</span>("H*", <span>md5</span>(<span>$k_ipad</span> . <span>$data</span><span>))); </span><span>20</span><span>} </span><span>21</span><span>//</span><span>我们把易宝支付要求怎样生成一个签名串 </span><span>22</span><span> //把各个请求参数凭借作为$data传入: $key 就是易宝给商家分配的密钥</span><span>23</span><span>24</span> ?>


<span> 1</span> <span> 2</span> <span> 3</span> <meta http-equiv="content-type" c> <span> 4</span> <span> 5</span>


<span> 1</span> <span> 2</span> <span> 3</span> <meta http-equiv="content-type" c> <span> 4</span> <span> 5</span> php 6include 'common.php'; 7// 这里我们获取用户提交的信息 8 9 // 1.获取订单号10$p0_Cmd = "Buy"; 11$p1_MerId = "10001126856"; 12$p2_Order = $_REQUEST['p2_Order']; 13$p3_Amt = $_REQUEST['p3_Amt']; 14$p4_Cur = "CNY"; 15// 商品名称16$p5_Pid = ""; 17$p6_Pcat = ""; // 商品种类18$p7_Pdesc = ""; // 商品介绍 19 // 只是易宝支付成功后,给url返回信息20$p8_Url = "http://loaclhost/FUCKPHP/onlinezhifu/res.php"; 21$p9_SAF = "0"; // 送货地址22$pa_MP = ""; // 额外介绍23$pd_FrpId = $_REQUEST['pd_FrpId']; // 支付通道24$pr_NeedResponse = "1"; // 应答机制 25 // 我们把请求参数一个一个拼接(拼接的时候,顺序很重要!!)26$data=""; 27$data=$data.$p0_Cmd; 28$data=$data.$p1_MerId; 29$data=$data.$p2_Order; 30$data=$data.$p3_Amt; 31$data=$data.$p4_Cur; 32$data=$data.$p5_Pid; 33$data=$data.$p6_Pcat; 34$data=$data.$p7_Pdesc; 35$data=$data.$p8_Url; 36$data=$data.$p9_SAF; 37$data=$data.$pa_MP; 38$data=$data.$pd_FrpId; 39$data=$data.$pr_NeedResponse; 4041$merchantKey ="69cl522AV6q613Ii4W6u8K6XuW8vM1N6bFgyv769220IuYe9u37N4y7rI4Pl"; 42// hmac是签名串,是用于易宝和商家互相确认的关键字 43 // 这里我们需要使用算法来生成(md5-hmac算法)44$hmac = HmacMd5($data,$merchantKey); 45 ?> 46 你的订单号是:echo$p2_Order; ?>支付的金额是echo$p3_Amt; ?> 47 48


<span> 1</span> <span>php </span><span> 2</span><span>include</span> 'common.php'<span>; </span><span> 3</span><span>//</span><span>获取从易宝支付网关返回的信息</span><span> 4</span><span>$p1_MerId</span> = "10001126856"<span>; </span><span> 5</span><span>$r0_Cmd</span> = <span>$_REQUEST</span>['r0_Cmd'<span>]; </span><span> 6</span><span>$r1_Code</span> = <span>$_REQUEST</span>['r1_Code'<span>]; </span><span> 7</span><span>$r2_TrxId</span> = <span>$_REQUEST</span>['r2_TrxId'<span>]; </span><span> 8</span><span>$r3_Amt</span> = <span>$_REQUEST</span>['r3_Amt'<span>]; </span><span> 9</span><span>$r4_Cur</span> = <span>$_REQUEST</span>['r4_Cur'<span>]; </span><span>10</span><span>$r5_Pid</span> = <span>$_REQUEST</span>['r5_Pid'<span>]; </span><span>11</span><span>$r6_Order</span> = <span>$_REQUEST</span>['r6_Order'<span>]; </span><span>12</span><span>$r7_Uid</span> = <span>$_REQUEST</span>['r7_Uid'<span>]; </span><span>13</span><span>$r8_MP</span> = <span>$_REQUEST</span>['r8_MP'<span>]; </span><span>14</span><span>$r9_BType</span> = <span>$_REQUEST</span>['r9_BType'<span>]; </span><span>15</span><span>$hmac</span> = <span>$_REQUEST</span>['hmac'<span>]; </span><span>16</span><span>17</span><span>//</span><span> 拼接</span><span>18</span><span>$res_src</span> = ""<span>; </span><span>19</span><span>$res_src</span> = <span>$res_src</span> . <span>$p1_MerId</span><span>; </span><span>20</span><span>$res_src</span> = <span>$res_src</span> . <span>$r0_Cmd</span><span>; </span><span>21</span><span>$res_src</span> = <span>$res_src</span> . <span>$r1_Code</span><span>; </span><span>22</span><span>$res_src</span> = <span>$res_src</span> . <span>$r2_TrxId</span><span>; </span><span>23</span><span>$res_src</span> = <span>$res_src</span> . <span>$r3_Amt</span><span>; </span><span>24</span><span>$res_src</span> = <span>$res_src</span> . <span>$r4_Cur</span><span>; </span><span>25</span><span>$res_src</span> = <span>$res_src</span> . <span>$r5_Pid</span><span>; </span><span>26</span><span>$res_src</span> = <span>$res_src</span> . <span>$r6_Order</span><span>; </span><span>27</span><span>$res_src</span> = <span>$res_src</span> . <span>$r7_Uid</span><span>; </span><span>28</span><span>$res_src</span> = <span>$res_src</span> . <span>$r8_MP</span><span>; </span><span>29</span><span>$res_src</span> = <span>$res_src</span> . <span>$r9_BType</span><span>; </span><span>30</span><span>$merchantKey</span> = "69c1522AV6q613Ii4W6u8K6XuW8vM1N6bFgyv769220IuYe9u37N4y7rI4P1"<span>; </span><span>31</span><span>//</span><span> 对返回的结果进行MD5-hmac加密处理,和返回的hmac签名串比较</span><span>32</span><span>if</span> (HmacMd5(<span>$res_src</span>, <span>$merchantKey</span>) == <span>$hmac</span><span>) { </span><span>33</span><span>if</span> (<span>$r1_Code</span> == 1<span>) { </span><span>34</span><span>if</span> (<span>$r9_BType</span> == 1<span>) { </span><span>35</span><span>echo</span> '交易成功!'<span>; </span><span>36</span><span>echo</span> '订单号为' . <span>$r6_Order</span> . '支付成功!' . '所付金额是' . <span>$r3_Amt</span> . '易宝支付订单号' . <span>$r2_TrxId</span><span>; </span><span>37</span><span>echo</span> '<br>浏览器重定向'<span>; </span><span>38</span> } <span>elseif</span> (<span>$r9_BType</span> == 2<span>) { </span><span>39</span><span>echo</span> 'success'<span>; </span><span>40</span><span>echo</span> '<br>交易成功!'<span>; </span><span>41</span><span>echo</span> '<br>服务器点对点通讯'<span>; </span><span>42</span><span> } </span><span>43</span><span> } </span><span>44</span> } <span>else</span><span> { </span><span>45</span><span>echo</span> '签名被篡改了'<span>; </span><span>46</span><span> } </span><span>47</span><span>48</span> ?>
以上就介绍了易宝网上支付平台的PHP接口代码,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

许多用户在选择智能手表的时候都会选择的华为的品牌,其中华为GT3pro和GT4都是非常热门的选择,不少用户都很好奇华为GT3pro和GT4有什么区别,下面就就给大家介绍一下二者。华为GT3pro和GT4有什么区别一、外观GT4:46mm和41mm,材质是玻璃表镜+不锈钢机身+高分纤维后壳。GT3pro:46.6mm和42.9mm,材质是蓝宝石玻璃表镜+钛金属机身/陶瓷机身+陶瓷后壳二、健康GT4:采用最新的华为Truseen5.5+算法,结果会更加的精准。GT3pro:多了ECG心电图和血管及安

为什么截图工具在Windows11上不起作用了解问题的根本原因有助于找到正确的解决方案。以下是截图工具可能无法正常工作的主要原因:对焦助手已打开:这可以防止截图工具打开。应用程序损坏:如果截图工具在启动时崩溃,则可能已损坏。过时的图形驱动程序:不兼容的驱动程序可能会干扰截图工具。来自其他应用程序的干扰:其他正在运行的应用程序可能与截图工具冲突。证书已过期:升级过程中的错误可能会导致此issu简单的解决方案这些适合大多数用户,不需要任何特殊的技术知识。1.更新窗口和Microsoft应用商店应用程

Go中Type关键字的用法有定义新的类型别名或者创建新的结构体类型。详细介绍:1、类型别名,使用“type”关键字可以为已有的类型创建别名,这种别名不会创建新的类型,只是为已有的类型提供一个新的名称,类型别名可以提高代码的可读性,使代码更加清晰;2、结构体类型,使用“type”关键字可以创建新的结构体类型,结构体是一种复合类型,可以用于定义包含多个字段的自定义类型等等。

ubuntu挂载移动硬盘出现错误:mount:unknownfilesystemtype'exfat'处理方法如下:Ubuntu13.10或安装exfat-fuse:sudoapt-getinstallexfat-fuseUbuntu13.04或以下sudoapt-add-repositoryppa:relan/exfatsudoapt-getupdatesudoapt-getinstallfuse-exfatCentOSLinux挂载exfat格式u盘错误的解决方法CentOS中加载extfa

laravel input隐藏域的实现方法:1、找到并打开Blade模板文件;2、在Blade模板中使用method_field方法来创建隐藏域,其创建语法是“{{ method_field('DELETE') }}”。

准备工作用vuecreateexample创建项目,参数大概如下:用原生input原生的input,主要是value和change,数据在change的时候需要同步。App.tsx如下:import{ref}from'vue';exportdefault{setup(){//username就是数据constusername=ref('张三');//输入框变化的时候,同步数据constonInput=;return()=>({

第1部分:初始故障排除步骤检查苹果的系统状态:在深入研究复杂的解决方案之前,让我们从基础知识开始。问题可能不在于您的设备;苹果的服务器可能会关闭。访问Apple的系统状态页面,查看AppStore是否正常工作。如果有问题,您所能做的就是等待Apple修复它。检查您的互联网连接:确保您拥有稳定的互联网连接,因为“无法连接到AppStore”问题有时可归因于连接不良。尝试在Wi-Fi和移动数据之间切换或重置网络设置(“常规”>“重置”>“重置网络设置”>设置)。更新您的iOS版本:

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code
