Added paypal callbacks

This commit is contained in:
2017-07-16 20:29:10 +02:00
parent 649672429d
commit d33b93d115
5 changed files with 105 additions and 12 deletions

37
pages/paypal/success.go Normal file
View File

@ -0,0 +1,37 @@
package paypal
import (
"net/http"
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
)
// Success ...
func Success(ctx *aero.Context) string {
paymentID := ctx.Query("paymentId")
// token := ctx.Query("token")
// payerID := ctx.Query("PayerID")
c, err := arn.PayPal()
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)
}
payment, err := c.GetPayment(paymentID)
if err != nil {
return ctx.Error(http.StatusInternalServerError, "Could not retrieve payment information", err)
}
arn.PrettyPrint(payment)
return ctx.HTML("success")
}