Skip to content

Commit c80050b

Browse files
Upgrade library to API version 2019-05-29. (#84)
## Description Upgrade library to support API version `2019-05-29` ### More information (if any) - Removed the flexibility to change API version because this updates will support only the latest API version `2019-05-29`. - Updated few fields according to the latest API version. - Updated tests. ### Documentation (if any) None for now. We need to update our README to announce the new major version release that supports only the latest API version `2019` and guide users on which library version to use for different API version. ## Decision(s) We removed the ability to set the API version. This change is necessary because the upcoming updates will not be compatible with the older API versions. So, switching API version to an older version is impractical. Instead, we specified the API version directly in the library. ## Rollback procedure <!-- Describe the Rollback procedure. If none/default, update with `default rollback procedure` -->
1 parent 45eafba commit c80050b

File tree

102 files changed

+1066
-600
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+1066
-600
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
.idea
2+
examples/.env
3+
examples/.DS_Store

balance.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package omise
44
// See https://www.omise.co/balance-api for more information.
55
type Balance struct {
66
Base
7-
Available int64 `json:"available"`
8-
Total int64 `json:"total"`
9-
Currency string `json:"currency"`
7+
Transferable int64 `json:"transferable"`
8+
Total int64 `json:"total"`
9+
Currency string `json:"currency"`
1010
}

bank_account.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,30 @@ package omise
22

33
// BankAccount represents Omise's bank account object.
44
// See https://www.omise.co/bank-account-api for more information.
5+
type BankAccountRequest struct {
6+
Base
7+
Brand string `json:"brand"`
8+
LastDigits string `json:"last_digits"`
9+
Name string `json:"name"`
10+
11+
// for Omise Japan
12+
BankCode string `json:"bank_code"`
13+
BranchCode string `json:"branch_code"`
14+
Type BankAccountType `json:"type"`
15+
Number string `json:"number"`
16+
}
17+
518
type BankAccount struct {
619
Base
720
Brand string `json:"brand"`
8-
Number string `json:"number"`
921
LastDigits string `json:"last_digits"`
1022
Name string `json:"name"`
1123

1224
// for Omise Japan
13-
BankCode string `json:"bank_code"`
14-
BranchCode string `json:"branch_code"`
15-
AccountType BankAccountType `json:"account_type"`
25+
BankCode string `json:"bank_code"`
26+
BranchCode string `json:"branch_code"`
27+
Type BankAccountType `json:"type"`
28+
AccountNumber string `json:"account_number"`
1629
}
1730

1831
// BankAccountType BankAccount an enumeration of possible types of BackAccount(s) which can be

base.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import "time"
55
// Base structure contains fields that are common to objects returned by the Omise's REST
66
// API.
77
type Base struct {
8-
Object string `json:"object"`
9-
ID string `json:"id"`
10-
Live bool `json:"livemode"`
11-
Location *string `json:"location"`
12-
Created time.Time `json:"created"`
8+
Object string `json:"object"`
9+
ID string `json:"id"`
10+
Live bool `json:"livemode"`
11+
Location *string `json:"location"`
12+
CreatedAt time.Time `json:"created_at"`
1313
}
1414

1515
// Deletion struct is used to receive deletion responses from delete operations.

charge.go

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import "time"
66
// See https://www.omise.co/charges-api for more information.
77
type Charge struct {
88
Base
9-
Status ChargeStatus `json:"status"`
10-
Amount int64 `json:"amount"`
11-
AuthorizationType AuthorizationType `json:"authorization_type"`
12-
AuthorizedAmount int64 `json:"authorized_amount"`
13-
CapturedAmount int64 `json:"captured_amount"`
14-
Currency string `json:"currency"`
15-
Description *string `json:"description"`
9+
Status ChargeStatus `json:"status"`
10+
Amount int64 `json:"amount"`
11+
AuthorizationType AuthorizationType `json:"authorization_type"`
12+
AuthorizedAmount int64 `json:"authorized_amount"`
13+
CapturedAmount int64 `json:"captured_amount"`
14+
Currency string `json:"currency"`
15+
Description *string `json:"description"`
1616

1717
Capture bool `json:"capture"`
1818
Authorized bool `json:"authorized"`
@@ -22,7 +22,7 @@ type Charge struct {
2222
Transaction string `json:"transaction"`
2323
Card *Card `json:"card"`
2424

25-
Refunded int64 `json:"refunded"`
25+
RefundedAmount int64 `json:"refunded_amount"`
2626
Refunds *RefundList `json:"refunds"`
2727
FailureCode *string `json:"failure_code"`
2828
FailureMessage *string `json:"failure_message"`
@@ -35,9 +35,35 @@ type Charge struct {
3535
AuthorizeURI string `json:"authorize_uri"`
3636

3737
SourceOfFund SourceOfFunds `json:"source_of_fund"`
38-
Offsite OffsiteTypes `json:"offsite"`
3938

4039
Source *Source `json:"source"`
4140
Metadata map[string]interface{} `json:"metadata"`
4241
ExpiresAt time.Time `json:"expires_at"`
4342
}
43+
44+
type TransactionIndicator string
45+
46+
const (
47+
MIT TransactionIndicator = "MIT"
48+
CIT TransactionIndicator = "CIT"
49+
)
50+
51+
type RecurringReason string
52+
53+
const (
54+
Blank RecurringReason = ""
55+
Unscheduled RecurringReason = "unscheduled"
56+
StandingOrder RecurringReason = "standing_order"
57+
Subscription RecurringReason = "subscription"
58+
Installment RecurringReason = "installment"
59+
PartialShipment RecurringReason = "partial_shipment"
60+
DelayedCharge RecurringReason = "delayed_charge"
61+
NoShow RecurringReason = "no_show"
62+
Resubmission RecurringReason = "resubmission"
63+
)
64+
65+
type PlatformFee struct {
66+
Fixed int32 `json:"fixed,omitempty"`
67+
Percentage float32 `json:"percentage,omitempty"`
68+
Amount int64 `json:"Amount,omitempty"`
69+
}

client.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ type Client struct {
2828
Endpoints map[internal.Endpoint]string
2929

3030
// configuration
31-
APIVersion string
3231
GoVersion string
3332
customHeaders map[string]string
3433
ctx context.Context
@@ -138,9 +137,7 @@ func (c *Client) setRequestHeaders(req *http.Request, desc *internal.Description
138137
}
139138

140139
req.Header.Add("User-Agent", strings.TrimSpace(ua))
141-
if c.APIVersion != "" {
142-
req.Header.Add("Omise-Version", c.APIVersion)
143-
}
140+
req.Header.Add("Omise-Version", internal.Version)
144141

145142
// setting custom headers passed from the caller
146143
for k, v := range c.customHeaders {

client_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,12 @@ func TestClient_Request(t *testing.T) {
7676
r.Contains(t, req.Header.Get("User-Agent"), "OmiseGo/")
7777
r.Contains(t, req.Header.Get("User-Agent"), "Go/go")
7878
r.Contains(t, req.Header.Get("X-Header-ABC"), "ABC")
79-
r.Empty(t, req.Header.Get("Omise-Version"), "Omise-Version header sent when APIVersion is not specified.")
79+
r.Equal(t, req.Header.Get("Omise-Version"), internal.Version)
8080

8181
client.GoVersion = "RANDOMXXXVERSION"
82-
client.APIVersion = "yadda"
8382
req, err = client.Request(desc)
8483
r.NoError(t, err)
8584
r.Contains(t, req.Header.Get("User-Agent"), "Go/RANDOMXXXVERSION")
86-
r.Equal(t, req.Header.Get("Omise-Version"), "yadda")
8785

8886
client.WithUserAgent("OmiseShopify/2.0.0 CheckoutPage/1.0.0")
8987
req, err = client.Request(desc)

examples/env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
PUBLIC_KEY=****
2+
SECRET_KEY=****

examples/go.mod

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module github.com/omise/omise-go/examples
2+
3+
go 1.21.3
4+
5+
require (
6+
github.com/joho/godotenv v1.5.1 // indirect
7+
github.com/omise/omise-go v1.5.0 // indirect
8+
)
9+
10+
replace github.com/omise/omise-go => /Users/aashish/go/src/github.com/omise/omise-go

examples/go.sum

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
2+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3+
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
4+
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
5+
github.com/omise/omise-go v1.5.0 h1:LVkNDMWVI3HdChugA6QmZuyTk63R00Army+TbZzxh/c=
6+
github.com/omise/omise-go v1.5.0/go.mod h1:P2sXynkJeQOAe46sk1krS/v2irWUxuI+cKoQgm5Ayp4=
7+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
8+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
9+
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
10+
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
11+
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
12+
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
13+
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
14+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
15+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
16+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 commit comments

Comments
 (0)