Skip to content

Commit

Permalink
add README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
adamnoto committed Jan 5, 2017
1 parent 7a15815 commit d39b1bb
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Midtrans Library for Go(lang)

Midtrans :heart: Go !

Go is a very modern, terse, and combine aspect of dynamic and static typing that is very
well suited for web development, among other things. Its small memory usage is also
an advantage of itself. Now, Midtrans is available to be used in Go, too.

## Usage blueprint

1. There is a type named `Client` (`midtrans.Client`) that should be instantiated through `NewClient` which hold any possible setting to the library.
2. There is a gateway classes which you will be using depending on whether you used Core, SNAP, or VT-WEB. The gateway type need a Client instance.
3. Any activity (charge, approve, etc) is done in the gateway level.

## Example

### Core Gateway

```go
midclient := midtrans.NewClient()
midclient.ServerKey = "VT-server-7CVlR3AJ8Dpkez3k_TeGJQZU"
midclient.ClientKey = "VT-client-IKktHiy3aRYHljsw"
midclient.ApiEnvType = midtrans.Sandbox

coreGateway = midtrans.CoreGateway{
Client: midclient,
}

chargeReq := &midtrans.ChargeReq{
PaymentType: midtrans.SourceCreditCard,
TransactionDetails: midtrans.TransactionDetails{
OrderID: "12345",
GrossAmt: 200000,
},
CreditCard: &midtrans.CreditCardDetail{
TokenID: "YOUR-CC-TOKEN",
},
Items: []midtrans.ItemDetail{
midtrans.ItemDetail{
Id: "ITEM1",
Price: 200000,
Qty: 1,
Name: "Someitem",
},
},
}

resp, _ := coreGateway.Charge(chargeReq)
```

0 comments on commit d39b1bb

Please sign in to comment.