From e7733f9388239b7731064ee3c0aa814c4593b137 Mon Sep 17 00:00:00 2001 From: Avni BALIKCI <108258717+abalikci@users.noreply.github.com> Date: Thu, 28 Mar 2024 22:14:30 +0300 Subject: [PATCH 1/3] Add card clone adapter (#80) --- adapter/model.go | 10 +++++++--- adapter/payment.go | 16 ++++++++++++++++ tests/onboarding_test.go | 9 +++------ tests/payment_test.go | 14 ++++++++++++++ 4 files changed, 40 insertions(+), 9 deletions(-) diff --git a/adapter/model.go b/adapter/model.go index dc18ccc..48927d6 100644 --- a/adapter/model.go +++ b/adapter/model.go @@ -791,6 +791,13 @@ type UpdateStoredCardRequest struct { ExpireMonth string `json:"expireMonth,omitempty"` } +type CloneStoredCardRequest struct { + SourceCardUserKey string `json:"sourceCardUserKey"` + SourceCardToken string `json:"sourceCardToken"` + TargetCardUserKey string `json:"targetCardUserKey,omitempty"` + TargetMerchantId int64 `json:"targetMerchantId"` +} + type DeleteStoredCardRequest struct { CardUserKey string `json:"cardUserKey,omitempty"` CardToken string `json:"cardToken,omitempty"` @@ -1371,7 +1378,6 @@ type CreateMemberRequest struct { Address string `json:"address,omitempty"` Email string `json:"email,omitempty"` PhoneNumber string `json:"phoneNumber,omitempty"` - IdentityNumber string `json:"identityNumber,omitempty"` ContactName string `json:"contactName,omitempty"` ContactSurname string `json:"contactSurname,omitempty"` MemberType MemberType `json:"memberType,omitempty"` @@ -1390,7 +1396,6 @@ type UpdateMemberRequest struct { Address string `json:"address,omitempty"` Email string `json:"email,omitempty"` PhoneNumber string `json:"phoneNumber,omitempty"` - IdentityNumber string `json:"identityNumber,omitempty"` ContactName string `json:"contactName,omitempty"` ContactSurname string `json:"contactSurname,omitempty"` MemberType MemberType `json:"memberType,omitempty"` @@ -1428,7 +1433,6 @@ type MemberResponse struct { Email *string `json:"email"` Address *string `json:"address"` PhoneNumber *string `json:"phoneNumber"` - IdentityNumber *string `json:"identityNumber"` ContactName *string `json:"contactName"` ContactSurname *string `json:"contactSurname"` LegalCompanyTitle *string `json:"legalCompanyTitle"` diff --git a/adapter/payment.go b/adapter/payment.go index 8040c97..e97eadd 100644 --- a/adapter/payment.go +++ b/adapter/payment.go @@ -433,6 +433,22 @@ func (api *Payment) UpdateStoredCard(ctx context.Context, request UpdateStoredCa return response.Data, nil } +func (api *Payment) CloneStoredCard(ctx context.Context, request CloneStoredCardRequest) (*StoredCardResponse, error) { + newRequest, err := api.Client.NewRequest(ctx, http.MethodPost, "/payment/v1/cards/clone", request) + + if err != nil { + return nil, err + } + + response := &Response[StoredCardResponse]{} + err = api.Client.Do(ctx, newRequest, response) + if err != nil { + return nil, err + } + + return response.Data, nil +} + func (api *Payment) DeleteStoredCard(ctx context.Context, request DeleteStoredCardRequest) error { newRequest, err := api.Client.NewRequest(ctx, http.MethodPost, "/payment/v1/cards/delete", request) if err != nil { diff --git a/tests/onboarding_test.go b/tests/onboarding_test.go index e1bde82..6458faf 100644 --- a/tests/onboarding_test.go +++ b/tests/onboarding_test.go @@ -3,11 +3,12 @@ package tests import ( "context" "fmt" + "testing" + "time" + "github.com/craftgate/craftgate-go-client/adapter" craftgate "github.com/craftgate/craftgate-go-client/adapter" "github.com/davecgh/go-spew/spew" - "testing" - "time" ) var onboardingClient, _ = craftgate.New("api-key", "secret-key", "https://sandbox-api.craftgate.io") @@ -41,7 +42,6 @@ func Test_CreateSubMerchantMember(t *testing.T) { Email: "haluk.demir@example.com", PhoneNumber: "905551111111", Iban: "TR930006701000000001111111", - IdentityNumber: "11111111110", LegalCompanyTitle: "Dem Zeytinyağı Üretim Ltd. Şti.", Name: "Dem Zeytinyağı Üretim Ltd. Şti.", MemberType: craftgate.MemberType_LIMITED_OR_JOINT_STOCK_COMPANY, @@ -68,7 +68,6 @@ func Test_CreateBuyerAndSubMerchantMember(t *testing.T) { Email: "haluk.demir@example.com", PhoneNumber: "905551111111", Iban: "TR930006701000000001111111", - IdentityNumber: "11111111110", LegalCompanyTitle: "Dem Zeytinyağı Üretim Ltd. Şti.", Name: "Dem Zeytinyağı Üretim Ltd. Şti.", MemberType: craftgate.MemberType_LIMITED_OR_JOINT_STOCK_COMPANY, @@ -94,7 +93,6 @@ func Test_UpdateSubMerchantMember(t *testing.T) { Email: "haluk.demir@example.com", PhoneNumber: "905551111111", Iban: "TR930006701000000001111111", - IdentityNumber: "11111111110", LegalCompanyTitle: "Dem Zeytinyağı Üretim Ltd. Şti.", Name: "Dem Zeytinyağı Üretim Ltd. Şti.", MemberType: craftgate.MemberType_LIMITED_OR_JOINT_STOCK_COMPANY, @@ -121,7 +119,6 @@ func Test_UpdateBuyerMember(t *testing.T) { Email: "haluk.demir@example.com", PhoneNumber: "905551111111", Iban: "TR930006701000000001111111", - IdentityNumber: "11111111110", LegalCompanyTitle: "Dem Zeytinyağı Üretim Ltd. Şti.", Name: "Dem Zeytinyağı Üretim Ltd. Şti.", MemberType: craftgate.MemberType_PERSONAL, diff --git a/tests/payment_test.go b/tests/payment_test.go index bbbeab2..f9a2349 100644 --- a/tests/payment_test.go +++ b/tests/payment_test.go @@ -704,6 +704,20 @@ func TestPayment_UpdateStoredCard(t *testing.T) { } } +func TestPayment_CloneStoredCard(t *testing.T) { + request := adapter.CloneStoredCardRequest{ + SourceCardUserKey: "6bcbac4b-6460-418d-b060-2d9896c08156", + SourceCardToken: "aa57f470-7423-449e-87b7-afb1fba151fb", + TargetMerchantId: 1, + } + res, err := paymentClient.Payment.CloneStoredCard(context.Background(), request) + _, _ = spew.Printf("%#v\n", res) + + if err != nil { + t.Errorf("Error %s", err) + } +} + func TestPayment_DeleteStoredCard(t *testing.T) { request := adapter.DeleteStoredCardRequest{ CardUserKey: "d94018bb-baa9-4418-84f8-760942f669af", From e4975ec365dec5a4b102b7c46b0c82f4c6c67de2 Mon Sep 17 00:00:00 2001 From: semihshn Date: Fri, 29 Mar 2024 15:54:44 +0300 Subject: [PATCH 2/3] Removes identity number field on onboarding flow --- tests/onboarding_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/onboarding_test.go b/tests/onboarding_test.go index 6458faf..6b560bc 100644 --- a/tests/onboarding_test.go +++ b/tests/onboarding_test.go @@ -42,6 +42,7 @@ func Test_CreateSubMerchantMember(t *testing.T) { Email: "haluk.demir@example.com", PhoneNumber: "905551111111", Iban: "TR930006701000000001111111", + IdentityNumber: "11111111110", LegalCompanyTitle: "Dem Zeytinyağı Üretim Ltd. Şti.", Name: "Dem Zeytinyağı Üretim Ltd. Şti.", MemberType: craftgate.MemberType_LIMITED_OR_JOINT_STOCK_COMPANY, From e462cbc2f84516fefa38044f3b83d887c62250a1 Mon Sep 17 00:00:00 2001 From: semihshn Date: Fri, 29 Mar 2024 15:55:30 +0300 Subject: [PATCH 3/3] Update --- tests/onboarding_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/onboarding_test.go b/tests/onboarding_test.go index 6b560bc..6458faf 100644 --- a/tests/onboarding_test.go +++ b/tests/onboarding_test.go @@ -42,7 +42,6 @@ func Test_CreateSubMerchantMember(t *testing.T) { Email: "haluk.demir@example.com", PhoneNumber: "905551111111", Iban: "TR930006701000000001111111", - IdentityNumber: "11111111110", LegalCompanyTitle: "Dem Zeytinyağı Üretim Ltd. Şti.", Name: "Dem Zeytinyağı Üretim Ltd. Şti.", MemberType: craftgate.MemberType_LIMITED_OR_JOINT_STOCK_COMPANY,