Started implementing PayPal
This commit is contained in:
parent
1a77183737
commit
649672429d
8
main.go
8
main.go
@ -32,6 +32,7 @@ import (
|
||||
"github.com/animenotifier/notify.moe/pages/newsoundtrack"
|
||||
"github.com/animenotifier/notify.moe/pages/newthread"
|
||||
"github.com/animenotifier/notify.moe/pages/notifications"
|
||||
"github.com/animenotifier/notify.moe/pages/paypal"
|
||||
"github.com/animenotifier/notify.moe/pages/posts"
|
||||
"github.com/animenotifier/notify.moe/pages/profile"
|
||||
"github.com/animenotifier/notify.moe/pages/search"
|
||||
@ -76,12 +77,12 @@ func configure(app *aero.Application) *aero.Application {
|
||||
app.Ajax("/forum/:tag", forum.Get)
|
||||
app.Ajax("/thread/:id", threads.Get)
|
||||
app.Ajax("/post/:id", posts.Get)
|
||||
app.Ajax("/track/:id", tracks.Get)
|
||||
app.Ajax("/soundtrack/:id", tracks.Get)
|
||||
app.Ajax("/character/:id", character.Get)
|
||||
app.Ajax("/new/thread", newthread.Get)
|
||||
app.Ajax("/new/soundtrack", newsoundtrack.Get)
|
||||
app.Ajax("/settings", settings.Get)
|
||||
app.Ajax("/music", music.Get)
|
||||
app.Ajax("/soundtracks", music.Get)
|
||||
app.Ajax("/users", users.Get)
|
||||
app.Ajax("/login", login.Get)
|
||||
|
||||
@ -90,7 +91,7 @@ func configure(app *aero.Application) *aero.Application {
|
||||
app.Ajax("/user/:nick", profile.Get)
|
||||
app.Ajax("/user/:nick/threads", profile.GetThreadsByUser)
|
||||
app.Ajax("/user/:nick/posts", profile.GetPostsByUser)
|
||||
app.Ajax("/user/:nick/tracks", profile.GetSoundTracksByUser)
|
||||
app.Ajax("/user/:nick/soundtracks", profile.GetSoundTracksByUser)
|
||||
app.Ajax("/user/:nick/stats", profile.GetStatsByUser)
|
||||
app.Ajax("/user/:nick/animelist", animelist.Get)
|
||||
app.Ajax("/user/:nick/animelist/watching", animelist.FilterByStatus(arn.AnimeListStatusWatching))
|
||||
@ -129,6 +130,7 @@ func configure(app *aero.Application) *aero.Application {
|
||||
|
||||
// API
|
||||
app.Get("/api/test/notification", notifications.Test)
|
||||
app.Get("/api/paypal/payment/create", paypal.CreatePayment)
|
||||
|
||||
// Middleware
|
||||
app.Use(middleware.Log())
|
||||
|
@ -15,7 +15,7 @@ component LoggedOutMenu
|
||||
.extra-navigation
|
||||
NavigationButton("Users", "/users", "globe")
|
||||
|
||||
NavigationButton("Music", "/music", "headphones")
|
||||
NavigationButton("Soundtracks", "/soundtracks", "headphones")
|
||||
|
||||
NavigationButton("Login", "/login", "sign-in")
|
||||
|
||||
@ -29,7 +29,7 @@ component LoggedInMenu(user *arn.User)
|
||||
NavigationButton("Forum", "/forum", "comment")
|
||||
|
||||
.extra-navigation
|
||||
NavigationButton("Music", "/music", "headphones")
|
||||
NavigationButton("Soundtracks", "/soundtracks", "headphones")
|
||||
|
||||
FuzzySearch
|
||||
|
||||
|
41
pages/paypal/paypal.go
Normal file
41
pages/paypal/paypal.go
Normal file
@ -0,0 +1,41 @@
|
||||
package paypal
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/logpacker/PayPal-Go-SDK"
|
||||
)
|
||||
|
||||
// CreatePayment ...
|
||||
func CreatePayment(ctx *aero.Context) string {
|
||||
// Create a client instance
|
||||
c, err := paypalsdk.NewClient("clientID", "secretID", paypalsdk.APIBaseSandBox)
|
||||
c.SetLog(os.Stdout) // Set log to terminal stdout
|
||||
|
||||
if err != nil {
|
||||
return ctx.Error(http.StatusInternalServerError, "Could not initiate PayPal client", err)
|
||||
}
|
||||
|
||||
_, err = c.GetAccessToken()
|
||||
|
||||
if err != nil {
|
||||
return ctx.Error(http.StatusInternalServerError, "Could not get PayPal access token", err)
|
||||
}
|
||||
|
||||
amount := paypalsdk.Amount{
|
||||
Total: "7.00",
|
||||
Currency: "USD",
|
||||
}
|
||||
redirectURI := "http://example.com/redirect-uri"
|
||||
cancelURI := "http://example.com/cancel-uri"
|
||||
description := "Description for this payment"
|
||||
paymentResult, err := c.CreateDirectPaypalPayment(amount, redirectURI, cancelURI, description)
|
||||
|
||||
if err != nil {
|
||||
return ctx.Error(http.StatusInternalServerError, "Could not create PayPal payment", err)
|
||||
}
|
||||
|
||||
return ctx.JSON(paymentResult)
|
||||
}
|
@ -64,7 +64,7 @@ component ProfileNavigation(viewUser *arn.User, uri string)
|
||||
Icon("comments")
|
||||
span.tab-text Posts
|
||||
|
||||
a.button.tab.action(href="/+" + viewUser.Nick + "/tracks", data-action="diff", data-trigger="click")
|
||||
a.button.tab.action(href="/+" + viewUser.Nick + "/soundtracks", data-action="diff", data-trigger="click")
|
||||
Icon("music")
|
||||
span.tab-text Tracks
|
||||
|
||||
|
@ -194,7 +194,7 @@ export function createSoundTrack(arn: AnimeNotifier, button: HTMLButtonElement)
|
||||
}
|
||||
|
||||
arn.post("/api/new/soundtrack", soundtrack)
|
||||
.then(() => arn.app.load("/music"))
|
||||
.then(() => arn.app.load("/soundtracks"))
|
||||
.catch(err => arn.statusMessage.showError(err))
|
||||
}
|
||||
|
||||
|
9
tests.go
9
tests.go
@ -22,8 +22,8 @@ var routeTests = map[string][]string{
|
||||
"/+Akyoto/posts",
|
||||
},
|
||||
|
||||
"/user/:nick/tracks": []string{
|
||||
"/+Akyoto/tracks",
|
||||
"/user/:nick/soundtracks": []string{
|
||||
"/+Akyoto/soundtracks",
|
||||
},
|
||||
|
||||
"/user/:nick/animelist": []string{
|
||||
@ -75,8 +75,8 @@ var routeTests = map[string][]string{
|
||||
"/search/Dragon Ball",
|
||||
},
|
||||
|
||||
"/track/:id": []string{
|
||||
"/track/h0ac8sKkg",
|
||||
"/soundtrack/:id": []string{
|
||||
"/soundtrack/h0ac8sKkg",
|
||||
},
|
||||
|
||||
// API
|
||||
@ -186,6 +186,7 @@ var routeTests = map[string][]string{
|
||||
"/import/kitsu/animelist": nil,
|
||||
"/import/kitsu/animelist/finish": nil,
|
||||
"/api/test/notification": nil,
|
||||
"/api/paypal/payment/create": nil,
|
||||
"/anime/:id/edit": nil,
|
||||
"/new/thread": nil,
|
||||
"/new/soundtrack": nil,
|
||||
|
Loading…
Reference in New Issue
Block a user