Implemented charge up
This commit is contained in:
@ -101,6 +101,12 @@
|
||||
opacity 0.7
|
||||
margin-top 0.5rem
|
||||
|
||||
&.mountable
|
||||
opacity 0 !important
|
||||
|
||||
&.mounted
|
||||
opacity 0.7 !important
|
||||
|
||||
.relations
|
||||
horizontal-wrap
|
||||
|
||||
|
@ -1,3 +1,29 @@
|
||||
component Charge(user *arn.User)
|
||||
ShopTabs(user)
|
||||
p Coming soon.
|
||||
|
||||
h1.mountable Charge up
|
||||
|
||||
p.text-center.mountable You can charge up your balance via PayPal. 1 USD equals 100 gems.
|
||||
|
||||
.buttons
|
||||
button.action.mountable(data-trigger="click", data-action="chargeUp", data-amount=1000)
|
||||
Icon("diamond")
|
||||
span 1000
|
||||
|
||||
button.action.mountable(data-trigger="click", data-action="chargeUp", data-amount=2000)
|
||||
Icon("diamond")
|
||||
span 2000
|
||||
|
||||
button.action.mountable(data-trigger="click", data-action="chargeUp", data-amount=3000)
|
||||
Icon("diamond")
|
||||
span 3000
|
||||
|
||||
button.action.mountable(data-trigger="click", data-action="chargeUp", data-amount=6000)
|
||||
Icon("diamond")
|
||||
span 6000
|
||||
|
||||
button.action.mountable(data-trigger="click", data-action="chargeUp", data-amount=12000)
|
||||
Icon("diamond")
|
||||
span 12000
|
||||
|
||||
.footer.text-center.mountable You need to enable popup windows in your browser.
|
@ -17,12 +17,24 @@ func CreatePayment(ctx *aero.Context) string {
|
||||
return ctx.Error(http.StatusUnauthorized, "Not logged in", nil)
|
||||
}
|
||||
|
||||
amount := string(ctx.RequestBody())
|
||||
|
||||
// Verify amount
|
||||
switch amount {
|
||||
case "1000", "2000", "3000", "6000", "12000":
|
||||
// OK
|
||||
default:
|
||||
return ctx.Error(http.StatusBadRequest, "Incorrect amount", nil)
|
||||
}
|
||||
|
||||
// Initiate PayPal client
|
||||
c, err := arn.PayPal()
|
||||
|
||||
if err != nil {
|
||||
return ctx.Error(http.StatusInternalServerError, "Could not initiate PayPal client", err)
|
||||
}
|
||||
|
||||
// Get access token
|
||||
_, err = c.GetAccessToken()
|
||||
|
||||
if err != nil {
|
||||
@ -55,6 +67,9 @@ func CreatePayment(ctx *aero.Context) string {
|
||||
// return ctx.Error(http.StatusInternalServerError, "Could not create PayPal web profile", err)
|
||||
// }
|
||||
|
||||
total := amount[:len(amount)-2] + "." + amount[len(amount)-2:]
|
||||
|
||||
// Create payment
|
||||
p := paypalsdk.Payment{
|
||||
Intent: "sale",
|
||||
Payer: &paypalsdk.Payer{
|
||||
@ -63,7 +78,7 @@ func CreatePayment(ctx *aero.Context) string {
|
||||
Transactions: []paypalsdk.Transaction{paypalsdk.Transaction{
|
||||
Amount: &paypalsdk.Amount{
|
||||
Currency: "USD",
|
||||
Total: "10.00",
|
||||
Total: total,
|
||||
},
|
||||
Description: "Top Up Balance",
|
||||
}},
|
||||
|
Reference in New Issue
Block a user