Compare commits

2 Commits

Author SHA1 Message Date
95e1f4a163 调整支付 2023-09-06 11:22:06 +08:00
3f58973c30 阶段更新 2023-09-05 10:49:03 +08:00
12 changed files with 101 additions and 28 deletions

View File

@@ -1 +1,11 @@
# 沃支付 WEB收银台支付接口文档
测试地址
支付https://www.unicompayment.com/wappay3.0/httpservice/wapPayPageAction.do?reqcharset=UTF-8
单笔查询https://www.unicompayment.com/CashierWeb/query/order.htm?reqCharSet=UTF-8
单笔订单退款https://www.unicompayment.com/CashierWeb/trade/singleRefund.htm?reqCharSet=UTF-8
正式地址
支付https://epay.10010.com/wappay3.0/httpservice/wapPayPageAction.do?reqcharset=UTF-8
单笔查询https://epay.10010.com/CashierWeb/query/order.htm?reqCharSet=UTF-8
单笔订单退款https://epay.10010.com/CashierWeb/trade/singleRefund.htm?reqCharSet=UTF-8

View File

@@ -1,6 +1,6 @@
{
"name": "xuanchen/wounicomweb",
"description": "沃钱包支付-WEB收银台支付接口文档",
"description": "沃钱包支付-驰玖",
"license": "MIT",
"homepage": "https://git.yuzhankeji.cn/xuanchen/WoUnicomWeb.git",
"authors": [

View File

@@ -1,9 +1,9 @@
<?php
return [
'merNo' => env('WO_UNICOM_MERNO', ''),//商户编号
'storeName' => env('WO_UNICOM_STORENAME', ''),//商户名
'key' => env('WO_UNICOM_KEY', ''),//商户密钥
'merNo' => env('WO_UNICOM_WEB_MERNO', ''),//商户编号
'storeName' => env('WO_UNICOM_WEB_STORE_NAME', ''),//商户名
'key' => env('WO_UNICOM_WEB_KEY', ''),//商户密钥
'signType' => 'RSA_SHA256',//签名方式
'woproductcode' => '',//产品编码
@@ -11,11 +11,11 @@ return [
'uri' => [
'unicom' => [
//下单
'order' => 'https://epay.10010.com/wappay3.0/httpservice/wapPayPageAction.do?reqcharset=UTF-8',
'order' => 'https://www.unicompayment.com/wappay3.0/httpservice/wapPayPageAction.do?reqcharset=UTF-8',
//查询
'query' => 'https://epay.10010.com/CashierWeb/query/order.htm?reqCharSet=UTF-8',
'query' => 'https://www.unicompayment.com/CashierWeb/query/order.htm?reqCharSet=UTF-8',
//单笔退款
'refund' => 'https://epay.10010.com/CashierWeb/trade/singleRefund.htm?reqCharSet=UTF-8',
'refund' => 'https://www.unicompayment.com/CashierWeb/trade/singleRefund.htm?reqCharSet=UTF-8',
],
'ysd' => [
'order' => env('APP_URL', 'https://card.ysd-bs.com'),
@@ -25,8 +25,8 @@ return [
//证书地址
'certificate' => [
'private' => env('WO_YSD_KEY_PATH', ''),//本地私钥
'public' => env('WO_YSD_CERT_PATH', ''),//本地公钥
'unicom_public' => env('WO_CERT_PATH', ''),//沃钱包公钥
'private' => env('WO_YSD_KEY_WEB_PATH', ''),//本地私钥
'public' => env('WO_YSD_CERT_WEB_PATH', ''),//本地公钥
'unicom_public' => env('WO_CERT_WEB_PATH', ''),//沃钱包公钥
],
];

View File

@@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateWoUnicomWebsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('wounicom_webs', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('orderId')->nullable()->comment('订单号');
$table->string('payFloodId')->nullable()->comment('交易流水号');
$table->string('payResult')->nullable()->comment('支付结果');
$table->string('payBalance')->nullable()->comment('支付金额');
$table->string('paymentBalanceDetail')->nullable()->comment('金额明细');
$table->string('respTime')->nullable()->comment('支付时间');
$table->json('source')->nullable();
$table->json('outsource')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('wounicom_webs');
}
}

View File

@@ -115,7 +115,6 @@ class Init
{
$sign = $this->getSign();
$this->params['signMsg'] = $sign;
return $this->params;
}
@@ -162,6 +161,7 @@ class Init
public function getSign(): string
{
$signStr = $this->getSignString();
$private_key = $this->getPrivate();
$privKeyId = openssl_get_privatekey($private_key);
@@ -197,7 +197,9 @@ class Init
ksort($params);
$signStr = $this->str2utf8(urldecode(http_build_query($params, '', '|')));
$this->signStr = $signStr;
// $signStr .= '|key='.$this->key;
return $signStr;
}
@@ -207,7 +209,7 @@ class Init
* @Author: 玄尘
* @Date : 2021/5/6 8:32
*/
public function getUnicomData($prefix = '$')
public function getUnicomData($prefix = '&')
{
$str = '';
@@ -320,8 +322,8 @@ class Init
if ($response->getStatusCode() == 200) {
$body = $response->getBody();
$content = str_replace(["\r\n", "\n", "\r", '/n', "\\n",], '&', $body->getContents());
parse_str($content, $data);
parse_str($content, $data);
$this->data = $data;
if (isset($data['queryResult']) && $data['queryResult'] != 'SUCCESS') {

View File

@@ -20,8 +20,9 @@ class Order extends Init
{
$this->addData();
$this->setSignData();
return $this->getUnicomData();
// dump($this);
// dump($this->params);
return $this->getUnicomData('$');
}
/**

View File

@@ -4,6 +4,7 @@ namespace XuanChen\WoUnicomWeb\Action;
/**
* Class Order 查询
*
* @Author : 玄尘
* @Date : 2021/4/30 9:34
* @package XuanChen\Coupon\Action
@@ -25,8 +26,7 @@ class Query extends Init
public function addData()
{
$order = $this->params;
$data = [
$data = [
'merNo' => $this->merNo,
'orderNo' => $order->orderid,
'orderDate' => $order->created_at->format('Ymd'),
@@ -35,7 +35,6 @@ class Query extends Init
];
$this->params = $data;
}
}

View File

@@ -6,6 +6,7 @@ use Carbon\Carbon;
/**
* Class Order 退款
*
* @Author : 玄尘
* @Date : 2021/4/30 9:34
* @package XuanChen\Coupon\Action
@@ -29,15 +30,15 @@ class Refund extends Init
$order = $this->params;
$data = [
'refundReqJournl' => 'R' . date('YmdHis') . sprintf('%06d', rand(1, 999999999)),
'refundReqJournl' => 'R'.date('YmdHis').sprintf('%06d', rand(1, 999999999)),
'merNo' => $this->merNo,
'orderNo' => $order->orderid,
'orderDate' => $order->created_at->format('Ymd'),
'payJournl' => $order->payment->out_trade_no,
'merReqTime' => Carbon::now()->format('YmdHis'),
'amount' => $order->payment->amount * 100,
'amount' => bcmul($order->payment->amount,100),
'reason' => '退款',
'signType' => 'RSA_SHA256',
'signType' => config('wounicomweb.signType'),
];
$this->params = $data;

View File

@@ -8,7 +8,7 @@ class WounicomWeb extends Model
{
protected $guarded = [];
public $casts = [
'source' => 'json',
'outsource' => 'json',

View File

@@ -16,10 +16,11 @@ class ServiceProvider extends LaravelServiceProvider
{
if ($this->app->runningInConsole()) {
$this->publishes([__DIR__.'/../config/config.php' => config_path('wounicomweb.php')]);
$this->loadMigrationsFrom(__DIR__.'/../database/migrations/');
}
$this->app->bind('xuanchen.wounicomweb', function ($app) {
return new WoUnicom();
return new WoUnicomWeb();
});
}
@@ -30,7 +31,7 @@ class ServiceProvider extends LaravelServiceProvider
*/
public function boot()
{
$this->mergeConfigFrom(__DIR__.'/../config/config.php', 'wounicom');
$this->mergeConfigFrom(__DIR__.'/../config/config.php', 'wounicomweb');
}
}

View File

@@ -2,7 +2,7 @@
namespace XuanChen\WoUnicomWeb\Traits;
use XuanChen\WoUnicomWeb\Model\Wounicom as LogModel;
use XuanChen\WoUnicomWeb\Model\WounicomWeb as LogModel;
trait Log
{
@@ -11,6 +11,7 @@ trait Log
/**
* Notes: 输入日志
*
* @Author: 玄尘
* @Date : 2021/5/11 15:58
* @param $data
@@ -33,6 +34,7 @@ trait Log
/**
* Notes: 更新
*
* @Author: 玄尘
* @Date : 2021/7/23 11:03
* @param $data

View File

@@ -3,6 +3,7 @@
namespace XuanChen\WoUnicomWeb;
use App\Helpers\Helper;
use App\Models\ActivityMonthOrder;
use App\Models\ActivitySchoolOrder;
use App\Models\ActivityPetroOrder;
use App\Models\ActivityUnicomOrder;
@@ -95,6 +96,7 @@ class WoUnicomWeb
*/
public function callback($inputs)
{
info($inputs);
if (empty($inputs)) {
return '缺少必要参数';
}
@@ -126,7 +128,7 @@ class WoUnicomWeb
break;
case 'school':
$order = ActivitySchoolOrder::where('orderid', $data['orderid'])->first();
if ($order && $order->state == 'UNPAY') {
if ($order && $order->state == ActivitySchoolOrder::ORDER_UNPAY) {
$payment = Payment::where('orderable_type', get_class($order))
->where('orderable_id', $order->id)
->latest()
@@ -142,6 +144,22 @@ class WoUnicomWeb
break;
case 'petro':
$order = ActivityPetroOrder::where('orderid', $data['orderid'])->first();
if ($order && $order->state == ActivityMonthOrder::ORDER_UNPAY) {
$payment = Payment::where('orderable_type', get_class($order))
->where('orderable_id', $order->id)
->latest()
->first();
$payment->state = Payment::STATE_SUCCESS;
$payment->out_trade_no = $data['payfloodid'];
$payment->type = Payment::TYPT_UNICOM_WEB;
$payment->paid_at = Carbon::now();
$payment->save();
$order->paid();
}
break;
case 'unicom':
$order = ActivityUnicomOrder::where('orderid', $data['orderid'])->first();
if ($order && $order->state == 'UNPAY') {
$payment = Payment::where('orderable_type', get_class($order))
->where('orderable_id', $order->id)
@@ -156,8 +174,8 @@ class WoUnicomWeb
$order->paid();
}
break;
case 'unicom':
$order = ActivityUnicomOrder::where('orderid', $data['orderid'])->first();
case 'month':
$order = ActivityMonthOrder::where('orderid', $data['orderid'])->first();
if ($order && $order->state == 'UNPAY') {
$payment = Payment::where('orderable_type', get_class($order))
->where('orderable_id', $order->id)