Toggle navigation
Toggle navigation
This project
Loading...
Sign in
OnePoem
/
OnePoem-Server
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
李帅
2022-03-25 18:16:24 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
3c1c31bb7782c2c02ce477e67cb18b370817eb49
3c1c31bb
1 parent
bdf20273
1.todo paypal
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
78 additions
and
6 deletions
app/Admin/Controllers/AdminMakeVideoController.php
app/Http/Controllers/V1/HomeController.php
app/Http/Controllers/V1/UserController.php
app/Payment/PaymentFactory.php
app/Payment/PaypalPayment.php
config/response.php
app/Admin/Controllers/AdminMakeVideoController.php
View file @
3c1c31b
...
...
@@ -95,6 +95,7 @@ class AdminMakeVideoController extends AdminController
->
when
(
1
,
function
(
Form
$form
){
$form
->
file
(
'video_url'
,
'上传视频'
)
// ->accept('mp4,mov')
->
chunked
()
->
autoUpload
()
->
uniqueName
()
->
maxSize
(
'128000'
)
...
...
app/Http/Controllers/V1/HomeController.php
View file @
3c1c31b
...
...
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\V1;
use
App\Http\Controllers\Controller
;
use
App\Models\PackPoem
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\Validator
;
use
Jiannei\Response\Laravel\Support\Facades\Response
;
class
HomeController
extends
Controller
...
...
@@ -23,7 +24,9 @@ class HomeController extends Controller
public
function
packpoem
(
Request
$request
)
{
$packpoems
=
PackPoem
::
query
()
->
where
(
'state'
,
0
)
->
paginate
(
0
);
$packpoems
=
PackPoem
::
query
()
->
where
(
'state'
,
0
)
->
orderByDesc
(
'id'
)
->
simplePaginate
(
intval
(
$request
->
per_page
));
return
Response
::
success
(
$packpoems
);
}
...
...
app/Http/Controllers/V1/UserController.php
View file @
3c1c31b
...
...
@@ -22,7 +22,7 @@ class UserController extends Controller
public
function
login
(
Request
$request
)
{
$validator
=
Validator
::
make
(
$request
->
all
(),
[
'email'
=>
'required|max:255'
,
'email'
=>
'required|
email|
max:255'
,
'password'
=>
'required'
,
]);
...
...
@@ -51,7 +51,7 @@ class UserController extends Controller
public
function
register
(
Request
$request
)
{
$validator
=
Validator
::
make
(
$request
->
all
(),
[
'email'
=>
'required|unique:users|max:255'
,
'email'
=>
'required|
email|
unique:users|max:255'
,
'password'
=>
'required'
,
'verify_code'
=>
'required'
]);
...
...
@@ -84,7 +84,7 @@ class UserController extends Controller
public
function
verify
(
Request
$request
)
{
$validator
=
Validator
::
make
(
$request
->
all
(),
[
'email'
=>
'required|max:255'
,
'email'
=>
'required|
email|
max:255'
,
]);
if
(
$validator
->
fails
()){
...
...
app/Payment/PaymentFactory.php
View file @
3c1c31b
...
...
@@ -17,6 +17,8 @@ class PaymentFactory
return
new
AliPayment
();
case
'wechat'
:
return
new
WechatPayment
();
case
'paypal'
:
return
new
PayPalPayment
();
default
:
throw
new
\Exception
(
'未知的支付方式'
);
}
...
...
app/Payment/PaypalPayment.php
0 → 100644
View file @
3c1c31b
<?php
/**
* Created by PhpStorm.
* User: lishuai
* Date: 2022/2/15
* Time: 4:23 PM
*/
namespace
App\Payment
;
use
App\Models\Order
;
use
GuzzleHttp\Client
;
use
Illuminate\Support\Facades\Redis
;
class
PaypalPayment
implements
PaymentInterface
{
const
IS_SANDBOX
=
true
;
public
$authUrl
=
'https://api-m.sandbox.paypal.com/v1/oauth2/token'
;
public
$paySandboxUrl
=
'https://api-m.sandbox.paypal.com'
;
public
$payUrl
=
'https://api-m.paypal.com'
;
public
$clientId
=
'AdDRE91WSp5q1fYLODpJduc2mRjA_v6E205SvkfVSOgvr98xLeyDCHY4OPAaSFMK1SHYOfJ4TksHSX1-'
;
public
$secret
=
'EDoy_PVrFyobWt9DzAMRMikJwWCXenkWSx9CGFz0MxHt3a8fs6v-LnORMilIbftb2GwBKxOoTVZNBHNR'
;
/** 访问令牌*/
public
$accessToken
;
public
function
__construct
()
{
// 初始化时做一些准备工作
$redis
=
Redis
::
connection
();
$access_token
=
$redis
->
get
(
'paypal:access_token'
);
if
(
$access_token
){
$this
->
accessToken
=
$access_token
;
}
else
{
$client
=
new
Client
([
'headers'
=>
[
'Content-Type'
=>
'application/x-www-form-urlencoded'
,
'Accept'
=>
'application/json'
,
]
]);
$response
=
$client
->
post
(
$this
->
authUrl
,[
'form_params'
=>
[
'grant_type'
=>
'client_credentials'
],
'auth'
=>
[
$this
->
clientId
,
$this
->
secret
],
]);
$body
=
$response
->
getBody
();
$content
=
json_decode
(
$body
->
getContents
(),
true
);
$this
->
accessToken
=
$content
[
'access_token'
];
$redis
->
setex
(
'paypal:access_token'
,
$content
[
'expires_in'
],
$content
[
'access_token'
]);
}
}
public
function
prepare
(
Order
$order
)
{
// 在PayPal上创建一个订单,它会返回一个订单对象,它有一个订单id
return
$this
->
accessToken
;
}
}
\ No newline at end of file
config/response.php
View file @
3c1c31b
...
...
@@ -81,10 +81,10 @@ return [
'count'
=>
[
'alias'
=>
'count'
,
'show'
=>
true
],
'per_page'
=>
[
'alias'
=>
'per_page'
,
'show'
=>
true
],
'current_page'
=>
[
'alias'
=>
'current_page'
,
'show'
=>
true
],
'total_pages'
=>
[
'alias'
=>
'total_pages'
,
'show'
=>
tru
e
],
'total_pages'
=>
[
'alias'
=>
'total_pages'
,
'show'
=>
fals
e
],
'links'
=>
[
'alias'
=>
'links'
,
'show'
=>
tru
e
,
'show'
=>
fals
e
,
'fields'
=>
[
'previous'
=>
[
'alias'
=>
'previous'
,
'show'
=>
true
],
...
...
Please
register
or
login
to post a comment