{"id":15562362,"url":"https://github.com/mohammadv184/gopayment","last_synced_at":"2025-04-23T23:07:34.259Z","repository":{"id":43127083,"uuid":"437104106","full_name":"mohammadv184/gopayment","owner":"mohammadv184","description":"multi gateway payment package for Golang","archived":false,"fork":false,"pushed_at":"2023-12-31T22:07:04.000Z","size":201,"stargazers_count":24,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-23T23:07:11.864Z","etag":null,"topics":["go","golang","payment","payment-gateway","payments"],"latest_commit_sha":null,"homepage":"https://mohammad-abbasi.me/gopayment","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/mohammadv184.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-12-10T20:21:34.000Z","updated_at":"2025-04-14T08:55:03.000Z","dependencies_parsed_at":"2023-12-31T23:18:33.124Z","dependency_job_id":"b653b778-4910-4c8e-8181-fcb86cf6061d","html_url":"https://github.com/mohammadv184/gopayment","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohammadv184%2Fgopayment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohammadv184%2Fgopayment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohammadv184%2Fgopayment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohammadv184%2Fgopayment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mohammadv184","download_url":"https://codeload.github.com/mohammadv184/gopayment/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250528731,"owners_count":21445516,"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":["go","golang","payment","payment-gateway","payments"],"created_at":"2024-10-02T16:13:50.955Z","updated_at":"2025-04-23T23:07:34.241Z","avatar_url":"https://github.com/mohammadv184.png","language":"Go","funding_links":["http://www.paypal.com/"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003cimg src=\"golang-logo.png?raw=true\"\u003e\u003c/p\u003e\r\n\r\n\r\n# GoPayment\r\n\r\n[![Go Reference](https://pkg.go.dev/badge/github.com/mohammadv184/gopayment.svg)](https://pkg.go.dev/github.com/mohammadv184/gopayment)\r\n[![GitHub license](https://img.shields.io/github/license/mohammadv184/gopayment)](https://github.com/mohammadv184/gopayment/blob/main/LICENSE)\r\n[![GitHub issues](https://img.shields.io/github/issues/mohammadv184/gopayment)](https://github.com/mohammadv184/gopayment/issues)\r\n[![codecov](https://codecov.io/gh/mohammadv184/gopayment/branch/main/graph/badge.svg?token=VO7KKJTIU2)](https://codecov.io/gh/mohammadv184/gopayment)\r\n[![Go Report Card](https://goreportcard.com/badge/github.com/mohammadv184/gopayment)](https://goreportcard.com/report/github.com/mohammadv184/gopayment)\r\n[![Build Status](https://app.travis-ci.com/mohammadv184/gopayment.svg?branch=main)](https://app.travis-ci.com/mohammadv184/gopayment)\r\n\r\nMulti Gateway Payment Package for Golang.\r\n\r\n# List of contents\r\n\r\n- [GoPayment](#gopayment)\r\n- [List of contents](#list-of-contents)\r\n- [List of available drivers](#list-of-available-drivers)\r\n    - [Installation](#Installation)\r\n    - [How to use](#how-to-use)\r\n        - [Purchase](#purchase)\r\n        - [Pay](#pay)\r\n        - [Verify payment](#verify-payment)\r\n        - [Working with invoices](#working-with-invoices)\r\n        - [Working with receipts](#working-with-receipts)\r\n        - [Example](#example)\r\n- [Contributing](#contributing)\r\n- [Security](#security)\r\n- [Credits](#credits)\r\n- [License](#license)\r\n\r\n# List of available drivers\r\n- [zarinpal](https://www.zarinpal.com/) :white_check_mark:\r\n- [payping](https://www.payping.ir/) :white_check_mark:\r\n- [asanpardakht](https://asanpardakht.ir/) :white_check_mark:\r\n- [behpardakht (mellat)](http://www.behpardakht.com/) :x: (will be added soon)\r\n- [digipay](https://www.mydigipay.com/) :x: (will be added soon)\r\n- [etebarino (Installment payment)](https://etebarino.com/) :x: (will be added soon)\r\n- [sepehr (saderat)](https://www.sepehrpay.com/) :x: (will be added soon)\r\n- [idpay](https://idpay.ir/) :white_check_mark:\r\n- [poolam](https://poolam.ir/) :x: (will be added soon)\r\n- [irankish](http://irankish.com/) :x: (will be added soon)\r\n- [nextpay](https://nextpay.ir/) :x: (will be added soon)\r\n- [parsian](https://www.pec.ir/) :x: (will be added soon)\r\n- [pasargad](https://bpi.ir/) :x: (will be added soon)\r\n- [payir](https://pay.ir/) :x: (will be added soon)\r\n- [paystar](http://paystar.ir/) :x: (will be added soon)\r\n- [sadad (melli)](https://sadadpsp.ir/) :x: (will be added soon)\r\n- [saman](https://www.sep.ir) :x: (will be added soon)\r\n- [walleta (Installment payment)](https://walleta.ir/) :x: (will be added soon)\r\n- [yekpay](https://yekpay.com/) :x: (will be added soon)\r\n- [zibal](https://www.zibal.ir/) :white_check_mark:\r\n- [sepordeh](https://sepordeh.com/) :x: (will be added soon)\r\n- [paypal](http://www.paypal.com/) :x: (will be added soon)\r\n- **Help me to add the other gateways by creating `pull requests`**\r\n\r\n## Installation\r\n\r\n```\r\ngo get -u github.com/mohammadv184/gopayment\r\n```\r\n\r\n## How to use\r\n\r\n\r\n#### Purchase\r\nIn order to pay the invoice, we need the payment transactionId.\r\nWe purchase the invoice to retrieve transaction id:\r\n```go\r\n// Configure the Gateway Driver\r\ngateway:=\u0026payping.Driver{\r\nCallback:    \"http://example.test/callback\",\r\nToken:       \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\",\r\n}\r\n// Create new Payment.\r\npayment := gopayment.NewPayment(gateway)\r\n// Set Invoice Amount.\r\npayment.Amount(amountInt)\r\n// Set Invoice Description.\r\npayment.Description(\"description\")\r\n// Purchase the invoice.\r\nerr = payment.Purchase()\r\nif err != nil {\r\n    fmt.Println(err)\r\n}\r\n// Get Transaction ID\r\ntransactionID := payment.GetTransactionID()\r\n```\r\n#### Pay\r\nAfter purchasing the invoice, we can redirect the user to the bank payment page:\r\n```go\r\nfunc pay() gin.HandlerFunc {\r\n    return func(c *gin.Context) {\r\n        // Configure the Gateway Driver\r\n        gateway:=\u0026payping.Driver{\r\n        Callback:    \"http://example.test/callback\",\r\n        Token:       \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\",\r\n        }\r\n        // Create new Payment.\r\n        payment := gopayment.NewPayment(gateway)\r\n        // Set Invoice Amount.\r\n\t\tpayment.Amount(amountInt)\r\n\t\t// Set Invoice Description.\r\n\t\tpayment.Description(\"description\")\r\n\t\t// Purchase the invoice.\r\n        err = payment.Purchase()\r\n        if err != nil {\r\n            fmt.Println(err)\r\n        }\r\n        // Get Transaction ID And Save it to the database.\r\n        transactionID := payment.GetTransactionID()\r\n        // Redirect the user to the bank payment page.\r\n        payUrl := payment.PayURL()\r\n\t\tc.Redirect(http.StatusFound, payUrl)\r\n\t}\r\n}\r\n\r\n```\r\n#### Verify payment\r\n\r\nWhen user has completed the payment, the bank redirects them to your website, then you need to **verify your payment** to make sure that the payment is valid.:\r\n```go\r\n// Configure the Gateway Driver\r\ngateway:=\u0026payping.Driver{\r\nCallback:    \"http://example.test/callback\",\r\nToken:       \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\",\r\n}\r\n\r\nrefId := c.Query(\"refId\")\r\nVerifyRequest:=\u0026payping.VerifyRequest{\r\nAmount: \"100\",\r\nRefID:  refID,\r\n}\r\n\r\nif receipt, err := gateway.Verify(VerifyRequest); err == nil {\r\n\r\nc.JSON(200, gin.H{\r\n\"status\": \"success\",\r\n\"data\":   receipt.GetReferenceID(),\r\n\"date\":   receipt.GetDate().String(),\r\n\"card\":   receipt.GetDetail(\"cardNumber\"),\r\n\"gateway\": receipt.GetDriver(),\r\n})\r\n} else {\r\nc.JSON(200, gin.H{\r\n\"message\": \"error \" + err.Error(),\r\n})\r\n}\r\n```\r\n#### Working with invoices\r\n\r\nWhen you make a payment, the invoice is automatically generated within the payment\r\n\r\n\r\nIn your code, use it like the below:\r\n```go\r\n// Create new Payment.\r\npayment := gopayment.NewPayment(gateway)\r\n// Get the invoice.\r\ninvoice:=payment.GetInvoice()\r\n// Set Invoice Amount.\r\ninvoice.SetAmount(1000)\r\n// Set Invoice Description.\r\ninvoice.SetDescription(\"description\")\r\n// Set Invoice Deatils.\r\ninvoice.Detail(\"phone\",\"0912345678\")\r\ninvoice.Detail(\"email\",\"example@example.com\")\r\n\r\n```\r\nAvailable methods:\r\n\r\n- `SetUuid`: set the invoice unique id\r\n- `GetUuid`: retrieve the invoice current unique id\r\n- `Detail`: attach some custom details into invoice\r\n- `GetDetail`: retrieve the invoice detail\r\n- `GetDetails`: retrieve all custom details\r\n- `SetAmount`: set the invoice amount\r\n- `GetAmount`: retrieve invoice amount\r\n- `SetTransactionID`: set invoice payment transaction id\r\n- `GetTransactionID`: retrieve payment transaction id\r\n- `SetDescription`: set invoice Description\r\n- `GetDescription`: retrieve payment Description\r\n#### Working with receipts\r\n\r\nWhen you verify a payment, the receipt is automatically generated.\r\n\r\n\r\nIn your code, use it like the below:\r\n```go\r\n// Verify the Payment.\r\nreceipt := gateway.verify(...)\r\n// Get the Payment Reference ID.\r\nrefId := receipt.GetReferenceID()\r\n// Get the payment date .\r\npaymentDate:=receipt.GetDate()\r\n// Get the payment driver name.\r\npaymentDriver:=receipt.GetDriver()\r\n// Get payment Deatils.\r\ncardNum:=receipt.GetDetail(\"cardNumber\")\r\ncardHNum:=receipt.GetDetail(\"HashedCardNumber\")\r\n\r\n\r\n```\r\nAvailable methods:\r\n\r\n- `GetReferenceID`: retrieve the payment reference id\r\n- `GetDriver`: retrieve the payment driver name\r\n- `Detail`: attach some custom details into invoice\r\n- `GetDate`: retrieve payment date\r\n- `GetDetail`: retrieve the invoice detail\r\n- `GetDetails`: retrieve all custom details\r\n#### Example\r\nThere is an example project using GoPayment you can find at [GoPayment-Example](https://github.com/mohammadv184/gopayment-example) Repo It contains a payment implementation.\r\n## Contributing\r\n\r\nPlease see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.\r\n## Security\r\n\r\nIf you discover any security related issues, please email mohammadv184@gmail.com instead of using the issue tracker.\r\n\r\n## Credits\r\n\r\n- [Mohammad Abbasi](https://github.com/mohammadv184)\r\n- [All Contributors](../../contributors)\r\n\r\n## License\r\n\r\nThe MIT License (MIT). Please see [License File](LICENSE) for more information.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohammadv184%2Fgopayment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmohammadv184%2Fgopayment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohammadv184%2Fgopayment/lists"}