|
@@ -23,6 +23,7 @@ use App\Modules\Product\Services\ProductService;
|
|
|
use App\Modules\Book\Services\BookConfigService;
|
|
|
use App\Modules\Book\Services\BookService;
|
|
|
use App\Modules\Channel\Services\PayTemplateService;
|
|
|
+use App\Modules\Trade\Models\PayMerchant;
|
|
|
use App\Modules\Trade\Pay\OrderArousePayFactory;
|
|
|
use App\Modules\Trade\Pay\OrderPaySuccess;
|
|
|
use Exception;
|
|
@@ -468,14 +469,62 @@ class OrdersController extends BaseController
|
|
|
*
|
|
|
* }
|
|
|
*/
|
|
|
- function wxindex(Request $request)
|
|
|
+ function wxIndex(Request $request)
|
|
|
{
|
|
|
if ($params = $this->getPayParams($request)) {
|
|
|
- $params['pay_merchant_source'] = 'QuickAppWxPay';
|
|
|
+ $params['pay_merchant_source'] = 'OFFICIALPAY_QAPP_APP';
|
|
|
} else {
|
|
|
return response()->error('QAPP_PARAM_ERROR');
|
|
|
}
|
|
|
- $app = OrderArousePayFactory::wxApp($this->uid);
|
|
|
+ $app = OrderArousePayFactory::wx($this->uid);
|
|
|
+ // 微信支付参数
|
|
|
+ $params['trade_type'] = 'APP'; //交易类型
|
|
|
+ $result = $app->handle($params);
|
|
|
+ if ($result) {
|
|
|
+ return response()->success($result);
|
|
|
+ } else {
|
|
|
+ return response()->error('APP_CREATE_WECHAT_ORDER_FAIL');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @apiVersion 1.0.0
|
|
|
+ * @apiDescription 微信H5支付
|
|
|
+ * @api {get} goToH5Pay 微信H5支付
|
|
|
+ * @apiGroup pay
|
|
|
+ * @apiName wxindex
|
|
|
+ * @apiParam {Int} product_id product_id
|
|
|
+ * @apiParam {Int} send_order_id send_order_id
|
|
|
+ * @apiParam {String} bid bid
|
|
|
+ * @apiHeader {String} [Authorization] token
|
|
|
+ * @apiSuccess {int} code 状态码
|
|
|
+ * @apiSuccess {String} msg 信息
|
|
|
+ * @apiSuccess {Object} data 信息
|
|
|
+ * @apiSuccess {Object} data.appId 唤起支付的appId
|
|
|
+ * @apiSuccess {Object} data.mch_id 唤起支付的mch_id
|
|
|
+ * @apiSuccess {Object} data.nonce_str 唤起支付的nonce_str
|
|
|
+ * @apiSuccess {Object} data.prepay_id 唤起支付的prepay_id
|
|
|
+ * @apiSuccess {Object} data.sign 唤起支付的sign
|
|
|
+ * @apiSuccess {Object} data.trade_type 唤起支付trade_type
|
|
|
+ * @apiSuccessExample {json} Success-Response:
|
|
|
+ * HTTP/1.1 200 OK
|
|
|
+ * {
|
|
|
+ * code: 0,
|
|
|
+ * msg: "",
|
|
|
+ * data: {
|
|
|
+ *
|
|
|
+ * }
|
|
|
+ */
|
|
|
+ function wxH5Index(Request $request)
|
|
|
+ {
|
|
|
+ if ($params = $this->getPayParams($request)) {
|
|
|
+ $params['pay_merchant_source'] = 'OFFICIALPAY_QAPP_H5';
|
|
|
+ } else {
|
|
|
+ return response()->error('QAPP_PARAM_ERROR');
|
|
|
+ }
|
|
|
+ $app = OrderArousePayFactory::wx($this->uid);
|
|
|
+ // 微信支付参数
|
|
|
+ $params['trade_type'] = 'MWEB'; //交易类型
|
|
|
$result = $app->handle($params);
|
|
|
if ($result) {
|
|
|
return response()->success($result);
|
|
@@ -567,12 +616,13 @@ class OrdersController extends BaseController
|
|
|
{
|
|
|
$param = $request->except('_url');
|
|
|
myLog('wxpay')->info($param);
|
|
|
+ $pay_merchant_name = $param['attach'];
|
|
|
+ $pay_merchant = PayMerchant::where('name', $pay_merchant_name)->first();
|
|
|
+ $pay_config = json_decode($pay_merchant->config_info);
|
|
|
$config = [
|
|
|
- // 微信支付参数
|
|
|
- 'appid' => 'wx7ff41112e6dfb2d7', // 应用ID
|
|
|
- 'merchant_id' => '1500977641', // 微信支付商户号
|
|
|
- 'key' => '0e7SfPt3EOS0HC1GxVa4fqmCUINcN71E', // 微信支付密钥
|
|
|
- 'trade_type' => 'APP',
|
|
|
+ 'appid' => $pay_config->appid,
|
|
|
+ 'merchant_id' => $pay_config->merchant_id,
|
|
|
+ 'key' => $pay_config->key,
|
|
|
];
|
|
|
$app = PayFactory::official($config);
|
|
|
$response = $app->notify()->handleNotify(function ($notify, $successful) {
|