Ejemplo n.º 1
0
<?php

include_once __DIR__ . '/bootstrap.php';
use HuNanZai\Component\Pay\Package\Alipay_wap\Handler\PhpFileConfigHandler as ConfigHandler;
use HuNanZai\Component\Pay\Package\Alipay_wap\Handler\ArraySearchRequestParamHandler as ParamHandler;
use HuNanZai\Component\Pay\Package\Alipay_wap\Api;
$config_handler = new ConfigHandler(__DIR__ . '/config.php');
$config = $config_handler->getConfig();
$param_handler = new ParamHandler(array('trade_no' => '', 'out_trade_no' => ''));
$param = $param_handler->getParam();
$alipay_api = new Api($config);
try {
    $result = $alipay_api->search($param);
} catch (\Exception $e) {
    var_dump($e);
}
$doc = new DOMDocument();
$doc->loadXML($result);
//请在这里加上商户的业务逻辑程序代码
//——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
//获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表
//解析XML
if (!empty($doc->getElementsByTagName("alipay")->item(0)->nodeValue)) {
    $alipay = $doc->getElementsByTagName("alipay")->item(0)->nodeValue;
    echo $alipay;
}
Ejemplo n.º 2
0
<?php

include_once __DIR__ . '/bootstrap.php';
use HuNanZai\Component\Pay\Package\Alipay_wap\Api;
use HuNanZai\Component\Pay\Package\Alipay_wap\Handler\PhpFileConfigHandler as ConfigHandler;
use HuNanZai\Component\Pay\Package\Alipay_wap\Handler\ArrayCallbackParamHandler as CallbackParamHander;
use HuNanZai\Component\Log\Service as Logger;
$config_handler = new ConfigHandler(__DIR__ . '/config.php');
$config = $config_handler->getConfig();
$callback_param_handler = new CallbackParamHander($_GET);
$callback_param = $callback_param_handler->getParam();
$alipay_api = new Api($config);
$res = $alipay_api->verifyCallback($callback_param);
Logger::addInfo('alipay_wap_demo', 'callback', array('get' => $_GET, 'res' => $res));
if ($res) {
    header("Location: https://www.baidu.com");
    die;
} else {
    header("Location: http://www.ci123.com");
    die;
}
Ejemplo n.º 3
0
<?php

include_once __DIR__ . '/bootstrap.php';
use HuNanZai\Component\Pay\Package\Alipay_wap\Api;
use HuNanZai\Component\Pay\Package\Alipay_wap\Handler\PhpFileConfigHandler as ConfigHandler;
use HuNanZai\Component\Pay\Package\Alipay_wap\Handler\ArrayNotifyParamHandler as NotifyParamHandler;
use HuNanZai\Component\Log\Service as Logger;
$config_handler = new ConfigHandler(__DIR__ . '/config.php');
$config = $config_handler->getConfig();
$notify_param_handler = new NotifyParamHandler($_POST);
$notify_param = $notify_param_handler->getParam();
$alipay_api = new Api($config);
$res = $alipay_api->verifyNotify($notify_param);
Logger::addInfo('alipay_wap_demo', 'notify', array('post' => $_POST, 'res' => $res));
if ($res) {
    echo "success";
} else {
    echo "fail";
}
Ejemplo n.º 4
0
<?php

include_once __DIR__ . '/bootstrap.php';
use HuNanZai\Component\Pay\Package\Alipay_wap\Api as AlipayApi;
use HuNanZai\Component\Pay\Package\Alipay_wap\Handler\PhpFileConfigHandler as ConfigHandler;
use HuNanZai\Component\Pay\Package\Alipay_wap\Handler\ArrayPayParamHandler as PayParamHandler;
$config_handler = new ConfigHandler(__DIR__ . '/config.php');
$config = $config_handler->getConfig();
$pay_param_handler = new PayParamHandler(array('out_trade_no' => date('YmdHis'), 'subject' => '测试订单', 'total_fee' => '0.01', 'notify_url' => URL_ROOT . 'notify.php', 'return_url' => URL_ROOT . 'callback.php'));
$alipay_api = new AlipayApi($config);
try {
    $result = $alipay_api->pay($pay_param_handler->getParam());
} catch (Exception $e) {
    var_dump($e);
}
var_dump($result);
Ejemplo n.º 5
0
<?php

include_once __DIR__ . '/bootstrap.php';
use HuNanZai\Component\Pay\Package\Alipay_wap\Api as AlipayApi;
use HuNanZai\Component\Pay\Package\Alipay_wap\Handler\PhpFileConfigHandler as ConfigHandler;
use HuNanZai\Component\Pay\Package\Alipay_wap\Handler\ArrayRefundParamHandler as ParamHandler;
$config_handler = new ConfigHandler(__DIR__ . '/config.php');
$config = $config_handler->getConfig();
$param_handler = new ParamHandler(array('refund_date' => date('Y-m-d H:i:s'), 'batch_no' => date('YmdHis'), 'batch_num' => 1, 'detail_data' => 'xxxx^0.01^测试退款'));
$alipay_api = new AlipayApi($config);
try {
    $result = $alipay_api->refund($param_handler->getParam());
    echo $result;
} catch (Exception $e) {
    var_dump($e);
}