Skip to content

Commit

Permalink
Merge pull request #24 from erwinwahyura/main
Browse files Browse the repository at this point in the history
v1.3.6 
- fix: CardPointInquiry returned response struct
  • Loading branch information
rizdaprasetya authored Oct 5, 2022
2 parents 0ae572c + 0659d1b commit 3f543f5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
9 changes: 5 additions & 4 deletions coreapi/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import (
"bytes"
"encoding/json"
"fmt"
"github.com/midtrans/midtrans-go"
"net/http"
"strconv"

"github.com/midtrans/midtrans-go"
)

// Client : CoreAPI Client struct
Expand Down Expand Up @@ -141,8 +142,8 @@ func RegisterCard(cardNumber string, expMonth int, expYear int) (*CardRegisterRe

// CardPointInquiry : Do `/point_inquiry/{tokenId}` API request to Midtrans Core API return `coreapi.CardTokenResponse`,
// more detail refer to: https://api-docs.midtrans.com/#point-inquiry
func (c Client) CardPointInquiry(cardToken string) (*CardTokenResponse, *midtrans.Error) {
resp := &CardTokenResponse{}
func (c Client) CardPointInquiry(cardToken string) (*PointInquiryResponse, *midtrans.Error) {
resp := &PointInquiryResponse{}
err := c.HttpClient.Call(
http.MethodGet,
fmt.Sprintf("%s/v2/point_inquiry/%s", c.Env.BaseUrl(), cardToken),
Expand All @@ -160,7 +161,7 @@ func (c Client) CardPointInquiry(cardToken string) (*CardTokenResponse, *midtran

// CardPointInquiry : Do `/point_inquiry/{tokenId}` API request to Midtrans Core API return `coreapi.CardTokenResponse`,
// more detail refer to: https://api-docs.midtrans.com/#point-inquiry
func CardPointInquiry(cardToken string) (*CardTokenResponse, *midtrans.Error) {
func CardPointInquiry(cardToken string) (*PointInquiryResponse, *midtrans.Error) {
return getDefaultClient().CardPointInquiry(cardToken)
}

Expand Down
26 changes: 17 additions & 9 deletions coreapi/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type PaymentAmount struct {
Amount string `json:"amount"`
}

//ChargeResponse : CoreAPI charge response struct when calling Midtrans API
// ChargeResponse : CoreAPI charge response struct when calling Midtrans API
type ChargeResponse struct {
TransactionID string `json:"transaction_id"`
OrderID string `json:"order_id"`
Expand Down Expand Up @@ -63,22 +63,22 @@ type ChargeResponse struct {
OnUs bool `json:"on_us"`
}

//ApproveResponse : Approve response type when calling Midtrans approve transaction API
// ApproveResponse : Approve response type when calling Midtrans approve transaction API
type ApproveResponse = ChargeResponse

//DenyResponse : Deny response type when calling Midtrans deny transaction API
// DenyResponse : Deny response type when calling Midtrans deny transaction API
type DenyResponse = ChargeResponse

//CancelResponse : Cancel response type when calling Midtrans cancel transaction API
// CancelResponse : Cancel response type when calling Midtrans cancel transaction API
type CancelResponse = ChargeResponse

//ExpireResponse : Expire response type when calling Midtrans expire transaction API
// ExpireResponse : Expire response type when calling Midtrans expire transaction API
type ExpireResponse = ChargeResponse

//CaptureResponse : Capture response type when calling Midtrans API capture for credit card transaction
// CaptureResponse : Capture response type when calling Midtrans API capture for credit card transaction
type CaptureResponse = ChargeResponse

//TransactionStatusResponse : Status transaction response struct
// TransactionStatusResponse : Status transaction response struct
type TransactionStatusResponse struct {
TransactionTime string `json:"transaction_time"`
GrossAmount string `json:"gross_amount"`
Expand Down Expand Up @@ -141,7 +141,7 @@ type RefundDetails struct {
CreatedAt string `json:"created_at"`
}

//RefundResponse : Refund response struct when calling Midtrans refund and direct refund API
// RefundResponse : Refund response struct when calling Midtrans refund and direct refund API
type RefundResponse struct {
StatusCode string `json:"status_code"`
StatusMessage string `json:"status_message"`
Expand Down Expand Up @@ -225,7 +225,7 @@ type UpdateSubscriptionResponse struct {
type EnableSubscriptionResponse = UpdateSubscriptionResponse
type DisableSubscriptionResponse = UpdateSubscriptionResponse

//ScheduleResponse Subscription schedule response object
// ScheduleResponse Subscription schedule response object
type ScheduleResponse struct {
Interval int `json:"interval"`
IntervalUnit string `json:"interval_unit"`
Expand Down Expand Up @@ -265,3 +265,11 @@ type BalanceDetails struct {
Value string `json:"value"`
Currency string `json:"currency"`
}

type PointInquiryResponse struct {
StatusCode string `json:"status_code"`
StatusMessage string `json:"status_message"`
PointBalance int `json:"point_balance"`
TransactionTime string `json:"transaction_time"`
PointBalanceAmount string `json:"point_balance_amount"`
}
2 changes: 1 addition & 1 deletion midtrans.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const (
Production

//libraryVersion : midtrans go library version
libraryVersion = "v1.3.5"
libraryVersion = "v1.3.6"
)

//ServerKey is config payment API key for global use
Expand Down

0 comments on commit 3f543f5

Please sign in to comment.