Skip to content

Commit

Permalink
add toki status constants
Browse files Browse the repository at this point in the history
  • Loading branch information
Cro8ox committed Jul 24, 2023
1 parent a296058 commit c739dd5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
8 changes: 8 additions & 0 deletions tokipay/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package tokipay

const (
OrderStatusPaid string = "PAID"
OrderStatusPending string = "PENDING"
OrderStatusCanceled string = "EXPIRED"
OrderStatusExpired string = "EXPIRED"
)
2 changes: 1 addition & 1 deletion tokipay/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type (
RequestId string `json:"requestId"`
}

TokipayPaymentStatusReponse struct {
TokipayPaymentStatusResponse struct {
StatusCode int `json:"statusCode"`
Error string `json:"error"`
Message string `json:"message"`
Expand Down
16 changes: 8 additions & 8 deletions tokipay/tokipay.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ type Tokipay interface {
PaymentQr(input TokipayPaymentQrInput) (TokipayPaymentResponse, error)
PaymentSentUser(input TokipayPaymentQrInput) (TokipayPaymentResponse, error)
PaymentScanUser(input TokipayPaymentQrInput) (TokipayPaymentResponse, error)
PaymentStatus(requestId string) (TokipayPaymentStatusReponse, error)
PaymentCancel(requestId string) (TokipayPaymentResponseExt, error)
PaymentStatus(requestId string) (TokipayPaymentStatusResponse, error)
PaymentCancel(requestId string) (TokipayPaymentStatusResponse, error)
}

func New(endpoint, apiKey, imApiKey, authorization, merchantId string) Tokipay {
Expand Down Expand Up @@ -97,27 +97,27 @@ func (q *tokipay) PaymentScanUser(input TokipayPaymentQrInput) (TokipayPaymentRe
return response, nil
}

func (q *tokipay) PaymentStatus(requestId string) (TokipayPaymentStatusReponse, error) {
func (q *tokipay) PaymentStatus(requestId string) (TokipayPaymentStatusResponse, error) {

res, err := q.httpRequestTokipay(nil, TokipayPaymentStatus, requestId)
if err != nil {
return TokipayPaymentStatusReponse{}, err
return TokipayPaymentStatusResponse{}, err
}

var response TokipayPaymentStatusReponse
var response TokipayPaymentStatusResponse
json.Unmarshal(res, &response)

return response, nil
}

func (q *tokipay) PaymentCancel(requestId string) (TokipayPaymentResponseExt, error) {
func (q *tokipay) PaymentCancel(requestId string) (TokipayPaymentStatusResponse, error) {

res, err := q.httpRequestTokipay(nil, TokipayPaymentCancel, requestId)
if err != nil {
return TokipayPaymentResponseExt{}, err
return TokipayPaymentStatusResponse{}, err
}

var response TokipayPaymentResponseExt
var response TokipayPaymentStatusResponse
json.Unmarshal(res, &response)

return response, nil
Expand Down

0 comments on commit c739dd5

Please sign in to comment.