| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- namespace App\Http\Controllers\V1;
- use App\Models\UserMemberOrder;
- use Illuminate\Http\Request;
- use Alipay\EasySDK\Kernel\Factory;
- use Alipay\EasySDK\Kernel\Util\ResponseChecker;
- use Alipay\EasySDK\Kernel\Config;
- /**
- * 支付
- */
- class PayController extends Controller
- {
- public function __construct()
- {
- $this->user = auth('api')->user();
- $this->userId = $this->user ? $this->user->id : 0;
- //如果用户被删除,会自动退出登录
- if (!empty($this->user->deleted_at)) {
- $this->user->online = 0;
- $this->user->save();
- auth('api')->logout();
- }
- Factory::setOptions($this->getOptions());
- }
- public function getOptions(){
- $options = new Config();
- $options->protocol = 'https';
- $options->gatewayHost = 'openapi.alipay.com';
- $options->signType = 'RSA2';
- $options->appId = '2016082201783461';
- $options->merchantPrivateKey = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6x0l1piPwoCObHcvkViykIsY+D8FJ5Cqvr0sUkpFgQpy9Mt/0zkA0gnWBDS3OtZl2QYuwKuooBrexa+Snbpd+SsTLGWtTieIt3xhtctigtw3j88HbiEZ/J/yDYCgHjgMCWglhYUOVMfnOFNqRTFhbSioKX1atmKLZvKR/iFFH5Sp9lIZUrutFvbB6fyyKqx4IdTc7ZxEBuwYZafuUSe6h4mYtQvPMPfbPX3+N0wLlhYjeiUMJiDC5x+V7CVP6muxuEKzBWsDyl8lP7bwfyAuaVlCX0QvsdNyTLwU/g2fagyHMg0Yd1rJnW/LWCp8OcKc0S2Q2NTCRut72i4jEU0bFwIDAQAB';
- $options->alipayPublicKey = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjkCziKKZaCde/Wyf29S7Z/lvVLcecLQzJa2V6EGCsBbN8GA/kF7dnHPbzps32eurMIysvmhhulAd+D3O/580lQh6cmcUVc3EZ01lfq2Ki+jM2B8EVTyegqS9ADsIVGa//1hJ7i2J2ulgD1Ros5WBZ8rebsd6Qhq/0uJeOksEFA/Fxv209yp+gKnidUozX7ACDalqHp38OeRw0YWRRICyKh1pPkW7n+hj2GElIBPZUc9SWPkNIkCHwExjV1ha6BkrdiBeLrkKjgh1ul6rTG7AeQdtW54nOWmt7caNJ/swnA7zi8n9j/FAzF9tz4mflVCvdOZYO0PCs+Gea4QVYh2X3wIDAQAB';
- // $options->notifyUrl = ''
- return $options;
- }
- /**
- * @return void
- * 构建支付
- */
- public function payment(Request $request){
- $order_id = $request->get('order_id');
- $pay_type = $request->get('pay_type');
- if(!$order_id || !$pay_type){
- return $this->error("缺少参数!");
- }
- $order = UserMemberOrder::query()->where('id',$order_id)->first();
- if(!$order){
- return $this->error("订单不存在!");
- }
- $result = Factory::payment()->common()->create("加入企业会员",$order->order_no,0.01,1);
- dd($result);
- }
- }
|