mirror of
https://github.com/bestbytes/datatrans.git
synced 2026-08-12 20:30:22 +00:00
rename config options, add DisableRawJSONBody
This commit is contained in:
@@ -45,9 +45,10 @@ type OptionMerchant struct {
|
||||
// simply retry your operation safely. Idempotency keys remain stored for 3
|
||||
// minutes. After 3 minutes have passed, sending the same request together
|
||||
// with the previous idempotency key will create a new operation.
|
||||
UseIdempotency bool
|
||||
MerchantID string // basic auth user
|
||||
Password string // basic auth pw
|
||||
EnableIdempotency bool
|
||||
DisableRawJSONBody bool
|
||||
MerchantID string // basic auth user
|
||||
Password string // basic auth pw
|
||||
}
|
||||
|
||||
func (m OptionMerchant) apply(c *Client) error {
|
||||
@@ -139,7 +140,7 @@ func (c *Client) do(req *http.Request, v interface{}) error {
|
||||
ri.Location = loc
|
||||
}
|
||||
}
|
||||
if set, ok := v.(rawJSONBodySetter); ok {
|
||||
if set, ok := v.(rawJSONBodySetter); !c.merchants[internalID].DisableRawJSONBody && ok {
|
||||
set.setJSONRawBody(buf.Bytes())
|
||||
}
|
||||
|
||||
@@ -215,7 +216,7 @@ func (c *Client) prepareJSONReq(method, path string, postData interface{}) (*htt
|
||||
if postData != nil {
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
}
|
||||
if method == http.MethodPost && c.merchants[internalID].UseIdempotency {
|
||||
if method == http.MethodPost && c.merchants[internalID].EnableIdempotency {
|
||||
// not quite happy with this
|
||||
// https://docs.datatrans.ch/docs/api-endpoints#section-idempotency
|
||||
fh := fnv.New64a()
|
||||
|
||||
+3
-3
@@ -93,9 +93,9 @@ func TestClient_Initialize(t *testing.T) {
|
||||
}
|
||||
})),
|
||||
datatrans.OptionMerchant{
|
||||
UseIdempotency: true,
|
||||
MerchantID: "322342",
|
||||
Password: "sfdgsdfg",
|
||||
EnableIdempotency: true,
|
||||
MerchantID: "322342",
|
||||
Password: "sfdgsdfg",
|
||||
},
|
||||
)
|
||||
must(t, err)
|
||||
|
||||
@@ -145,18 +145,39 @@ type CardAlias struct {
|
||||
}
|
||||
|
||||
type ResponseStatus struct {
|
||||
TransactionID string `json:"transactionId,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
Currency string `json:"currency,omitempty"`
|
||||
RefNo string `json:"refno,omitempty"`
|
||||
PaymentMethod string `json:"paymentMethod,omitempty"`
|
||||
Detail map[string]interface{} `json:"detail,omitempty"`
|
||||
Customer *Customer `json:"customer,omitempty"`
|
||||
Card *CardExtended `json:"card,omitempty"`
|
||||
Language string `json:"language,omitempty"`
|
||||
History []History `json:"history,omitempty"`
|
||||
RawJSONBody `json:"raw,omitempty"`
|
||||
TransactionID string `json:"transactionId,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
Currency string `json:"currency,omitempty"`
|
||||
RefNo string `json:"refno,omitempty"`
|
||||
PaymentMethod string `json:"paymentMethod,omitempty"`
|
||||
Detail struct {
|
||||
Init struct {
|
||||
Expires time.Time `json:"expires,omitempty"` // Tells when the initialized transaction will expire if not continued - 30 minutes after initialization.
|
||||
} `json:"init,omitempty"`
|
||||
Authorize struct {
|
||||
Amount int `json:"amount,omitempty"`
|
||||
AcquirerAuthorizationCode string `json:"acquirerAuthorizationCode,omitempty"`
|
||||
} `json:"authorize,omitempty"`
|
||||
Settle struct {
|
||||
Amount int `json:"amount,omitempty"`
|
||||
} `json:"settle,omitempty"`
|
||||
Credit struct {
|
||||
Amount int `json:"amount,omitempty"`
|
||||
} `json:"credit,omitempty"`
|
||||
Cancel struct {
|
||||
Reversal bool `json:"reversal,omitempty"` // Whether the transaction was reversed on acquirer side.
|
||||
} `json:"cancel,omitempty"`
|
||||
Fail struct {
|
||||
Reason string `json:"reason,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
} `json:"fail,omitempty"`
|
||||
} `json:"detail,omitempty"`
|
||||
Customer *Customer `json:"customer,omitempty"`
|
||||
Card *CardExtended `json:"card,omitempty"`
|
||||
Language string `json:"language,omitempty"`
|
||||
History []History `json:"history,omitempty"`
|
||||
RawJSONBody `json:"raw,omitempty"`
|
||||
}
|
||||
|
||||
type CardExtended struct {
|
||||
|
||||
Reference in New Issue
Block a user