webpay

package module
v0.0.0-...-19bbd2f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2014 License: MIT Imports: 8 Imported by: 0

README

webpay library for golang
================================================
.. image:: https://drone.io/github.com/tsukinowasha/go-webpay/status.png
   :target: https://drone.io/github.com/tsukinowasha/go-webpay/status.png

.. image:: https://coveralls.io/repos/tsukinowasha/go-webpay/badge.png?branch=master
   :target: https://coveralls.io/r/tsukinowasha/go-webpay?branch=master

This is a **unofficial** library for WebPay (https://webpay.jp/)

godoc : http://godoc.org/github.com/tsukinowasha/go-webpay


Install
--------

::

   go get github.com/tsukinowasha/go-webpay


Usage
--------

::

   client := webpay.NewWebPayClient("YOUR_AUTH_TOKEN")
   ret, _ := client.Charge.Create(
       400.0,
      "jpy",
       webpay.Card{
           Number:    "4242-4242-4242-4242",
           Exp_month: 11,
           Exp_year:  2015,
           Cvc:       "123",
           Name:      "John Doe",
       },
   )

   chargeId, _ := webpay.GetId(ret)
   fmt.Println(chargeId)

Difference
-----------------

ByCustomer
++++++++++++++++++

Webpay can charge not only by the Card but also Customer Id. The
official library can use same function to both.

But golang does not permit it. In this library, you should use
another function.

::

  client := webpay.NewWebPayClient("YOUR_AUTH_TOKEN")
  ret, err := client.Charge.CreateByCustomer(400.0, "jpy", "cus_45d3MV5xxxxxxv")

Same as CustomerByToken.

::

  client := webpay.NewWebPayClient("YOUR_AUTH_TOKEN")
  ret, err := client.Customer.CreateByToken("tok_34M4Vxxxxxxv")


All
++++++++++++++++++

Customer or other list can be acquired with count, offset or created arguments.
These args can be empty.

In this library, arguments are map[string]int.

::

  ret, err := client.Charge.All(map[string]int{
      "count": 5,
      "gt":    1412751347,
  })


Current Status
------------------------

- Charge

  - Create: done
  - CreateByCustomer: done
  - Retrieve: done
  - Refund: notyet
  - Capture: notyet
  - all: done

- Customer

  - Create: done
  - Retrieve: done
  - Update: notyet
  - delete: done
  - all: done
  - delete_active_card: notyet

- Token

  - Create: done
  - Retrieve: done

- Recursion

  - Create: done
  - Retrieve: done
  - Resume: notyet
  - delete: notyet
  - all: done

- Account

  - Retrieve: done
  - Delete: notyet

- Event

  - Retrieve: done
  - All: done

- Shop ?

LICENSE
-----------

MIT



Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetId

func GetId(json *simplejson.Json) (string, error)

GetId returns 'id' of the JSON.

Types

type Account

type Account struct {
	// contains filtered or unexported fields
}

func NewAccount

func NewAccount(cli *WebPayClient) Account

func (Account) Retrieve

func (c Account) Retrieve() (*simplejson.Json, error)

type Card

type Card struct {
	Number    string
	Exp_month int
	Exp_year  int
	Cvc       string
	Name      string
}

func NewCard

func NewCard() Card

func (Card) AddParams

func (c Card) AddParams(params url.Values) url.Values

type Charge

type Charge struct {
	// contains filtered or unexported fields
}

func NewCharge

func NewCharge(cli *WebPayClient) Charge

func (Charge) All

func (c Charge) All(args map[string]int, customer, recursion string) (*simplejson.Json, error)

All returnes customer list filtered by params.

func (Charge) Create

func (c Charge) Create(amount float64, currency string, card Card) (*simplejson.Json, error)

CreateByCustomerId creates Charge.

func (Charge) CreateByCustomer

func (c Charge) CreateByCustomer(amount float64, currency string, customer string) (*simplejson.Json, error)

CreateByCustomer creates Charge from specified Customer.

func (Charge) Retrieve

func (c Charge) Retrieve(chid string) (*simplejson.Json, error)

Retrieve retrieves Charge information from WebPay.

type Customer

type Customer struct {
	// contains filtered or unexported fields
}

func NewCustomer

func NewCustomer(cli *WebPayClient) Customer

func (Customer) All

func (c Customer) All(args map[string]int) (*simplejson.Json, error)

All returnes customer list filtered by params.

func (Customer) Create

func (c Customer) Create(card Card, email, description string) (*simplejson.Json, error)

Create creates new Customer.

func (Customer) CreateByToken

func (c Customer) CreateByToken(token, email, description string) (*simplejson.Json, error)

CreateByToken creates Customer from the token.

func (Customer) Delete

func (c Customer) Delete(customerId string) (*simplejson.Json, error)

Delete deltes a Customer.

type Event

type Event struct {
	// contains filtered or unexported fields
}

func NewEvent

func NewEvent(cli *WebPayClient) Event

func (Event) All

func (c Event) All(args map[string]int) (*simplejson.Json, error)

All returnes customer list filtered by params.

func (Event) Retrieve

func (c Event) Retrieve(chid string) (*simplejson.Json, error)

Retrieve retrieves Event information from WebPay.

type Recursion

type Recursion struct {
	// contains filtered or unexported fields
}

func NewRecursion

func NewRecursion(cli *WebPayClient) Recursion

func (Recursion) All

func (c Recursion) All(args map[string]int) (*simplejson.Json, error)

All returnes customer list filtered by params.

func (Recursion) Create

func (c Recursion) Create(amount float64, currency, customer, period, description string) (*simplejson.Json, error)

func (Recursion) Delete

func (c Recursion) Delete(recursionId string) (*simplejson.Json, error)

Delete deltes a Recursion.

func (Recursion) Retrieve

func (c Recursion) Retrieve(recid string) (*simplejson.Json, error)

type Token

type Token struct {
	// contains filtered or unexported fields
}

func NewToken

func NewToken(cli *WebPayClient) Token

func (Token) Create

func (c Token) Create(uuid string, card Card) (*simplejson.Json, error)

func (Token) Retrieve

func (c Token) Retrieve(chid string) (*simplejson.Json, error)

type WebPayClient

type WebPayClient struct {
	Charge    Charge
	Customer  Customer
	Recursion Recursion
	Token     Token
	Event     Event
	Account   Account
	// contains filtered or unexported fields
}

func NewWebPayClient

func NewWebPayClient(auth_token string) WebPayClient

func (WebPayClient) Delete

func (cli WebPayClient) Delete(path string, params url.Values) (*simplejson.Json, error)

func (WebPayClient) Get

func (cli WebPayClient) Get(path string, params url.Values) (*simplejson.Json, error)

func (WebPayClient) Post

func (cli WebPayClient) Post(path string, params url.Values) (*simplejson.Json, error)

func (WebPayClient) Request

func (cli WebPayClient) Request(method, path string, params url.Values) (*simplejson.Json, error)

func (WebPayClient) SetAcceptLanguage

func (cli WebPayClient) SetAcceptLanguage(lang string)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL