Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
8980117f
authored
Jan 25, 2026
by
mehunk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
docs: Update the comment of the functions.
parent
6a55a413
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
3 deletions
+22
-3
controller/topup_stripe.go
+22
-3
No files found.
controller/topup_stripe.go
View file @
8980117f
...
...
@@ -28,11 +28,18 @@ const (
var
stripeAdaptor
=
&
StripeAdaptor
{}
// StripePayRequest represents a payment request for Stripe checkout.
type
StripePayRequest
struct
{
Amount
int64
`json:"amount"`
// Amount is the quantity of units to purchase.
Amount
int64
`json:"amount"`
// PaymentMethod specifies the payment method (e.g., "stripe").
PaymentMethod
string
`json:"payment_method"`
SuccessURL
string
`json:"success_url,omitempty"`
CancelURL
string
`json:"cancel_url,omitempty"`
// SuccessURL is the optional custom URL to redirect after successful payment.
// If empty, defaults to the server's console log page.
SuccessURL
string
`json:"success_url,omitempty"`
// CancelURL is the optional custom URL to redirect when payment is canceled.
// If empty, defaults to the server's console topup page.
CancelURL
string
`json:"cancel_url,omitempty"`
}
type
StripeAdaptor
struct
{
...
...
@@ -212,6 +219,18 @@ func sessionExpired(event stripe.Event) {
log
.
Println
(
"充值订单已过期"
,
referenceId
)
}
// genStripeLink generates a Stripe Checkout session URL for payment.
// It creates a new checkout session with the specified parameters and returns the payment URL.
//
// Parameters:
// - referenceId: unique reference identifier for the transaction
// - customerId: existing Stripe customer ID (empty string if new customer)
// - email: customer email address for new customer creation
// - amount: quantity of units to purchase
// - successURL: custom URL to redirect after successful payment (empty for default)
// - cancelURL: custom URL to redirect when payment is canceled (empty for default)
//
// Returns the checkout session URL or an error if the session creation fails.
func
genStripeLink
(
referenceId
string
,
customerId
string
,
email
string
,
amount
int64
,
successURL
string
,
cancelURL
string
)
(
string
,
error
)
{
if
!
strings
.
HasPrefix
(
setting
.
StripeApiSecret
,
"sk_"
)
&&
!
strings
.
HasPrefix
(
setting
.
StripeApiSecret
,
"rk_"
)
{
return
""
,
fmt
.
Errorf
(
"无效的Stripe API密钥"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment