Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
adamnoto committed Jan 11, 2017
1 parent ba426f2 commit 4003c40
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,38 @@ an advantage of itself. Now, Midtrans is available to be used in Go, too.
}

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

### Snap Gateway

Snap is Midtrans existing tool to help merchant charge customers using a
mobile-friendly, in-page, no-redirect checkout facilities. Using snap is
completely simple.

```go
var snapGateway midtrans.SnapGateway
snapGateway = midtrans.SnapGateway{
Client: midclient,
}

snapResp, err := snapGateway.GetTokenQuick(generateOrderId(), 200000)
var snapToken string
if err != nil {
snapToken = snapResp.Token
}
```

On the client side:

```javascript
var token = $("#snap-token").val();
snap.pay(token, {
onSuccess: function(res) { alert("Payment accepted!"); },
onPending: function(res) { alert("Payment pending", res); },
onError: function(res) { alert("Error", res); }
});
```

You may want to override those `onSuccess`, `onPending` and `onError`
functions to reflect the behaviour that you wished when the charging
result in their respective state.

0 comments on commit 4003c40

Please sign in to comment.