-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from paylike/feature/implementation
Initial implementation
- Loading branch information
Showing
7 changed files
with
1,411 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,5 @@ | |
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
vendor |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Gopkg.toml example | ||
# | ||
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html | ||
# for detailed Gopkg.toml documentation. | ||
# | ||
# required = ["github.com/user/thing/cmd/thing"] | ||
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] | ||
# | ||
# [[constraint]] | ||
# name = "github.com/user/project" | ||
# version = "1.0.0" | ||
# | ||
# [[constraint]] | ||
# name = "github.com/user/project2" | ||
# branch = "dev" | ||
# source = "github.com/myfork/project2" | ||
# | ||
# [[override]] | ||
# name = "github.com/x/y" | ||
# version = "2.4.0" | ||
# | ||
# [prune] | ||
# non-go = false | ||
# go-tests = true | ||
# unused-packages = true | ||
|
||
|
||
[prune] | ||
go-tests = true | ||
unused-packages = true | ||
|
||
[[constraint]] | ||
name = "github.com/stretchr/testify" | ||
version = "1.3.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
test: ## Runs tests | ||
go test ./... | ||
.PHONY: help | ||
help: | ||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' | ||
|
||
.DEFAULT_GOAL := help |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,139 @@ | ||
# go-api | ||
Golang SDK for Paylike API | ||
# Paylike client (Go) | ||
|
||
Writing your own client? Checkout the raw [HTTP service](https://github.com/paylike/api-docs). | ||
|
||
**Make sure to [subscribe to our mailling list](http://eepurl.com/bCGmg1) for | ||
deprecation notices, API changes and new features** | ||
|
||
[Godoc for the project](https://godoc.org/github.com/paylike/go-api) | ||
|
||
## Getting an API key | ||
|
||
An API key can be obtained by creating a merchant and adding an app through | ||
our [dashboard](https://app.paylike.io). If your app's target audience is | ||
third parties, please reach out and we will make your app's API key hidden. | ||
|
||
## Install | ||
|
||
```shell | ||
dep ensure -add github.com/paylike/node-api | ||
``` | ||
|
||
```golang | ||
import paylike "github.com/paylike/go-api" | ||
|
||
client := paylike.NewClient(os.Getenv("PAYLIKE_APP_KEY")) | ||
``` | ||
|
||
## Methods | ||
|
||
```golang | ||
// change key for authentication | ||
client.SetKey("key") | ||
|
||
// this command is also chainable | ||
app, err := client.SetKey("key").FetchApp() | ||
|
||
// create an app (requires no authentication) | ||
createdApp, err := client.CreateApp() | ||
|
||
// create an app with a dedicated name | ||
createdAppWithName, err := client.CreateAppWithName("myApplication") | ||
|
||
// fetch current app (based on key) | ||
app, err := client.FetchApp() | ||
|
||
// list app's merchants with limit | ||
merchants, err := client.FetchMerchants("appID", 10) | ||
|
||
// create merchant | ||
merchant, err := client.CreateMerchant(MerchantCreateDTO{ | ||
Test: true, | ||
Currency: "HUF", | ||
Email: TestEmail, | ||
Website: TestSite, | ||
Descriptor: "1234567897891234", | ||
Company: &MerchantCompany{ | ||
Country: "HU", | ||
}, | ||
}) | ||
|
||
// update merchant | ||
err := client.UpdateMerchant(MerchantUpdateDTO{ | ||
Name: "Test", | ||
Descriptor: "Test", | ||
Email: "[email protected]", | ||
}) | ||
|
||
// get merchant | ||
fetchedMerchant, err := client.GetMerchant(merchant.ID) | ||
|
||
// add users | ||
data, err := client.InviteUserToMerchant(merchant.ID, "[email protected]") | ||
|
||
// revoke users | ||
err := client.RevokeUserFromMerchant(merchant.ID, users[0].ID) | ||
|
||
// fetch users with limit | ||
users, err := client.FetchUsersToMerchant(merchant.ID, 3) | ||
|
||
// add app | ||
err := client.AddAppToMerchant(merchant.ID, app.ID) | ||
|
||
// revoke app | ||
err := client.RevokeAppFromMerchant(merchant.ID, app.ID) | ||
|
||
// fetch apps with limit | ||
apps, err := client.FetchAppsToMerchant(merchant.ID, 2) | ||
|
||
// fetch lines with limit | ||
lines, err := client.FetchLinesToMerchant(merchant.ID, 1) | ||
|
||
// create transaction | ||
data, err := client.CreateTransaction(TestMerchant, TransactionDTO{ | ||
TransactionID: "560fd96b7973ff3d2362a78c", | ||
Currency: "EUR", | ||
Amount: 200, | ||
Custom: map[string]interface{}{"source": "test"}, | ||
}) | ||
|
||
// fetch transactions with limit | ||
transactions, err := client.ListTransactions(merchant.ID, 20) | ||
|
||
// transaction capture | ||
dto := TransactionTrailDTO{ | ||
Amount: 2, | ||
Currency: "EUR", | ||
Descriptor: "Testing", | ||
} | ||
transaction, err := client.CaptureTransaction(transaction.ID, dto) | ||
|
||
// transaction refund | ||
dto := TransactionTrailDTO{ | ||
Amount: 1, | ||
Descriptor: "Testing Refund", | ||
} | ||
transaction, err := client.RefundTransaction(data.ID, dto) | ||
|
||
// transaction void | ||
dto := TransactionTrailDTO{ | ||
Amount: 1, | ||
} | ||
transaction, err := client.VoidTransaction(data.ID, dto) | ||
|
||
// transaction find | ||
transaction, err := client.FindTransaction(data.ID) | ||
|
||
// card create | ||
dto := CardDTO{ | ||
TransactionID: "560fd96b7973ff3d2362a78c", | ||
} | ||
data, err := client.CreateCard(TestMerchant, dto) | ||
|
||
// card find | ||
card, err := client.FetchCard(data.ID) | ||
``` | ||
|
||
A webshop would typically need only `CaptureTransaction`, `RefundTransaction` and `VoidTransaction`. Some might | ||
as well use `ListTransactions` and for recurring subscriptions | ||
`CreateTransaction`. |
Oops, something went wrong.