diff --git a/.env.example b/.env.example index fb779d3..7e51d64 100644 --- a/.env.example +++ b/.env.example @@ -56,3 +56,5 @@ VITE_PUSHER_HOST="${PUSHER_HOST}" VITE_PUSHER_PORT="${PUSHER_PORT}" VITE_PUSHER_SCHEME="${PUSHER_SCHEME}" VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" + +ALIPAY_APP_ID= diff --git a/app/Exceptions/PaymentException.php b/app/Exceptions/PaymentException.php new file mode 100644 index 0000000..7a0f7b5 --- /dev/null +++ b/app/Exceptions/PaymentException.php @@ -0,0 +1,10 @@ +validate([ 'amount' => 'required|numeric', ]); - $balance = $request->user(); + $user = $request->user(); - // 启用事物 - \DB::beginTransaction(); - try { - $balance->increment('amount', $request->amount); - \DB::commit(); - } catch (\Exception $e) { - \DB::rollBack(); - return $this->error($e->getMessage()); - } + $balance = new Balance(); + + + $balance = $balance->create([ + 'user_id' => $user->id, + 'amount' => $request->amount, + 'payment' => 'alipay', + ]); + + // 生成 18 位订单号 + $order_id = date('YmdHis') . $balance->id . rand(1000, 9999); + $balance->order_id = $order_id; + + $balance->save(); + + $balance = $balance->toArray(); + $balance['pay_url'] = route('balances.pay.show', ['balance' => $balance['order_id']]); return $this->success($balance); } + public function show(Request $request, Balance $balance) + { + // dd(AlipayFactory::payment()->common()->query('20220901070430102316')); + // dd(route('')); + if ($balance->paid_at !== null) { + return $this->error('订单已支付'); + } + + try { + $result = AlipayFactory::payment()->page()->pay("支付", $balance->order_id, $balance->amount, 'http://rcrmqishil.sharedwithexpose.com/api/pay/return'); + + $responseChecker = new ResponseChecker(); + + // dd($result); + + if ($responseChecker->success($result)) { + $html = $result->body; + return view('pay', compact('html')); + } + } catch (Exception $e) { + dd($e->getMessage()); + echo "调用失败," . $e->getMessage() . PHP_EOL;; + } + + + return $this->success($balance); + } + + public function notify(Request $request) + { + // 检测订单是否存在 + $balance = Balance::where('order_id', $request->out_trade_no)->with('user')->first(); + if (!$balance) { + return $this->notFound('balance not found'); + } + + // 检测订单是否已支付 + if ($balance->paid_at !== null) { + return $this->success('订单已支付'); + } + + $trade = AlipayFactory::payment()->common()->query($request->out_trade_no); + + if ($trade->code == "10000" && $trade->tradeStatus == "TRADE_SUCCESS") { + $balance->paid_at = now(); + $balance->save(); + + + DB::beginTransaction(); + try { + $balance->user->increment('balance', $trade->totalAmount); + DB::commit(); + } catch (\Exception $e) { + DB::rollBack(); + AlipayFactory::payment()->common()->refund($request->out_trade_no, $trade->totalAmount); + return $this->error($e->getMessage()); + } + + return $this->success('订单支付成功'); + } else { + return $this->error('订单支付失败'); + } + + + } + // // 转换为 drops // public function transfer($amount = 1) // { @@ -49,6 +128,4 @@ public function store(Request $request) // } - - } diff --git a/app/Models/User/Balance.php b/app/Models/User/Balance.php new file mode 100644 index 0000000..061e817 --- /dev/null +++ b/app/Models/User/Balance.php @@ -0,0 +1,32 @@ +belongsTo(User::class); + } +} diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index a3382e9..f3d6510 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,7 +2,10 @@ namespace App\Providers; +use Alipay\EasySDK\Kernel\Config as AlipayConfig; +use Alipay\EasySDK\Kernel\Factory as AlipayFactory; use Illuminate\Support\Facades\Http; +use Illuminate\Support\Facades\Storage; use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider @@ -34,5 +37,33 @@ public function boot() ])->baseUrl($url); }); + AlipayFactory::setOptions($this->alipayOptions()); + + } + + private function alipayOptions() + { + $options = new AlipayConfig(); + $options->protocol = 'https'; + $options->gatewayHost = 'openapi.alipaydev.com'; + $options->signType = 'RSA2'; + + $options->appId = config('alipay.app_id'); + + // 为避免私钥随源码泄露,推荐从文件中读取私钥字符串而不是写入源码中 + $options->merchantPrivateKey = trim(Storage::get('alipayAppPriv.key')); + + $options->alipayCertPath = storage_path('app/alipayCertPublicKey_RSA2.crt'); + $options->alipayRootCertPath = storage_path('app/alipayRootCert.crt'); + $options->merchantCertPath = storage_path('app/appCertPublicKey.crt'); + + //注:如果采用非证书模式,则无需赋值上面的三个证书路径,改为赋值如下的支付宝公钥字符串即可 + // $options->alipayPublicKey = Storage::get('alipayCertPublicKey_RSA2.crt'); + + //可设置异步通知接收服务地址(可选) + $options->notifyUrl = "http://rcrmqishil.sharedwithexpose.com/api/pay/notify"; + + + return $options; } } diff --git a/composer.json b/composer.json index 1b28fcb..3c459ef 100644 --- a/composer.json +++ b/composer.json @@ -6,6 +6,7 @@ "license": "MIT", "require": { "php": "^8.0.2", + "alipaysdk/easysdk": "^2.0", "doctrine/dbal": "^3.3", "guzzlehttp/guzzle": "^7.2", "laravel/framework": "^9.19", @@ -13,7 +14,8 @@ "laravel/octane": "^1.2", "laravel/sanctum": "^2.14.1", "laravel/telescope": "^4.9", - "laravel/tinker": "^2.7" + "laravel/tinker": "^2.7", + "league/omnipay": "^3" }, "require-dev": { "fakerphp/faker": "^1.9.1", diff --git a/composer.lock b/composer.lock index 3128770..61be705 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,249 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "90a43fb7e2ad250a4fd0c8306adf0883", + "content-hash": "847c228b28d8e87b173855aebdf22fdd", "packages": [ + { + "name": "adbario/php-dot-notation", + "version": "2.4.1", + "source": { + "type": "git", + "url": "https://github.com/adbario/php-dot-notation.git", + "reference": "3bfe67895d26697d20485343499532234eeb7c08" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/adbario/php-dot-notation/zipball/3bfe67895d26697d20485343499532234eeb7c08", + "reference": "3bfe67895d26697d20485343499532234eeb7c08", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "ext-json": "*", + "php": "^5.5 || ^7.0 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8|^5.7|^6.6|^7.5|^8.5|^9.5", + "squizlabs/php_codesniffer": "^3.6" + }, + "type": "library", + "autoload": { + "files": [ + "src/helpers.php" + ], + "psr-4": { + "Adbar\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Riku Särkinen", + "email": "riku@adbar.io" + } + ], + "description": "PHP dot notation access to arrays", + "homepage": "https://github.com/adbario/php-dot-notation", + "keywords": [ + "ArrayAccess", + "dotnotation" + ], + "support": { + "issues": "https://github.com/adbario/php-dot-notation/issues", + "source": "https://github.com/adbario/php-dot-notation/tree/2.4.1" + }, + "time": "2022-08-25T19:47:20+00:00" + }, + { + "name": "alibabacloud/tea", + "version": "3.1.24", + "source": { + "type": "git", + "url": "https://github.com/aliyun/tea-php.git", + "reference": "bb33395f47db3847d1940d6eb8ba1e56cd0623cb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/aliyun/tea-php/zipball/bb33395f47db3847d1940d6eb8ba1e56cd0623cb", + "reference": "bb33395f47db3847d1940d6eb8ba1e56cd0623cb", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "adbario/php-dot-notation": "^2.3", + "ext-curl": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-openssl": "*", + "ext-simplexml": "*", + "ext-xmlwriter": "*", + "guzzlehttp/guzzle": "^6.3|^7.0", + "php": ">=5.5" + }, + "require-dev": { + "phpunit/phpunit": "*", + "symfony/dotenv": "^3.4", + "symfony/var-dumper": "^3.4" + }, + "suggest": { + "ext-sockets": "To use client-side monitoring" + }, + "type": "library", + "autoload": { + "psr-4": { + "AlibabaCloud\\Tea\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Alibaba Cloud SDK", + "email": "sdk-team@alibabacloud.com", + "homepage": "http://www.alibabacloud.com" + } + ], + "description": "Client of Tea for PHP", + "homepage": "https://www.alibabacloud.com/", + "keywords": [ + "alibabacloud", + "client", + "cloud", + "tea" + ], + "support": { + "issues": "https://github.com/aliyun/tea-php/issues", + "source": "https://github.com/aliyun/tea-php" + }, + "time": "2022-07-18T11:27:29+00:00" + }, + { + "name": "alibabacloud/tea-fileform", + "version": "0.3.4", + "source": { + "type": "git", + "url": "https://github.com/alibabacloud-sdk-php/tea-fileform.git", + "reference": "4bf0c75a045c8115aa8cb1a394bd08d8bb833181" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/alibabacloud-sdk-php/tea-fileform/zipball/4bf0c75a045c8115aa8cb1a394bd08d8bb833181", + "reference": "4bf0c75a045c8115aa8cb1a394bd08d8bb833181", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "alibabacloud/tea": "^3.0", + "php": ">5.5" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35|^5.4.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "AlibabaCloud\\Tea\\FileForm\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Alibaba Cloud SDK", + "email": "sdk-team@alibabacloud.com" + } + ], + "description": "Alibaba Cloud Tea File Library for PHP", + "support": { + "issues": "https://github.com/alibabacloud-sdk-php/tea-fileform/issues", + "source": "https://github.com/alibabacloud-sdk-php/tea-fileform/tree/0.3.4" + }, + "time": "2020-12-01T07:24:35+00:00" + }, + { + "name": "alipaysdk/easysdk", + "version": "2.2.2", + "source": { + "type": "git", + "url": "https://github.com/alipay/alipay-easysdk.git", + "reference": "eac46450971d094e8cfb1c183da1080ca53d75b9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/alipay/alipay-easysdk/zipball/eac46450971d094e8cfb1c183da1080ca53d75b9", + "reference": "eac46450971d094e8cfb1c183da1080ca53d75b9", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "alibabacloud/tea": "^3.1", + "alibabacloud/tea-fileform": "^0.3.2", + "ext-ctype": "*", + "ext-curl": "*", + "ext-dom": "*", + "ext-fileinfo": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-openssl": "*", + "ext-simplexml": "*", + "ext-xmlwriter": "*", + "guzzlehttp/guzzle": ">=6.3", + "php": ">=7.0" + }, + "require-dev": { + "phpunit/phpunit": "^7.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Alipay\\EasySDK\\": "php/src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "junying.wjy", + "email": "junying.wjy@antfin.com" + } + ], + "description": "支付宝官方 Alipay Easy SDK", + "support": { + "source": "https://github.com/alipay/alipay-easysdk/tree/v2.2.2" + }, + "time": "2022-05-07T03:29:10+00:00" + }, { "name": "brick/math", "version": "0.10.1", @@ -68,6 +309,78 @@ ], "time": "2022-08-01T22:54:31+00:00" }, + { + "name": "clue/stream-filter", + "version": "v1.6.0", + "source": { + "type": "git", + "url": "https://github.com/clue/stream-filter.git", + "reference": "d6169430c7731d8509da7aecd0af756a5747b78e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/clue/stream-filter/zipball/d6169430c7731d8509da7aecd0af756a5747b78e", + "reference": "d6169430c7731d8509da7aecd0af756a5747b78e", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "php": ">=5.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.36" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "Clue\\StreamFilter\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering" + } + ], + "description": "A simple and modern approach to stream filtering in PHP", + "homepage": "https://github.com/clue/php-stream-filter", + "keywords": [ + "bucket brigade", + "callback", + "filter", + "php_user_filter", + "stream", + "stream_filter_append", + "stream_filter_register" + ], + "support": { + "issues": "https://github.com/clue/stream-filter/issues", + "source": "https://github.com/clue/stream-filter/tree/v1.6.0" + }, + "funding": [ + { + "url": "https://clue.engineering/support", + "type": "custom" + }, + { + "url": "https://github.com/clue", + "type": "github" + } + ], + "time": "2022-02-21T13:15:14+00:00" + }, { "name": "dflydev/dot-access-data", "version": "v3.0.1", @@ -2417,6 +2730,169 @@ ], "time": "2022-04-17T13:12:02+00:00" }, + { + "name": "league/omnipay", + "version": "v3.2.1", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/omnipay.git", + "reference": "38f66a0cc043ed51d6edf7956d6439a2f263501f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/omnipay/zipball/38f66a0cc043ed51d6edf7956d6439a2f263501f", + "reference": "38f66a0cc043ed51d6edf7956d6439a2f263501f", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "omnipay/common": "^3.1", + "php": "^7.2|^8.0", + "php-http/discovery": "^1.14", + "php-http/guzzle7-adapter": "^1" + }, + "require-dev": { + "omnipay/tests": "^3|^4" + }, + "type": "metapackage", + "extra": { + "branch-alias": { + "dev-master": "3.2.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Adrian Macneil", + "email": "adrian@adrianmacneil.com" + }, + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "Omnipay payment processing library", + "homepage": "https://omnipay.thephpleague.com/", + "keywords": [ + "checkout", + "creditcard", + "omnipay", + "payment" + ], + "support": { + "issues": "https://github.com/thephpleague/omnipay/issues", + "source": "https://github.com/thephpleague/omnipay/tree/v3.2.1" + }, + "funding": [ + { + "url": "https://github.com/barryvdh", + "type": "github" + } + ], + "time": "2021-06-05T11:34:12+00:00" + }, + { + "name": "moneyphp/money", + "version": "v4.0.5", + "source": { + "type": "git", + "url": "https://github.com/moneyphp/money.git", + "reference": "cee58435ff82a5de252c516e6a31beb674898985" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/moneyphp/money/zipball/cee58435ff82a5de252c516e6a31beb674898985", + "reference": "cee58435ff82a5de252c516e6a31beb674898985", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "ext-bcmath": "*", + "ext-filter": "*", + "ext-json": "*", + "php": "~8.0.0 || ~8.1.0" + }, + "require-dev": { + "cache/taggable-cache": "^1.1.0", + "doctrine/coding-standard": "^9.0", + "doctrine/instantiator": "^1.4.0", + "ext-gmp": "*", + "ext-intl": "*", + "florianv/exchanger": "^2.6.3", + "florianv/swap": "^4.3.0", + "moneyphp/iso-currencies": "^3.2.1", + "php-http/message": "^1.11.0", + "php-http/mock-client": "^1.4.1", + "phpbench/phpbench": "^1.2.5", + "phpspec/phpspec": "^7.2", + "phpunit/phpunit": "^9.5.4", + "psalm/plugin-phpunit": "^0.15.1", + "psr/cache": "^1.0.1", + "vimeo/psalm": "~4.7.0 || ^4.8.2" + }, + "suggest": { + "ext-gmp": "Calculate without integer limits", + "ext-intl": "Format Money objects with intl", + "florianv/exchanger": "Exchange rates library for PHP", + "florianv/swap": "Exchange rates library for PHP", + "psr/cache-implementation": "Used for Currency caching" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Money\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mathias Verraes", + "email": "mathias@verraes.net", + "homepage": "http://verraes.net" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + }, + { + "name": "Frederik Bosch", + "email": "f.bosch@genkgo.nl" + } + ], + "description": "PHP implementation of Fowler's Money pattern", + "homepage": "http://moneyphp.org", + "keywords": [ + "Value Object", + "money", + "vo" + ], + "support": { + "issues": "https://github.com/moneyphp/money/issues", + "source": "https://github.com/moneyphp/money/tree/v4.0.5" + }, + "time": "2022-08-11T09:12:20+00:00" + }, { "name": "monolog/monolog", "version": "2.8.0", @@ -2946,6 +3422,516 @@ ], "time": "2022-08-01T11:03:24+00:00" }, + { + "name": "omnipay/common", + "version": "v3.2.0", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/omnipay-common.git", + "reference": "e278ff00676c05cd0f4aaaf6189a226f26ae056e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/omnipay-common/zipball/e278ff00676c05cd0f4aaaf6189a226f26ae056e", + "reference": "e278ff00676c05cd0f4aaaf6189a226f26ae056e", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "moneyphp/money": "^3.1|^4.0.3", + "php": "^7.2|^8", + "php-http/client-implementation": "^1", + "php-http/discovery": "^1.14", + "php-http/message": "^1.5", + "symfony/http-foundation": "^2.1|^3|^4|^5|^6" + }, + "require-dev": { + "omnipay/tests": "^4.1", + "php-http/guzzle7-adapter": "^1", + "php-http/mock-client": "^1", + "squizlabs/php_codesniffer": "^3.5" + }, + "suggest": { + "league/omnipay": "The default Omnipay package provides a default HTTP Adapter." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Omnipay\\Common\\": "src/Common" + }, + "classmap": [ + "src/Omnipay.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Adrian Macneil", + "email": "adrian@adrianmacneil.com" + }, + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + }, + { + "name": "Jason Judge", + "email": "jason.judge@consil.co.uk" + }, + { + "name": "Del" + }, + { + "name": "Omnipay Contributors", + "homepage": "https://github.com/thephpleague/omnipay-common/contributors" + } + ], + "description": "Common components for Omnipay payment processing library", + "homepage": "https://github.com/thephpleague/omnipay-common", + "keywords": [ + "gateway", + "merchant", + "omnipay", + "pay", + "payment", + "purchase" + ], + "support": { + "issues": "https://github.com/thephpleague/omnipay-common/issues", + "source": "https://github.com/thephpleague/omnipay-common/tree/v3.2.0" + }, + "funding": [ + { + "url": "https://github.com/barryvdh", + "type": "github" + } + ], + "time": "2021-12-30T11:32:00+00:00" + }, + { + "name": "php-http/discovery", + "version": "1.14.2", + "source": { + "type": "git", + "url": "https://github.com/php-http/discovery.git", + "reference": "c8d48852fbc052454af42f6de27635ddd916b959" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/discovery/zipball/c8d48852fbc052454af42f6de27635ddd916b959", + "reference": "c8d48852fbc052454af42f6de27635ddd916b959", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "conflict": { + "nyholm/psr7": "<1.0" + }, + "require-dev": { + "graham-campbell/phpspec-skip-example-extension": "^5.0", + "php-http/httplug": "^1.0 || ^2.0", + "php-http/message-factory": "^1.0", + "phpspec/phpspec": "^5.1 || ^6.1" + }, + "suggest": { + "php-http/message": "Allow to use Guzzle, Diactoros or Slim Framework factories" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.9-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Discovery\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "Finds installed HTTPlug implementations and PSR-7 message factories", + "homepage": "http://php-http.org", + "keywords": [ + "adapter", + "client", + "discovery", + "factory", + "http", + "message", + "psr7" + ], + "support": { + "issues": "https://github.com/php-http/discovery/issues", + "source": "https://github.com/php-http/discovery/tree/1.14.2" + }, + "time": "2022-05-25T07:26:05+00:00" + }, + { + "name": "php-http/guzzle7-adapter", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/guzzle7-adapter.git", + "reference": "fb075a71dbfa4847cf0c2938c4e5a9c478ef8b01" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/guzzle7-adapter/zipball/fb075a71dbfa4847cf0c2938c4e5a9c478ef8b01", + "reference": "fb075a71dbfa4847cf0c2938c4e5a9c478ef8b01", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "guzzlehttp/guzzle": "^7.0", + "php": "^7.2 | ^8.0", + "php-http/httplug": "^2.0", + "psr/http-client": "^1.0" + }, + "provide": { + "php-http/async-client-implementation": "1.0", + "php-http/client-implementation": "1.0", + "psr/http-client-implementation": "1.0" + }, + "require-dev": { + "php-http/client-integration-tests": "^3.0", + "phpunit/phpunit": "^8.0|^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Adapter\\Guzzle7\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com" + } + ], + "description": "Guzzle 7 HTTP Adapter", + "homepage": "http://httplug.io", + "keywords": [ + "Guzzle", + "http" + ], + "support": { + "issues": "https://github.com/php-http/guzzle7-adapter/issues", + "source": "https://github.com/php-http/guzzle7-adapter/tree/1.0.0" + }, + "time": "2021-03-09T07:35:15+00:00" + }, + { + "name": "php-http/httplug", + "version": "2.3.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/httplug.git", + "reference": "f640739f80dfa1152533976e3c112477f69274eb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/httplug/zipball/f640739f80dfa1152533976e3c112477f69274eb", + "reference": "f640739f80dfa1152533976e3c112477f69274eb", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "php": "^7.1 || ^8.0", + "php-http/promise": "^1.1", + "psr/http-client": "^1.0", + "psr/http-message": "^1.0" + }, + "require-dev": { + "friends-of-phpspec/phpspec-code-coverage": "^4.1", + "phpspec/phpspec": "^5.1 || ^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Eric GELOEN", + "email": "geloen.eric@gmail.com" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" + } + ], + "description": "HTTPlug, the HTTP client abstraction for PHP", + "homepage": "http://httplug.io", + "keywords": [ + "client", + "http" + ], + "support": { + "issues": "https://github.com/php-http/httplug/issues", + "source": "https://github.com/php-http/httplug/tree/2.3.0" + }, + "time": "2022-02-21T09:52:22+00:00" + }, + { + "name": "php-http/message", + "version": "1.13.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/message.git", + "reference": "7886e647a30a966a1a8d1dad1845b71ca8678361" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/message/zipball/7886e647a30a966a1a8d1dad1845b71ca8678361", + "reference": "7886e647a30a966a1a8d1dad1845b71ca8678361", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "clue/stream-filter": "^1.5", + "php": "^7.1 || ^8.0", + "php-http/message-factory": "^1.0.2", + "psr/http-message": "^1.0" + }, + "provide": { + "php-http/message-factory-implementation": "1.0" + }, + "require-dev": { + "ergebnis/composer-normalize": "^2.6", + "ext-zlib": "*", + "guzzlehttp/psr7": "^1.0", + "laminas/laminas-diactoros": "^2.0", + "phpspec/phpspec": "^5.1 || ^6.3 || ^7.1", + "slim/slim": "^3.0" + }, + "suggest": { + "ext-zlib": "Used with compressor/decompressor streams", + "guzzlehttp/psr7": "Used with Guzzle PSR-7 Factories", + "laminas/laminas-diactoros": "Used with Diactoros Factories", + "slim/slim": "Used with Slim Framework PSR-7 implementation" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.10-dev" + } + }, + "autoload": { + "files": [ + "src/filters.php" + ], + "psr-4": { + "Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "HTTP Message related tools", + "homepage": "http://php-http.org", + "keywords": [ + "http", + "message", + "psr-7" + ], + "support": { + "issues": "https://github.com/php-http/message/issues", + "source": "https://github.com/php-http/message/tree/1.13.0" + }, + "time": "2022-02-11T13:41:14+00:00" + }, + { + "name": "php-http/message-factory", + "version": "v1.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-http/message-factory.git", + "reference": "a478cb11f66a6ac48d8954216cfed9aa06a501a1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/message-factory/zipball/a478cb11f66a6ac48d8954216cfed9aa06a501a1", + "reference": "a478cb11f66a6ac48d8954216cfed9aa06a501a1", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "php": ">=5.4", + "psr/http-message": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "Factory interfaces for PSR-7 HTTP Message", + "homepage": "http://php-http.org", + "keywords": [ + "factory", + "http", + "message", + "stream", + "uri" + ], + "support": { + "issues": "https://github.com/php-http/message-factory/issues", + "source": "https://github.com/php-http/message-factory/tree/master" + }, + "time": "2015-12-19T14:08:53+00:00" + }, + { + "name": "php-http/promise", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/promise.git", + "reference": "4c4c1f9b7289a2ec57cde7f1e9762a5789506f88" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/promise/zipball/4c4c1f9b7289a2ec57cde7f1e9762a5789506f88", + "reference": "4c4c1f9b7289a2ec57cde7f1e9762a5789506f88", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "friends-of-phpspec/phpspec-code-coverage": "^4.3.2", + "phpspec/phpspec": "^5.1.2 || ^6.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Promise\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Joel Wurtz", + "email": "joel.wurtz@gmail.com" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "Promise used for asynchronous HTTP requests", + "homepage": "http://httplug.io", + "keywords": [ + "promise" + ], + "support": { + "issues": "https://github.com/php-http/promise/issues", + "source": "https://github.com/php-http/promise/tree/1.1.0" + }, + "time": "2020-07-07T09:29:14+00:00" + }, { "name": "phpoption/phpoption", "version": "1.8.1", diff --git a/config/alipay.php b/config/alipay.php new file mode 100644 index 0000000..a020774 --- /dev/null +++ b/config/alipay.php @@ -0,0 +1,5 @@ + env('ALIPAY_APP_ID'), +]; diff --git a/database/migrations/2022_09_01_033240_create_balances_table.php b/database/migrations/2022_09_01_033240_create_balances_table.php new file mode 100644 index 0000000..3d276fd --- /dev/null +++ b/database/migrations/2022_09_01_033240_create_balances_table.php @@ -0,0 +1,51 @@ +id(); + + // order id + $table->string('order_id')->nullable()->index(); + + // trade id + $table->string('trade_id')->nullable()->index(); + + // payment + $table->string('payment')->nullable()->index(); + + // amount + $table->decimal('amount', 10, 2)->default(0); + + // paid_at + $table->timestamp('paid_at')->nullable(); + + // user id + $table->unsignedBigInteger('user_id')->nullable()->index(); + $table->foreign('user_id')->references('id')->on('users'); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('balances'); + } +}; diff --git a/resources/views/pay.blade.php b/resources/views/pay.blade.php new file mode 100644 index 0000000..615e158 --- /dev/null +++ b/resources/views/pay.blade.php @@ -0,0 +1,13 @@ + + +
+ +