From f27292f1bce6110f4b62ee8b0d718ee2a476e6a5 Mon Sep 17 00:00:00 2001 From: semihshn Date: Wed, 20 Mar 2024 12:02:23 +0300 Subject: [PATCH] Adds instant transfer with Compay integration as apm --- tests/instant_transfer_payment_test.go | 53 ++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 tests/instant_transfer_payment_test.go diff --git a/tests/instant_transfer_payment_test.go b/tests/instant_transfer_payment_test.go new file mode 100644 index 0000000..0a9bd52 --- /dev/null +++ b/tests/instant_transfer_payment_test.go @@ -0,0 +1,53 @@ +package tests + +import ( + "context" + "testing" + + "github.com/craftgate/craftgate-go-client/adapter" + craftgate "github.com/craftgate/craftgate-go-client/adapter" + "github.com/davecgh/go-spew/spew" + "github.com/stretchr/testify/require" +) + +var instantTransferPaymentClient, _ = craftgate.New("api-key", "secret-key", "https://sandbox-api.craftgate.io") + +func TestRetrieveActiveBanks(t *testing.T) { + res, err := instantTransferPaymentClient.Payment.RetrieveActiveBanks(context.Background()) + require.NotEmpty(t, res.Items) + if err != nil { + t.Errorf("Error %s", err) + } +} + +func TestInitCompayAPMPayment(t *testing.T) { + additionalParams := make(map[string]string) + additionalParams["bankCode"] = "0" + + request := adapter.InitApmPaymentRequest{ + ApmType: craftgate.ApmType_COMPAY, + Price: 1, + PaidPrice: 1, + Currency: craftgate.Currency_TRY, + PaymentGroup: craftgate.PaymentGroup_LISTING_OR_SUBSCRIPTION, + ConversationId: "foo-bar", + CallbackUrl: "https://www.your-website.com/callback", + Items: []craftgate.PaymentItem{ + { + Name: "Item 1", + Price: 0.6, + }, + { + Name: "Item 2", + Price: 0.4, + }, + }, + AdditionalParams: additionalParams, + } + res, err := instantTransferPaymentClient.Payment.InitApmPayment(context.Background(), request) + _, _ = spew.Printf("%#v\n", res) + + if err != nil { + t.Errorf("Error %s", err) + } +}