Giter Club home page Giter Club logo

go-api's Introduction

Paylike client (Go)

Writing your own client? Checkout the raw HTTP service.

Make sure to subscribe to our mailling list for deprecation notices, API changes and new features

Godoc for the project

Getting an API key

An API key can be obtained by creating a merchant and adding an app through our dashboard. If your app's target audience is third parties, please reach out and we will make your app's API key hidden.

Install

go get github.com/paylike/go-api
import paylike "github.com/paylike/go-api"

client := paylike.NewClient(os.Getenv("PAYLIKE_APP_KEY"))

Methods

// 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(paylike.MerchantCreateDTO{
    Test:       true,
    Currency:   "HUF",
    Email:      TestEmail,
    Website:    TestSite,
    Descriptor: "1234567897891234",
    Company: &MerchantCompany{
        Country: "HU",
    },
})

// update merchant
err := client.UpdateMerchant(paylike.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(merchant.ID, paylike.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 := paylike.TransactionTrailDTO{
    Amount:     2,
    Currency:   "EUR",
    Descriptor: "Testing",
}
transaction, err := client.CaptureTransaction(transaction.ID, dto)

// transaction refund
dto := paylike.TransactionTrailDTO{
    Amount:     1,
    Descriptor: "Testing Refund",
}
transaction, err := client.RefundTransaction(data.ID, dto)

// transaction void
dto := paylike.TransactionTrailDTO{
    Amount: 1,
}
transaction, err := client.VoidTransaction(data.ID, dto)

// transaction find
transaction, err := client.FindTransaction(data.ID)

// card create
dto := paylike.CardDTO{
    TransactionID: "560fd96b7973ff3d2362a78c",
}
data, err := client.CreateCard(merchant.ID, 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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.