ePRO Online payment Platform PHP interface code, easy Bao Online payment _php Tutorial

Source: Internet
Author: User
Tags hmac

ePRO Online payment Platform PHP interface code, easy Bao Online payment


This code refers to from Hanshunping 149 video After 5 speaking, need to learn a friend can refer to this code

Here is the test picture:

Here is the Code section:

1 Php 2 3 4 functionHMACMD5 ( $data, $key ) 5 { 6 7 // need to configure the environment support ICONV, otherwise Chinese parameters can not be handled properly 8 $key= Iconv("GB2312", "UTF-8", $key ); 9 $data= Iconv("GB2312", "UTF-8", $data ); Ten $b= 64 ; One if( strlen( $key) > $b ) { A $key= Pack("h*", MD5( $key )); - } - $key= Str_pad( $key, $b, CHR(0x00 )); the $ipad= Str_pad('', $b, CHR(0x36 )); - $opad= Str_pad('', $b, CHR(0x5c )); - $k _ipad= $key^ $ipad ; - $k _opad= $key^ $opad ; + return MD5( $k _opad. Pack("h*", MD5( $k _ipad. $data ))); - } + // How can we make a signature string for the PayPal payment request? A //Each request parameter is passed as $data: $key is the key that easy treasure assigns to merchant at -?> common.php 1 2 3 4 5 - pay.php 1 2 3 4 5 Php 6 include' Common.php ' ; 7 // Here we get user-submitted information 8 9 //1. Get Order number Ten $p 0_cmd= "Buy" ; One $p 1_merid= "10001126856" ; A $p 2_order= $_request[' P2_order ' ]; - $p 3_amt= $_request[' P3_amt ' ]; - $p 4_cur= "CNY" ; the // Product Name - $p 5_pid= "" ; - $p 6_pcat= ""; // Product Type - $p 7_pdesc= ""; // Product Introduction + //Just epro after the successful payment, return the information to the URL - $p 8_url= "http://loaclhost/FUCKPHP/onlinezhifu/res.php" ; + $p 9_saf= "0"; // Shipping Address A $pa _MP= ""; // Additional Information at $pd _frpid= $_request[' Pd_frpid ']; // Payment Channel - $PR _needresponse= "1"; // Response mechanism - //We put the request parameters one by one stitching (stitching time, order is very important!) - $data="" ; - $data= $data. $p 0_cmd ; - $data= $data. $p 1_merid ; in $data= $data. $p 2_order ; - $data= $data. $p 3_amt ; to $data= $data. $p 4_cur ; + $data= $data. $p 5_pid ; - $data= $data. $p 6_pcat ; the $data= $data. $p 7_pdesc ; * $data= $data. $p 8_url ; $ $data= $data. $p 9_saf ; Panax Notoginseng $data= $data. $pa _MP ; - $data= $data. $pd _frpid ; the $data= $data. $PR _needresponse ; + A $merchantKey= "69CL522AV6Q613II4W6U8K6XUW8VM1N6BFGYV769220IUYE9U37N4Y7RI4PL" ; the // HMAC is a signature string, a keyword used for epro and merchant mutual confirmation. + //Here we need to use algorithm to generate (Md5-hmac algorithm) - $hmac= HmacMd5 ( $data, $merchantKey ); $?> $Your order number is: Echo $p 2_order; The amount paid by?> is Echo $p 3_amt;?> - - $ payconfirm.php 1 Php 2 include' Common.php ' ; 3 // get the information returned from the ePRO payment gateway 4 $p 1_merid= "10001126856" ; 5 $r 0_cmd= $_request[' R0_cmd ' ]; 6 $r 1_code= $_request[' R1_code ' ]; 7 $r 2_trxid= $_request[' R2_trxid ' ]; 8 $r 3_amt= $_request[' R3_amt ' ]; 9 $r 4_cur= $_request[' R4_cur ' ]; Ten $r 5_pid= $_request[' R5_pid ' ]; One $r 6_order= $_request[' R6_order ' ]; A $r 7_uid= $_request[' R7_uid ' ]; - $r 8_MP= $_request[' R8_mp ' ]; - $r 9_btype= $_request[' R9_btype ' ]; the $hmac= $_request[' HMAC ' ]; - - // Stitching - $res _src= "" ; + $res _src= $res _src. $p 1_merid ; - $res _src= $res _src. $r 0_cmd ; + $res _src= $res _src. $r 1_code ; A $res _src= $res _src. $r 2_trxid ; at $res _src= $res _src. $r 3_amt ; - $res _src= $res _src. $r 4_cur ; - $res _src= $res _src. $r 5_pid ; - $res _src= $res _src. $r 6_order ; - $res _src= $res _src. $r 7_uid ; - $res _src= $res _src. $r 8_MP ; in $res _src= $res _src. $r 9_btype ; - $merchantKey= "69C1522AV6Q613II4W6U8K6XUW8VM1N6BFGYV769220IUYE9U37N4Y7RI4P1" ; to // Md5-hmac Cryptographic processing of returned results, and comparison of returned HMAC signature strings + if(HmacMd5 ( $res _src, $merchantKey) == $hmac ) { - if( $r 1_code= = 1 ) { the if( $r 9_btype= = 1 ) { * Echo' Trading Success! ' ; $ Echo' Order number is '. $r 6_order. ' Payment is successful! ' . ' The amount paid is '. $r 3_amt. ' ePRO payment order number '. $r 2_trxid ; Panax Notoginseng Echo'
Browser redirection ' ; -} ElseIf( $r 9_btype= = 2 ) { the Echo' Success ' ; + Echo'
Trading Success! ' ; A Echo'
Server Point-to-point communication ' ; the } + } -} Else { $ Echo' The signature has been tampered with ' ; $ } - -?> res.php

http://www.bkjia.com/PHPjc/1010337.html www.bkjia.com true http://www.bkjia.com/PHPjc/1010337.html techarticle Easy Bao Online payment platform PHP interface code, easy Bao Online payment This code reference since Hanshunping 149 video after 5 speak, need to learn a friend can refer to this code this is the test picture: The following ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.