-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds instant transfer with Compay integration as apm
- Loading branch information
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()) | ||
Check failure on line 16 in tests/instant_transfer_payment_test.go GitHub Actions / build
|
||
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, | ||
Check failure on line 28 in tests/instant_transfer_payment_test.go GitHub Actions / build
|
||
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) | ||
} | ||
} |