Authored by 郝肖肖

通过支付方式获取支付类方法封装

... ... @@ -338,6 +338,7 @@ class PayModel
$result = array(
'id' => $payId,
'pay_code' => $paymentParams['data']['payCode'],
'payName' => $paymentParams['data']['payName'],
'pay_params' => isset($paymentParams['data']['payParams']) ? $paymentParams['data']['payParams'] : ''
);
}
... ...
... ... @@ -403,6 +403,7 @@ class PaymentModel
$result = array(
'id' => $payId,
'pay_code' => $paymentParams['data']['payCode'],
'payName' => $paymentParams['data']['payName'],
'pay_params' => isset($paymentParams['data']['payParams']) ? $paymentParams['data']['payParams'] : ''
);
}
... ...
... ... @@ -23,10 +23,7 @@ class NoticeController extends WebAction
*/
public function alipaynoticeAction()
{
$payment = PayModel::getPaymentById(2);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_POST); //支付宝通知使用的
$res = $this->getParseResponse($_POST, 2);
if ($res->payResult != -1) {
$this->payResultProc($res, 2);
echo "success";
... ... @@ -39,9 +36,7 @@ class NoticeController extends WebAction
*/
public function alipayreturnAction()
{
$payment = PayModel::getPaymentById(2);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_GET);
$res = $this->getParseResponse($_GET, 2);
$dealResult = $this->payResultProc($res, 2);
$dealResult['payData'] = array('payWay' => '支付宝');
$this->commonShowResult($dealResult);
... ... @@ -52,9 +47,7 @@ class NoticeController extends WebAction
*/
public function alibarcodenoticeAction()
{
$payment = PayModel::getPaymentById(17);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_POST); //支付宝通知使用的
$res = $this->getParseResponse($_POST, 17);
if ($res->payResult != -1) {
$this->payResultProc($res, 17);
echo "success";
... ... @@ -67,9 +60,7 @@ class NoticeController extends WebAction
*/
public function alibarcodereturnAction()
{
$payment = PayModel::getPaymentById(17);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_GET);
$res = $this->getParseResponse($_GET, 17);
$dealResult = $this->payResultProc($res, 17);
$dealResult['payData'] = array('payWay' => '支付宝');
$this->commonShowResult($dealResult);
... ... @@ -80,9 +71,7 @@ class NoticeController extends WebAction
*/
public function allinpaynoticeAction()
{
$payment = PayModel::getPaymentById(16);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_POST);
$res = $this->getParseResponse($_POST, 16);
if ($res->payResult != -1) {
$this->payResultProc($res, 16);
echo "success";
... ... @@ -95,9 +84,7 @@ class NoticeController extends WebAction
*/
public function allinpayreturnAction()
{
$payment = PayModel::getPaymentById(16);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_POST);
$res = $this->getParseResponse($_POST, 16);
$dealResult = $this->payResultProc($res, 16);
$dealResult['payData'] = array('payWay' => '通联支付');
$this->commonShowResult($dealResult);
... ... @@ -108,9 +95,7 @@ class NoticeController extends WebAction
*/
public function aliexpressgatewayreturnAction()
{
$payment = PayModel::getPaymentById(13);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_GET);
$res = $this->getParseResponse($_GET, 13);
$dealResult = $this->payResultProc($res, 13);
$dealResult['payData'] = array('payWay' => '支付宝');
$this->commonShowResult($dealResult);
... ... @@ -121,9 +106,7 @@ class NoticeController extends WebAction
*/
public function aliexpressgatewaynoticeAction()
{
$payment = PayModel::getPaymentById(13);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_POST); //支付宝通知使用的
$res = $this->getParseResponse($_POST, 13);
if ($res->payResult != -1) {
$this->payResultProc($res, 13);
echo "success";
... ... @@ -136,10 +119,7 @@ class NoticeController extends WebAction
*/
public function alibanknoticeAction()
{
$payment = PayModel::getPaymentById(12);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_POST);
$res = $this->getParseResponse($_POST, 12);
if ($res->payResult != -1) {
$this->payResultProc($res, 12);
echo "success";
... ... @@ -153,9 +133,7 @@ class NoticeController extends WebAction
*/
public function alibankreturnAction()
{
$payment = PayModel::getPaymentById(12);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_GET);
$res = $this->getParseResponse($_GET, 12);
$dealResult = $this->payResultProc($res, 12);
$dealResult['payData'] = array('payWay' => '银行卡');
$this->commonShowResult($dealResult);
... ... @@ -166,9 +144,7 @@ class NoticeController extends WebAction
*/
public function chinabankAction()
{
$payment = PayModel::getPaymentById(4);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_POST);
$res = $this->getParseResponse($_POST, 4);
$dealResult = $this->payResultProc($res, 4);
$dealResult['payData'] = array('payWay' => '网银在线');
$this->commonShowResult($dealResult);
... ... @@ -179,9 +155,7 @@ class NoticeController extends WebAction
*/
public function chinabankautorevAction()
{
$payment = PayModel::getPaymentById(4);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_POST);
$res = $this->getParseResponse($_POST, 4);
if ($res->payResult != -1) {
$this->payResultProc($res, 4);
echo "ok";
... ... @@ -196,11 +170,8 @@ class NoticeController extends WebAction
*/
public function tenpayAction()
{
$payment = PayModel::getPaymentById(1);
$payService = PayFactory::factory($payment);
$rspParams = $payService->parseResponse($_GET); //财付通是以get方式回复的。
$dealResult = $this->payResultProc($rspParams, 1);
$res = $this->getParseResponse($_GET, 1);
$dealResult = $this->payResultProc($res, 1);
$dealResult['payData'] = array('payWay' => '财付通');
$this->commonShowResult($dealResult);
}
... ... @@ -211,9 +182,7 @@ class NoticeController extends WebAction
*/
public function shengpayreturnAction()
{
$payment = PayModel::getPaymentById(11);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_POST);
$res = $this->getParseResponse($_POST, 11);
$dealResult = $this->payResultProc($res, 11);
$dealResult['payData'] = array('payWay' => '盛付通');
$this->commonShowResult($dealResult);
... ... @@ -224,9 +193,7 @@ class NoticeController extends WebAction
*/
public function shengpaynoticeAction()
{
$payment = PayModel::getPaymentById(11);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_POST);
$res = $this->getParseResponse($_POST, 11);
if ($res->payResult != -1) {
$this->payResultProc($res, 11);
echo "OK";
... ... @@ -293,9 +260,7 @@ class NoticeController extends WebAction
*/
public function unionpaywebreturnAction()
{
$payment = PayModel::getPaymentById(25);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_REQUEST);
$res = $this->getParseResponse($_REQUEST, 25);
$dealResult = $this->payResultProc($res, 25);
$dealResult['payData'] = array('payWay' => '银联在线支付');
$this->commonShowResult($dealResult);
... ... @@ -306,9 +271,7 @@ class NoticeController extends WebAction
*/
public function unionpaywebnoticeAction()
{
$payment = PayModel::getPaymentById(25);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_REQUEST);
$res = $this->getParseResponse($_REQUEST, 25);
if ($res->payResult != -1) {
$this->payResultProc($res, 25);
echo "OK";
... ... @@ -322,9 +285,7 @@ class NoticeController extends WebAction
*/
public function alimobilenoticeminiAction()
{
$payment = PayModel::getPaymentById(20);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_POST); //支付宝通知使用的
$res = $this->getParseResponse($_POST, 20);
if ($res->payResult != -1) {
$this->payResultProc($res, 20);
echo "OK";
... ... @@ -334,7 +295,28 @@ class NoticeController extends WebAction
exit();
}
/**
* 获取支付方式类对象
* @param type array $Parameters 回调参数
* @param type int $payment 支付方式
* @return type object
*/
private function getParseResponse($Parameters, $payment)
{
$payment = PayModel::getPaymentById($payment);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($Parameters);
if (empty($res->bankName)) {
$res->bankName = empty($payment['payName']) ? '' : $payment['payName'];
}
if (empty($res->bankCode)) {
$res->bankCode = empty($payment['pay_code']) ? '' : $payment['pay_code'];
}
return $res;
}
/**
* 通用显示结果的方法
... ...
... ... @@ -16,9 +16,7 @@ class PayreturnController extends WebAction
*/
public function alipayreturnAction()
{
$payment = PaymentModel::getPaymentById(2);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_GET);
$res = $this->getParseResponse($_GET, 2);
$dealResult = $this->payResultProc($res, 2);
$dealResult['payData'] = array('payWay' => '支付宝');
$this->commonShowResult($dealResult);
... ... @@ -67,9 +65,7 @@ class PayreturnController extends WebAction
*/
public function unionpaywebreturnAction()
{
$payment = PaymentModel::getPaymentById(25);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_REQUEST);
$res = $this->getParseResponse($_REQUEST, 25);
$dealResult = $this->payResultProc($res, 25);
$dealResult['payData'] = array('payWay' => '银联在线支付');
$this->commonShowResult($dealResult);
... ... @@ -79,15 +75,34 @@ class PayreturnController extends WebAction
*/
public function alibankreturnAction()
{
$payment = PaymentModel::getPaymentById(12);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_GET);
$res = $this->getParseResponse($_GET, 12);
$dealResult = $this->payResultProc($res, 12);
$dealResult['payData'] = array('payWay' => '支联支付');
$this->commonShowResult($dealResult);
}
/**
* 获取支付方式类对象
* @param type array $Parameters 回调参数
* @param type int $payment 支付方式
* @return type object
*/
private function getParseResponse($Parameters, $payment)
{
$payment = PayModel::getPaymentById($payment);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($Parameters);
if (empty($res->bankName)) {
$res->bankName = empty($payment['payName']) ? '' : $payment['payName'];
}
if (empty($res->bankCode)) {
$res->bankCode = empty($payment['pay_code']) ? '' : $payment['pay_code'];
}
return $res;
}
/**
* 通用显示结果的方法
* @param array $dealResult
*/
... ...