Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add masterpass loyalty retrieve endpoint #86

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: "900000000000",
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)
}
}
Loading