Skip to content

Commit

Permalink
Add masterpass loyalty retrieve endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
onurpolattimur committed May 3, 2024
1 parent a248ba2 commit 0b5089c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
15 changes: 15 additions & 0 deletions adapter/masterpass.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,18 @@ func (api *Masterpass) Complete3DSMasterpassPayment(ctx context.Context, request

return response.Data, nil
}

func (api *Masterpass) RetrieveLoyalties(ctx context.Context, request MasterpassRetrieveLoyaltiesRequest) (*RetrieveLoyaltiesResponse, error) {
newRequest, err := api.Client.NewRequest(ctx, http.MethodPost, "/payment/v2/masterpass-payments/loyalties/retrieve", request)
if err != nil {
return nil, err
}

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

return response.Data, nil
}
6 changes: 6 additions & 0 deletions adapter/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,12 @@ type RetrieveLoyaltiesRequest struct {
CardToken string `json:"cardToken,omitempty"`
}

type MasterpassRetrieveLoyaltiesRequest struct {
Msisdn string `json:"msisdn,omitempty"`
BinNumber string `json:"binNumber,omitempty"`
CardName string `json:"cardName,omitempty"`
}

type InitGarantiPayPaymentRequest struct {
Price float64 `json:"price,omitempty"`
PaidPrice float64 `json:"paidPrice,omitempty"`
Expand Down
15 changes: 15 additions & 0 deletions tests/masterpass_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,18 @@ func TestMasterpass_Complete3DSMasterpassPayment(t *testing.T) {
t.Errorf("Error %s", err)
}
}

func TestMasterpass_RetrieveLoyalties(t *testing.T) {
request := adapter.MasterpassRetrieveLoyaltiesRequest{
Msisdn: "905436636070",
BinNumber: "404809",
CardName: "YKB Test Kart",
}

res, err := masterpassClient.Masterpass.RetrieveLoyalties(context.Background(), request)

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

0 comments on commit 0b5089c

Please sign in to comment.