A small project that collects various nice things to get started with Go Web Development.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.0 KiB

package features_paypal
import (
"github.com/gofiber/fiber/v2"
"net/http"
"net/http/httptest"
mockserver "github.com/plutov/paypal/v4/mockserver"
srvPayouts "github.com/plutov/paypal/v4/mockserver/payments_payouts_batch_v1"
srvShipping "github.com/plutov/paypal/v4/mockserver/shipping_shipment_tracking_v1"
"MY/webapp/config"
)
var PAYPAL *httptest.Server = nil
func createTestServer() *httptest.Server {
mock := &mockserver.MockServer{}
mux := http.NewServeMux()
payoutsSI := srvPayouts.NewStrictHandler(mock, nil)
srvPayouts.HandlerWithOptions(payoutsSI, srvPayouts.StdHTTPServerOptions{
BaseRouter: mux,
})
shippingSI := srvShipping.NewStrictHandler(mock, nil)
srvShipping.HandlerWithOptions(shippingSI, srvShipping.StdHTTPServerOptions{
BaseRouter: mux,
})
return httptest.NewServer(mux)
}
func Setup(app *fiber.App) {
// if you don't set the URL then use a fake mock
if config.Settings.Paypal.URL == "" {
PAYPAL = createTestServer()
config.Settings.Paypal.URL = PAYPAL.URL
}
SetupApi(app)
SetupViews(app)
}