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

Adds tompay integration #52

Merged
merged 1 commit into from
Oct 31, 2023
Merged
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
11 changes: 8 additions & 3 deletions adapter/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ const (
ApmType_KLARNA ApmType = "KLARNA"
ApmType_AFTERPAY ApmType = "AFTERPAY"
ApmType_KASPI ApmType = "KASPI"
ApmType_TOMPAY ApmType = "TOMPAY"
ApmType_STRIPE ApmType = "STRIPE"
ApmType_FUND_TRANSFER ApmType = "FUND_TRANSFER"
ApmType_CASH_ON_DELIVERY ApmType = "CASH_ON_DELIVERY"
Expand All @@ -97,6 +98,7 @@ const (
PaymentProvider_KLARNA PaymentProvider = "KLARNA"
PaymentProvider_AFTERPAY PaymentProvider = "AFTERPAY"
PaymentProvider_KASPI PaymentProvider = "KASPI"
PaymentProvider_TOMPAY PaymentProvider = "TOMPAY"
PaymentProvider_APPLEPAY PaymentProvider = "APPLEPAY"
PaymentProvider_GOOGLEPAY PaymentProvider = "GOOGLEPAY"
PaymentProvider_HEPSIPAY PaymentProvider = "HEPSIPAY"
Expand Down Expand Up @@ -169,6 +171,7 @@ const (
PaymentMethod_KLARNA PaymentMethod = "KLARNA"
PaymentMethod_AFTERPAY PaymentMethod = "AFTERPAY"
PaymentMethod_KASPI PaymentMethod = "KASPI"
PaymentMethod_TOMPAY PaymentMethod = "TOMPAY"
PaymentMethod_STRIPE PaymentMethod = "STRIPE"
)

Expand Down Expand Up @@ -316,9 +319,11 @@ const (

// apm additional action type declaration
const (
ApmAdditionalAction_REDIRECT_TO_URL ApmAdditionalAction = "REDIRECT_TO_URL"
ApmAdditionalAction_OTP_REQUIRED ApmAdditionalAction = "OTP_REQUIRED"
ApmAdditionalAction_NONE ApmAdditionalAction = "NONE"
ApmAdditionalAction_REDIRECT_TO_URL ApmAdditionalAction = "REDIRECT_TO_URL"
ApmAdditionalAction_OTP_REQUIRED ApmAdditionalAction = "OTP_REQUIRED"
ApmAdditionalAction_WAIT_FOR_WEBHOOK ApmAdditionalAction = "WAIT_FOR_WEBHOOK"
ApmAdditionalAction_APPROVAL_REQUIRED ApmAdditionalAction = "APPROVAL_REQUIRED"
ApmAdditionalAction_NONE ApmAdditionalAction = "NONE"
)

// report file type declaration
Expand Down
33 changes: 33 additions & 0 deletions tests/payment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,39 @@ func TestPayment_InitKaspiApmPayment(t *testing.T) {
}
}

func TestPayment_InitTompayApmPayment(t *testing.T) {
additionalParams := make(map[string]string)
additionalParams["phone"] = "phone"
additionalParams["channel"] = "channel"

request := adapter.InitApmPaymentRequest{
ApmType: craftgate.ApmType_TOMPAY,
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 := paymentClient.Payment.InitApmPayment(context.Background(), request)
_, _ = spew.Printf("%#v\n", res)

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

func TestPayment_CompleteApmPayment(t *testing.T) {
request := adapter.CompleteApmPaymentRequest{
PaymentId: 123,
Expand Down
Loading