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-05-31 23:28:47 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d466adcde5c7356b9071313aaba36d4183c14822
d466adcd
1 parent
77513cf3
1.打印paypal token
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
28 deletions
app/Http/Controllers/V1/PayController.php
app/Payment/PaypalPayment.php
app/Http/Controllers/V1/PayController.php
View file @
d466adc
...
...
@@ -20,7 +20,7 @@ class PayController extends Controller
$order
=
Order
::
query
()
->
where
(
'order_sn'
,
$order_sn
)
->
first
();
if
(
$order
->
status
!=
=
Order
::
UNPAID
)
return
false
;
if
(
$order
->
status
!=
Order
::
UNPAID
)
return
Response
::
fail
(
'订单错误!'
)
;
// if ($order->pay_amount <= 0) return $this->paid($order_sn); 0元购应该单独写一套
...
...
app/Payment/PaypalPayment.php
View file @
d466adc
...
...
@@ -35,33 +35,27 @@ class PaypalPayment implements PaymentInterface
public
function
__construct
()
{
try
{
// 初始化时做一些准备工作
$redis
=
Redis
::
connection
();
$access_token
=
$redis
->
get
(
'paypal:access_token'
);
if
(
$access_token
){
Log
::
channel
(
'daily'
)
->
debug
(
$access_token
);
$this
->
accessToken
=
$access_token
;
}
else
{
$client
=
new
Client
([
'base_uri'
=>
$this
->
baseUrlSandbox
,
'headers'
=>
[
'Content-Type'
=>
'application/x-www-form-urlencoded'
,
'Accept'
=>
'application/json'
,
]
]);
$response
=
$client
->
post
(
'/v1/oauth2/token'
,[
'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'
];
Log
::
channel
(
'daily'
)
->
debug
(
$content
[
'access_token'
]);
$redis
->
setex
(
'paypal:access_token'
,
$content
[
'expires_in'
],
$content
[
'access_token'
]);
}
}
catch
(
\Exception
$exception
){
Log
::
channel
(
'daily'
)
->
error
(
$exception
->
getMessage
());
// 初始化时做一些准备工作
$redis
=
Redis
::
connection
();
$access_token
=
$redis
->
get
(
'paypal:access_token'
);
if
(
$access_token
){
$this
->
accessToken
=
$access_token
;
}
else
{
$client
=
new
Client
([
'base_uri'
=>
$this
->
baseUrlSandbox
,
'headers'
=>
[
'Content-Type'
=>
'application/x-www-form-urlencoded'
,
'Accept'
=>
'application/json'
,
]
]);
$response
=
$client
->
post
(
'/v1/oauth2/token'
,[
'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'
]);
}
}
...
...
Please
register
or
login
to post a comment