{"id":13414073,"url":"https://github.com/plutov/paypal","last_synced_at":"2025-05-15T00:09:50.653Z","repository":{"id":37027284,"uuid":"44224873","full_name":"plutov/paypal","owner":"plutov","description":"Golang client for PayPal REST API","archived":false,"fork":false,"pushed_at":"2025-05-03T19:14:40.000Z","size":389,"stargazers_count":721,"open_issues_count":1,"forks_count":284,"subscribers_count":29,"default_branch":"master","last_synced_at":"2025-05-03T19:36:19.019Z","etag":null,"topics":["hacktoberfest"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/plutov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-10-14T04:57:49.000Z","updated_at":"2025-05-03T19:12:37.000Z","dependencies_parsed_at":"2023-07-13T23:52:38.828Z","dependency_job_id":"c3e9dc30-af63-409e-8595-82eddf94a2d8","html_url":"https://github.com/plutov/paypal","commit_stats":{"total_commits":287,"total_committers":88,"mean_commits":"3.2613636363636362","dds":0.7526132404181185,"last_synced_commit":"3713084b64e9c7c20291706b85730871aeb0da65"},"previous_names":["logpacker/paypal-go-sdk","plutov/paypal-go-sdk","logpacker/paypalsdk"],"tags_count":66,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plutov%2Fpaypal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plutov%2Fpaypal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plutov%2Fpaypal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plutov%2Fpaypal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/plutov","download_url":"https://codeload.github.com/plutov/paypal/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254249206,"owners_count":22039029,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest"],"created_at":"2024-07-30T20:01:56.912Z","updated_at":"2025-05-15T00:09:45.631Z","avatar_url":"https://github.com/plutov.png","language":"Go","funding_links":["https://developer.paypal.com/api/rest/","https://api-m.sandbox.paypal.com/v2/invoicing/invoices?total_required=true"],"categories":["Go","Third-party APIs","Utility"],"sub_categories":["Utility/Miscellaneous","Fail injection"],"readme":"[Docs](https://pkg.go.dev/github.com/plutov/paypal)\n\n\u003cp\u003e\n    \u003ca href=\"https://github.com/plutov/paypal/releases\"\u003e\u003cimg src=\"https://img.shields.io/github/release/plutov/paypal.svg\" alt=\"Latest Release\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://pkg.go.dev/github.com/plutov/paypal?tab=doc\"\u003e\u003cimg src=\"https://godoc.org/github.com/golang/gddo?status.svg\" alt=\"GoDoc\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n# Go client for PayPal REST API\n\n## Paypal REST API Docs\n\n[Get started with PayPal REST APIs](https://developer.paypal.com/api/rest/)\n\n## Missing endpoints\n\nIt is possible that some endpoints are missing in this client, but you can use built-in `paypal` functions to perform a request: `NewClient -\u003e NewRequest -\u003e SendWithAuth`\n\n## Usage\n\n```go\nimport \"github.com/plutov/paypal/v4\"\n\n// Create a client instance\nc, err := paypal.NewClient(\"clientID\", \"secretID\", paypal.APIBaseSandBox)\nc.SetLog(os.Stdout) // Set log to terminal stdout\n```\n\n## Get authorization by ID\n\n```go\nauth, err := c.GetAuthorization(\"2DC87612EK520411B\")\n```\n\n### Capture authorization\n\n```go\ncapture, err := c.CaptureAuthorization(authID, \u0026paypal.Amount{Total: \"7.00\", Currency: \"USD\"}, true)\n```\n\n### Void authorization\n\n```go\nauth, err := c.VoidAuthorization(authID)\n```\n\n### Reauthorize authorization\n\n```go\nauth, err := c.ReauthorizeAuthorization(authID, \u0026paypal.Amount{Total: \"7.00\", Currency: \"USD\"})\n```\n\n### Get Refund by ID\n\n```go\nrefund, err := c.GetRefund(\"O-4J082351X3132253H\")\n```\n\n### Get Order by ID\n\n```go\norder, err := c.GetOrder(\"O-4J082351X3132253H\")\n```\n\n### Create an Order\n\n```go\nctx := context.Background()\nunits := []paypal.PurchaseUnitRequest{}\nsource := \u0026paypal.PaymentSource{}\nappCtx := \u0026paypal.ApplicationContext{}\norder, err := c.CreateOrder(ctx, paypal.OrderIntentCapture, units, ource, appCtx)\n```\n\n### Update Order by ID\n\n```go\norder, err := c.UpdateOrder(\"O-4J082351X3132253H\", []paypal.PurchaseUnitRequest{})\n```\n\n### Authorize Order\n\n```go\nauth, err := c.AuthorizeOrder(orderID, paypal.AuthorizeOrderRequest{})\n```\n\n### Capture Order\n\n```go\ncapture, err := c.CaptureOrder(orderID, paypal.CaptureOrderRequest{})\n```\n\n### Identity\n\n```go\ntoken, err := c.GrantNewAccessTokenFromAuthCode(\"\u003cAuthorization-Code\u003e\", \"http://example.com/myapp/return.php\")\n// ... or by refresh token\ntoken, err := c.GrantNewAccessTokenFromRefreshToken(\"\u003cRefresh-Token\u003e\")\n```\n\n### Retreive user information\n\n```go\nuserInfo, err := c.GetUserInfo(\"openid\")\n```\n\n### Create single payout to email\n\n```go\npayout := paypal.Payout{\n    SenderBatchHeader: \u0026paypal.SenderBatchHeader{\n        EmailSubject: \"Subject will be displayed on PayPal\",\n    },\n    Items: []paypal.PayoutItem{\n        paypal.PayoutItem{\n            RecipientType: \"EMAIL\",\n            Receiver:      \"single-email-payout@mail.com\",\n            Amount: \u0026paypal.AmountPayout{\n                Value:    \"15.11\",\n                Currency: \"USD\",\n            },\n            Note:         \"Optional note\",\n            SenderItemID: \"Optional Item ID\",\n        },\n    },\n}\n\npayoutResp, err := c.CreatePayout(payout)\n```\n\n### Get payout by ID\n\n```go\npayout, err := c.GetPayout(\"PayoutBatchID\")\n```\n\n### Get payout item by ID\n\n```go\npayoutItem, err := c.GetPayoutItem(\"PayoutItemID\")\n```\n\n### Cancel unclaimed payout item by ID\n\n```go\npayoutItem, err := c.CancelPayoutItem(\"PayoutItemID\")\n```\n\n### Create web experience profile\n\n```go\nwebprofile := WebProfile{\n    Name: \"YeowZa! T-Shirt Shop\",\n    Presentation: Presentation{\n        BrandName:  \"YeowZa! Paypal\",\n        LogoImage:  \"http://www.yeowza.com\",\n        LocaleCode: \"US\",\n    },\n\n    InputFields: InputFields{\n        AllowNote:       true,\n        NoShipping:      NoShippingDisplay,\n        AddressOverride: AddrOverrideFromCall,\n    },\n\n    FlowConfig: FlowConfig{\n        LandingPageType:   LandingPageTypeBilling,\n        BankTXNPendingURL: \"http://www.yeowza.com\",\n    },\n}\n\nresult, err := c.CreateWebProfile(webprofile)\n```\n\n### Get web experience profile\n\n```go\nwebprofile, err := c.GetWebProfile(\"XP-CP6S-W9DY-96H8-MVN2\")\n```\n\n### List web experience profile\n\n```go\nwebprofiles, err := c.GetWebProfiles()\n```\n\n### Update web experience profile\n\n```go\nwebprofile := WebProfile{\n    ID: \"XP-CP6S-W9DY-96H8-MVN2\",\n    Name: \"Shop YeowZa! YeowZa! \",\n}\nerr := c.SetWebProfile(webprofile)\n```\n\n### Delete web experience profile\n\n```go\nerr := c.DeleteWebProfile(\"XP-CP6S-W9DY-96H8-MVN2\")\n```\n\n### Vault\n\n```go\n// Store CC\nc.StoreCreditCard(paypal.CreditCard{\n    Number:      \"4417119669820331\",\n    Type:        \"visa\",\n    ExpireMonth: \"11\",\n    ExpireYear:  \"2020\",\n    CVV2:        \"874\",\n    FirstName:   \"Foo\",\n    LastName:    \"Bar\",\n})\n\n// Delete it\nc.DeleteCreditCard(\"CARD-ID-123\")\n\n// Edit it\nc.PatchCreditCard(\"CARD-ID-123\", []paypal.CreditCardField{\n    paypal.CreditCardField{\n        Operation: \"replace\",\n        Path:      \"/billing_address/line1\",\n        Value:     \"New value\",\n    },\n})\n\n// Get it\nc.GetCreditCard(\"CARD-ID-123\")\n\n// Get all stored credit cards\nc.GetCreditCards(nil)\n```\n\n### Webhooks\n\n```go\n// Create a webhook\nc.CreateWebhook(paypal.CreateWebhookRequest{\n    URL: \"webhook URL\",\n    EventTypes: []paypal.WebhookEventType{\n        paypal.WebhookEventType{\n            Name: \"PAYMENT.AUTHORIZATION.CREATED\",\n        },\n    },\n})\n\n// Update a registered webhook\nc.UpdateWebhook(\"WebhookID\", []paypal.WebhookField{\n    paypal.WebhookField{\n        Operation: \"replace\",\n        Path:      \"/event_types\",\n        Value: []interface{}{\n            map[string]interface{}{\n                \"name\": \"PAYMENT.SALE.REFUNDED\",\n            },\n        },\n    },\n})\n\n// Get a registered webhook\nc.GetWebhook(\"WebhookID\")\n\n// Delete a webhook\nc.DeleteWebhook(\"WebhookID\")\n\n// List registered webhooks\nc.ListWebhooks(paypal.AncorTypeApplication)\n```\n\n### Generate Next Invoice Number\n\n```go\n// GenerateInvoiceNumber: generates the next invoice number that is available to the merchant.\nc.GenerateInvoiceNumber(ctx) // might return something like \"0001\" or \"0010\".\n```\n\n### Get Invoice Details by ID\n\n```go\n// the second argument is an ID, it should be valid\ninvoice, err := c.GetInvoiceDetails(ctx, \"INV2-XFXV-YW42-ZANU-4F33\")\n```\n\n- for now, we are yet to implement the ShowAllInvoices endpoint, so use the following cURL request for the same(this gives you the list of invoice-IDs for this customer)\n\n  ```bash\n  curl -v -X GET https://api-m.sandbox.paypal.com/v2/invoicing/invoices?total_required=true \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Authorization: Bearer \u003cToken\u003e\"\n  ```\n\n- refer to the beginning of this Usage section for obtaining a Token.\n\n## How to Contribute\n\n- Fork a repository\n- Add/Fix something\n- Check that tests are passing\n- Create PR\n\nMain contributors:\n\n- [Alex Pliutau](https://github.com/plutov)\n- [Roopak Venkatakrishnan](https://github.com/roopakv)\n\n## Tests\n\n```\ngo test -v ./...\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplutov%2Fpaypal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplutov%2Fpaypal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplutov%2Fpaypal/lists"}