Skip to content

adobaai/paypal

Repository files navigation

paypal

A PayPal Golang SDK.

License GitHubRelease BuildWorkflow GoVersion GoDoc GoReportCard CodeFactor Coverage Status Contributors

Usage

package main

import (
	"context"
	"fmt"

	"github.com/adobaai/paypal"
)

func main() {
	ctx := context.Background()
	pc := paypal.NewClient(
		"https://api-m.sandbox.paypal.com",
		os.Getenv("PAYPAL_ID"),
		os.Getenv("PAYPAL_SECRET"),
	)
	order, err := pc.CreateOrder(ctx, &paypal.CreateOrderReq{
		Order: &paypal.Order{
			Intent: paypal.OICapture,
			PurchaseUnits: []*paypal.PurchaseUnit{
				{
					Amount: &paypal.Amount{
						CurrencyCode: "USD",
						Value:        "8.88",
					},
					Description: "Hello order",
				},
			},
		},
	})
	if err != nil {
		panic(err)
	}
	fmt.Println(order)
}

Webhook

See https://developer.paypal.com/api/rest/webhooks/event-names/ or Wayback Machine.

TODO

  • Codecov
  • Dependabot
  • Unit test in GitHub Action
  • Enable secret scanning
  • Enable CodeQL

Other coverage tools