Alipay interface public functions
Dec 05, 2016 pm 01:27 PMwemall-mobile is an Android app mall based on WeMall. You only need to upload the interface file in the original mall directory to complete the server-side configuration. The client can be customized and modified. This article shares the Alipay interface public functions of the wemall app mall source code Android. This class is the core processing file of the public functions called by the request and notification return files for technicians to refer to and learn.
The following code is only a sample code provided to facilitate merchant testing. Merchants can write it according to the technical documentation according to the needs of their own websites. It is not necessary to use this code. This code is only for learning and researching the Alipay interface and is only provided as a reference.
Concatenate all the elements of the array into a string using the "&" character according to the pattern of "parameter = parameter value"
<?php<br />
<br />
function createLinkstring($para) {<br />
$arg = "";<br />
While (list ($key, $val) = each ($para)) {<br />
????????? $arg.=$key."=".$val."&";<br />
}<br />
//Remove the last & character <br />
$arg = substr($arg,0,count($arg)-2);<br />
? <br />
//If there is an escape character, remove the escape <br />
If(get_magic_quotes_gpc()){$arg = stripslashes($arg);}<br />
? <br />
Return $arg;<br />
}<br />
/**<br />
* Concatenate all the elements of the array into a string using the "&" character according to the pattern of "parameter = parameter value", and perform urlencode encoding on the string<br />
* @param $para Array to be spliced<br />
* return the string after the splicing is completed<br />
?*/<br />
function createLinkstringUrlencode($para) {<br />
$arg = "";<br />
While (list ($key, $val) = each ($para)) {<br />
?????????? $arg.=$key."=".urlencode($val)."&";<br />
}<br />
//Remove the last & character <br />
$arg = substr($arg,0,count($arg)-2);<br />
? <br />
//If there is an escape character, remove the escape <br />
If(get_magic_quotes_gpc()){$arg = stripslashes($arg);}<br />
? <br />
Return $arg;<br />
}<br />
/**<br />
* Remove null values ????and signature parameters in the array<br />
* @param $para Signature parameter group<br />
* return The new signature parameter group after removing the null value and signature parameters<br />
?*/<br />
function paraFilter($para) {<br />
$para_filter = array();<br />
While (list ($key, $val) = each ($para)) {<br />
If($key == "sign" || $key == "sign_type" || $val == "")continue;<br />
Else $ Para_filter [$ key] = $ Para [$ key]; <br />
}<br />
Return $para_filter;<br />
}<br />
/**<br />
* Sort the array<br />
* @param $para Array before sorting<br />
* return sorted array<br />
?*/<br />
function argSort($para) {<br />
ksort($para);<br />
??reset($para);<br />
Return $para;<br />
}<br />
/**<br />
* Write logs to facilitate testing (depending on the website requirements, you can also change the records to be stored in the database) <br />
* Note: The server needs to enable fopen configuration<br />
* @param $word The text content to be written in the log Default value: null<br />
?*/<br />
function logResult($word='') {<br />
$fp = fopen("log.txt","a");<br />
flock($fp, LOCK_EX) ;<br />
??fwrite($fp,"Execution date:".strftime("%Y%m%d%H%M%S",time())."n".$word."n");<br />
flock($fp, LOCK_UN);<br />
??fclose($fp);<br />
}<br />
<br />
/**<br />
* Remotely obtain data, POST mode<br />
* Note: <br />
* 1. To use Crul, you need to modify the settings of the php.ini file in the server. Find php_curl.dll and remove the ";" in front of it<br />
* 2. cacert.pem in the folder is an SSL certificate. Please ensure that its path is valid. The current default path is: getcwd().'\cacert.pem'<br />
* @param $url specifies the full path address of the URL<br />
* @param $cacert_url specifies the absolute path of the current working directory<br />
* @param $para Requested data<br />
* @param $input_charset encoding format. Default value: null <br />* return remote output data<br />
*/<br />
function getHttpResponsePOST($url, $cacert_url, $para, $input_charset = '') {<br />
<br />
If (trim($input_charset) != '') {<br />
??????? $url = $url."_input_charset=".$input_charset;<br />
}<br />
$curl = curl_init($url);<br />
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);//SSL certificate authentication<br />
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);//Strict authentication<br />
curl_setopt($curl, CURLOPT_CAINFO,$cacert_url);//Certificate address<br />
curl_setopt($curl, CURLOPT_HEADER, 0); // Filter HTTP header<br />
curl_setopt($curl,CURLOPT_RETURNTRANSFER, 1); // Display the output results <br />
curl_setopt($curl,CURLOPT_POST,true); // post transfer data<br />
curl_setopt($curl,CURLOPT_POSTFIELDS,$para); // post transfer data<br />
$responseText = curl_exec($curl);<br />
//var_dump( curl_error($curl) );//If an exception occurs during curl execution, you can turn on this switch to view the exception content<br />
? curl_close($curl);<br />
? <br />
Return $responseText;<br />
}<br />
<br />
/**<br />
* Remotely obtain data, GET mode<br />
* Note: <br />
* 1. To use Crul, you need to modify the settings of the php.ini file in the server. Find php_curl.dll and remove the ";" in front of it<br />
* 2. cacert.pem in the folder is an SSL certificate. Please ensure that its path is valid. The current default path is: getcwd().'\cacert.pem'<br />
* @param $url specifies the full path address of the URL<br />
* @param $cacert_url specifies the absolute path of the current working directory<br />
* return remote output data<br />
?*/<br />
function getHttpResponseGET($url,$cacert_url) {<br />
$curl = curl_init($url);<br />
curl_setopt($curl, CURLOPT_HEADER, 0); // Filter HTTP header<br />
curl_setopt($curl,CURLOPT_RETURNTRANSFER, 1); // Display the output results <br />
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);//SSL certificate authentication<br />
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);//Strict authentication<br />
curl_setopt($curl, CURLOPT_CAINFO,$cacert_url);//Certificate address<br />
$responseText = curl_exec($curl);<br />
//var_dump( curl_error($curl) );//If an exception occurs during curl execution, you can turn on this switch to view the exception content<br />
? curl_close($curl);<br />
? <br />
Return $responseText;<br />
}<br />
<br />
/**<br />
* Implement multiple character encoding methods<br />
* @param $input The string that needs to be encoded<br />
* @param $_output_charset Output encoding format<br />
* @param $_input_charset Input encoding format<br />
* return the encoded string<br />
?*/<br />
function charsetEncode($input,$_output_charset,$_input_charset) {<br />
$output = "";<br />
If(!isset($_output_charset) )$_output_charset = $_input_charset;<br />
If($_input_charset == $_output_charset || $input ==null ) {<br />
???????? $output = $input;<br />
} elseif (function_exists("mb_convert_encoding")) {<br />
???????? $output =?mb_convert_encoding($input,$_output_charset,$_input_charset);<br />
} elseif(function_exists("iconv")) {<br />
???????? $output = iconv($_input_charset,$_output_charset,$input);<br />
????????????? else die("sorry, you have no libs support for charset change.");<br />
Return $output;<br />
}<br />
/**<br />
* Implement multiple character decoding methods<br />
* @param $input The string to be decoded<br />
* @param $_output_charset Output decoding format<br />?*?@param?$_input_charset?輸入的解碼格式<br />
?*?return?解碼后的字符串<br />
?*/<br />
function?charsetDecode($input,$_input_charset?,$_output_charset)?{<br />
????$output?=?"";<br />
????if(!isset($_input_charset)?)$_input_charset??=?$_input_charset?;<br />
????if($_input_charset?==?$_output_charset?||?$input?==null?)?{<br />
????????$output?=?$input;<br />
????}?elseif?(function_exists("mb_convert_encoding"))?{<br />
????????$output?=?mb_convert_encoding($input,$_output_charset,$_input_charset);<br />
????}?elseif(function_exists("iconv"))?{<br />
????????$output?=?iconv($_input_charset,$_output_charset,$input);<br />
????}?else?die("sorry,?you?have?no?libs?support?for?charset?changes.");<br />
????return?$output;<br />
}<br />
?>
wemall官網(wǎng)地址:http://www.wemallshop.com

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to design the mall's coupon table structure in MySQL? With the rapid development of e-commerce, coupons have become one of the important marketing methods to attract users. In a shopping mall system, it is very important to properly design the structure of the coupon table. This article will introduce how to design the coupon table structure of the mall in MySQL and provide specific code examples. Basic attributes of mall coupons First, we need to clarify the basic attributes of mall coupons. Generally speaking, a coupon includes the following attributes: Coupon ID: Each coupon should have a

How to design the product table structure of the mall in MySQL? MySQL is a commonly used relational database management system that is widely used in various types of websites and applications. When designing the product table structure of the mall, factors such as product attributes, classification, and inventory need to be taken into consideration. The following will introduce in detail how to design the product table structure of the mall in MySQL and give specific code examples. Basic information of the product table: When designing the structure of the product table, you first need to determine the basic information of the product, such as product name, price, description, and pictures.

With the rapid development of e-commerce, more and more companies choose to open online malls and sell products online. For a mall, SKU (StockKeepingUnits) is a very important concept. SKU is a specific code defined by merchants to better manage product inventory. It can uniquely identify a product and record the characteristics and attributes of the product. In order to better manage SKU inventory, merchants need to develop a dedicated SKU inventory management system. in the text

How to design the mall's shipping address table structure in MySQL? The shipping address table is a very important part of the e-commerce system. Reasonable design can improve the performance and scalability of the system. This article will introduce how to design the mall's shipping address table structure in MySQL and give specific code examples. The design of the delivery address table can consider the following aspects: Field design In the delivery address table, we can consider the following field design: ID: address primary key, used to uniquely identify an address record; User ID: between the user and the address of

How to design the refund table structure of the mall in MySQL? In a shopping mall system, refunds are an important feature because customers may need to return their payments for various reasons. A good database design is essential when handling refunds. This article will introduce how to design the refund table structure of the mall in MySQL and provide specific code examples. First, we need to create a table to store refund information. We can name it "refunds". Here is a sample code with basic fields: CR

Detailed explanation of the design of the mall collection product function developed with PHP In today's e-commerce era, users usually browse a series of products on the mall website, and the collection function is a common user experience enhancement technology. This article will introduce in detail how to use the collection product function in the PHP Developer City website and provide relevant code examples. The basic principle of implementing the collection product function is that after logging in to the mall website, users can click the collection button to add products to their personal favorites, and in their personal collections, users can manage the collected products, such as viewing and deleting

Architectural design and PHP code implementation of the mall SKU management module 1. Introduction With the rapid development of e-commerce, the scale and complexity of the mall are also increasing. The SKU (StockKeepingUnit) management module of the mall is one of the core modules of the mall and is responsible for managing the inventory, price, attributes and other information of the products. This article will introduce the architectural design and PHP code implementation of the mall SKU management module. 2. Architecture design Database design The database design of the SKU management module is the foundation of the entire architecture. SKU of the mall

How to design the mall's evaluation table structure in MySQL? In a shopping mall system, evaluation is one of the most important functions. Evaluations can not only provide reference for other users, but also help merchants understand users’ feedback and opinions on products. Designing a reasonable evaluation form structure is crucial to the operation of the mall system and user experience. This article will introduce how to design the mall's evaluation table structure in MySQL and provide specific code examples. First, we need to create two basic tables: product table and user table. product list (product
