Skip to content

Commit

Permalink
Adds tompay integration (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
abalikci committed Oct 31, 2023
1 parent c12ce29 commit 4362e26
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
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

0 comments on commit 4362e26

Please sign in to comment.