Skip to content

Commit

Permalink
Merge pull request #128 from rjjatson/feature/fix-transaction-object
Browse files Browse the repository at this point in the history
Add optional settlement information on transaction object
  • Loading branch information
adityarx authored May 30, 2023
2 parents c093978 + 684ac55 commit ccb95a7
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 30 deletions.
34 changes: 18 additions & 16 deletions transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,24 @@ import "time"
// For more details see https://developers.xendit.co/api-reference/#transactions.
// For documentation of subpackage payout, checkout https://pkg.go.dev/github.com/xendit/xendit-go/transaction
type Transaction struct {
ID string `json:"id"`
ProductID string `json:"product_id"`
Type string `json:"type"`
ChannelCode string `json:"channel_code,omitempty"`
ReferenceID string `json:"reference_id"`
AccountIdentifier string `json:"account_identifier,omitempty"`
Currency string `json:"currency,omitempty"`
Amount float64 `json:"amount"`
NetAmount float64 `json:"net_amount"`
Cashflow string `json:"cashflow"`
Status string `json:"status"`
ChannelCategory string `json:"channel_category"`
BusinessID string `json:"business_id"`
Created *time.Time `json:"created"`
Updated *time.Time `json:"updated"`
Fee TransactionFee `json:"fee"`
ID string `json:"id"`
ProductID string `json:"product_id"`
Type string `json:"type"`
ChannelCode string `json:"channel_code,omitempty"`
ReferenceID string `json:"reference_id"`
AccountIdentifier string `json:"account_identifier,omitempty"`
Currency string `json:"currency,omitempty"`
Amount float64 `json:"amount"`
NetAmount float64 `json:"net_amount"`
Cashflow string `json:"cashflow"`
Status string `json:"status"`
ChannelCategory string `json:"channel_category"`
BusinessID string `json:"business_id"`
SettlementStatus string `json:"settlement_status,omitempty"`
EstimatedSettlementTime *time.Time `json:"estimated_settlement_time,omitempty"`
Created *time.Time `json:"created"`
Updated *time.Time `json:"updated"`
Fee TransactionFee `json:"fee"`
}

type TransactionFee struct {
Expand Down
34 changes: 20 additions & 14 deletions transaction/transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ func (m *apiRequesterGetListMock) Call(ctx context.Context, method string, path
"currency": "IDR",
"amount": 1,
"cashflow": "MONEY_IN",
"settlement_status" : "PENDING",
"estimated_settlement_time" : "2021-06-26T04:03:02.123Z",
"business_id": "5fc9f5b246f820517e38c84d",
"created": "2021-06-23T02:42:15.601Z",
"updated": "2021-06-23T02:42:15.601Z"
Expand Down Expand Up @@ -196,6 +198,8 @@ func TestGetListTransaction(t *testing.T) {
created2 := time.Date(2021, 6, 23, 2, 39, 23, 176000000, time.UTC)
updated2 := time.Date(2021, 6, 23, 2, 39, 23, 176000000, time.UTC)

estimatedSettlement := time.Date(2021, 6, 26, 4, 3, 2, 123000000, time.UTC)

testCases := []struct {
desc string
data *transaction.GetListTransactionParams
Expand All @@ -209,20 +213,22 @@ func TestGetListTransaction(t *testing.T) {
HasMore: true,
Data: []xendit.Transaction{
{
ID: "txn_13dd178d-41fa-40b7-8fd3-f83675d6f413",
ProductID: "d290f1ee-6c54-4b01-90e6-d701748f0701",
Type: "PAYMENT",
Status: "SUCCESS",
ChannelCategory: "RETAIL_OUTLET",
ChannelCode: "ALFAMART",
ReferenceID: "ref23244",
AccountIdentifier: "",
Currency: "IDR",
Amount: 1,
Cashflow: "MONEY_IN",
BusinessID: "5fc9f5b246f820517e38c84d",
Created: &created,
Updated: &updated,
ID: "txn_13dd178d-41fa-40b7-8fd3-f83675d6f413",
ProductID: "d290f1ee-6c54-4b01-90e6-d701748f0701",
Type: "PAYMENT",
Status: "SUCCESS",
ChannelCategory: "RETAIL_OUTLET",
ChannelCode: "ALFAMART",
ReferenceID: "ref23244",
AccountIdentifier: "",
Currency: "IDR",
Amount: 1,
Cashflow: "MONEY_IN",
BusinessID: "5fc9f5b246f820517e38c84d",
SettlementStatus: "PENDING",
EstimatedSettlementTime: &estimatedSettlement,
Created: &created,
Updated: &updated,
},
{
ID: "txn_a765a3f0-34c0-41ee-8686-bca11835ebdc",
Expand Down

0 comments on commit ccb95a7

Please sign in to comment.