Skip to content

Commit

Permalink
adds checkout token expire endpoint with new fields (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
reywyn committed Aug 29, 2023
1 parent 5ca17c4 commit 3f4d61b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
6 changes: 4 additions & 2 deletions adapter/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ type InitCheckoutPaymentRequest struct {
AllowOnlyCreditCard bool `json:"allowOnlyCreditCard,omitempty"`
ForceThreeDS bool `json:"forceThreeDS,omitempty"`
ForceAuthForNonCreditCards bool `json:"forceAuthForNonCreditCards,omitempty"`
Ttl int64 `json:"ttl,omitempty"`
CustomInstallments []CustomInstallment `json:"customInstallments,omitempty"`
Items []PaymentItem `json:"items"`
}
Expand Down Expand Up @@ -682,8 +683,9 @@ type Init3DSPaymentResponse struct {
}

type InitCheckoutPaymentResponse struct {
Token *string `json:"token"`
PageUrl *string `json:"pageUrl"`
Token *string `json:"token"`
PageUrl *string `json:"pageUrl"`
TokenExpireDate *TimeResponse `json:"tokenExpireDate"`
}

type InitApmPaymentResponse struct {
Expand Down
15 changes: 15 additions & 0 deletions adapter/payment.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,21 @@ func (api *Payment) RetrieveCheckoutPayment(ctx context.Context, token string) (
return response.Data, nil
}

func (api *Payment) ExpireCheckoutPayment(ctx context.Context, token string) error {
newRequest, err := api.Client.NewRequest(ctx, http.MethodDelete, fmt.Sprintf("/payment/v1/checkout-payments/%s", token), nil)
if err != nil {
return err
}

response := &Void{}
err = api.Client.Do(ctx, newRequest, response)
if err != nil {
return err
}

return nil
}

func (api *Payment) CreateDepositPayment(ctx context.Context, request DepositPaymentRequest) (*DepositPaymentResponse, error) {
newRequest, err := api.Client.NewRequest(ctx, http.MethodPost, "/payment/v1/deposits", request)

Expand Down
8 changes: 8 additions & 0 deletions tests/payment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,14 @@ func TestPayment_RetrieveCheckoutPayment(t *testing.T) {
}
}

func TestPayment_ExpireCheckoutPayment(t *testing.T) {
err := paymentClient.Payment.ExpireCheckoutPayment(context.Background(), "foo-bar")

if err != nil {
t.Errorf("Error %s", err)
}
}

func TestPayment_CreateDepositPayment(t *testing.T) {
request := adapter.DepositPaymentRequest{
Price: 100,
Expand Down

0 comments on commit 3f4d61b

Please sign in to comment.