youhua
This commit is contained in:
@@ -1,13 +1,20 @@
|
||||
<?php
|
||||
/*
|
||||
* @Author: 万永康
|
||||
* @Date: 2020-10-11 12:32:50
|
||||
* @LastEditTime: 2020-10-12 10:29:34
|
||||
* @LastEditors: Please set LastEditors
|
||||
* @Description: In User Settings Edit
|
||||
* @FilePath: /phptest/alipay/Alipay.php
|
||||
*/
|
||||
|
||||
namespace alipay;
|
||||
|
||||
require_once APP_PATH.'aop/AopClient.php';
|
||||
require_once APP_PATH.'aop/AopCertification.php';
|
||||
require_once APP_PATH.'aop/request/AlipayTradeQueryRequest.php';
|
||||
require_once APP_PATH.'aop/request/AlipayTradePagePayRequest.php';
|
||||
require_once APP_PATH.'aop/request/AlipayTradeAppPayRequest.php';
|
||||
|
||||
require_once APP_PATH . 'aop/AopClient.php';
|
||||
require_once APP_PATH . 'aop/AopCertification.php';
|
||||
require_once APP_PATH . 'aop/request/AlipayTradeQueryRequest.php';
|
||||
require_once APP_PATH . 'aop/request/AlipayTradePagePayRequest.php';
|
||||
require_once APP_PATH . 'aop/request/AlipayFundTransUniTransferRequest.php';
|
||||
|
||||
/**
|
||||
* 证书类型AopClient功能方法使用测试
|
||||
@@ -16,18 +23,19 @@ require_once APP_PATH.'aop/request/AlipayTradeAppPayRequest.php';
|
||||
* 3、pageExecute 调用示例
|
||||
*/
|
||||
|
||||
class Alipay {
|
||||
class Alipay
|
||||
{
|
||||
|
||||
//配置内容
|
||||
protected static $config = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
self::$config = require APP_PATH.'config/config.php';
|
||||
self::$config = require APP_PATH . 'config/config.php';
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* web 付款
|
||||
* $param = [
|
||||
* 'body' => '123',
|
||||
@@ -37,12 +45,12 @@ require_once APP_PATH.'aop/request/AlipayTradeAppPayRequest.php';
|
||||
* 'product_code' => "FAST_INSTANT_TRADE_PAY",//QUICK_WAP_PAY
|
||||
* 'timeout_express'=>"15m"
|
||||
*];
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static function pay($param){
|
||||
//1、execute 使用
|
||||
$aop = new \AopClient ();
|
||||
public static function pay($param)
|
||||
{
|
||||
$aop = new \AopClient();
|
||||
|
||||
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
|
||||
$aop->appId = self::$config['alipay']['app_id'];
|
||||
@@ -53,13 +61,57 @@ require_once APP_PATH.'aop/request/AlipayTradeAppPayRequest.php';
|
||||
$aop->postCharset = 'utf-8';
|
||||
$aop->format = 'json';
|
||||
|
||||
$request = new \AlipayTradePagePayRequest ();
|
||||
$request = new \AlipayTradePagePayRequest();
|
||||
|
||||
$param = json_encode($param);
|
||||
|
||||
|
||||
$request->setBizContent($param);
|
||||
$result = $aop->pageExecute($request);
|
||||
echo $result;
|
||||
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @description: 转帐到支付宝账户
|
||||
* @param {type}$param
|
||||
* [
|
||||
* 'out_biz_no'=>'201806300001',
|
||||
* 'trans_amount' => '0.01',
|
||||
* 'product_code' => 'TRANS_ACCOUNT_NO_PWD',
|
||||
* 'payee_info' => {
|
||||
* 'identity' => '208812*****41234',
|
||||
* 'identity_type' => 'ALIPAY_LOGON_ID',
|
||||
* 'name' => 'peter'
|
||||
* },
|
||||
* 'remark' => '提现-单笔转帐'
|
||||
* ]
|
||||
* @return {type}
|
||||
*/
|
||||
public static function transfer()
|
||||
{
|
||||
$aop = new \AopClient();
|
||||
|
||||
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
|
||||
$aop->appId = self::$config['alipay']['app_id'];
|
||||
$aop->rsaPrivateKey = self::$config['alipay']['private_key'];
|
||||
$aop->alipayrsaPublicKey = self::$config['alipay']['public_key'];
|
||||
$aop->apiVersion = '1.0';
|
||||
$aop->signType = 'RSA2';
|
||||
$aop->postCharset = 'utf-8';
|
||||
$aop->format = 'json';
|
||||
|
||||
$request = new \AlipayFundTransUniTransferRequest();
|
||||
|
||||
$param = json_encode($param);
|
||||
|
||||
$request->setBizContent($param);
|
||||
$result = $aop->execute ( $request);
|
||||
|
||||
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
|
||||
$resultCode = $result->$responseNode->code;
|
||||
if(!empty($resultCode)&&$resultCode == 10000){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user