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 metropol integration as APM #87

Merged
merged 2 commits into from
May 15, 2024
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
5 changes: 3 additions & 2 deletions adapter/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ const (
ApmType_PAPARA ApmType = "PAPARA"
ApmType_PAYONEER ApmType = "PAYONEER"
ApmType_SODEXO ApmType = "SODEXO"
ApmType_METROPOL ApmType = "METROPOL"
ApmType_EDENRED ApmType = "EDENRED"
ApmType_EDENRED_GIFT ApmType = "EDENRED_GIFT"
ApmType_PAYPAL ApmType = "PAYPAL"
Expand Down Expand Up @@ -107,6 +108,7 @@ const (
PaymentProvider_PAPARA PaymentProvider = "PAPARA"
PaymentProvider_PAYONEER PaymentProvider = "PAYONEER"
PaymentProvider_SODEXO PaymentProvider = "SODEXO"
PaymentProvider_METROPOL PaymentProvider = "METROPOL"
PaymentProvider_EDENRED PaymentProvider = "EDENRED"
PaymentProvider_ALIPAY PaymentProvider = "ALIPAY"
PaymentProvider_PAYPAL PaymentProvider = "PAYPAL"
Expand Down Expand Up @@ -197,9 +199,7 @@ const (
PaymentMethod_PAYPAL PaymentMethod = "PAYPAL"
PaymentMethod_KLARNA PaymentMethod = "KLARNA"
PaymentMethod_AFTERPAY PaymentMethod = "AFTERPAY"
PaymentMethod_KASPI PaymentMethod = "KASPI"
PaymentMethod_INSTANT_TRANSFER PaymentMethod = "INSTANT_TRANSFER"
PaymentMethod_TOMPAY PaymentMethod = "TOMPAY"
PaymentMethod_STRIPE PaymentMethod = "STRIPE"
)

Expand Down Expand Up @@ -1030,6 +1030,7 @@ type InitApmPaymentResponse struct {
PaymentStatus *PaymentStatus `json:"paymentStatus"`
ApmAdditionalAction *ApmAdditionalAction `json:"additionalAction"`
PaymentError *PaymentError `json:"paymentError"`
AdditionalData map[string]any `json:"additionalData"`
}

type CompleteApmPaymentResponse struct {
Expand Down
49 changes: 49 additions & 0 deletions tests/payment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,55 @@ func TestPayment_InitApmPayment(t *testing.T) {
}
}

func TestPayment_InitMetropolApmPayment(t *testing.T) {
request := adapter.InitApmPaymentRequest{
ApmType: craftgate.ApmType_METROPOL,
Price: 1.25,
PaidPrice: 1.25,
Currency: craftgate.Currency_TRY,
PaymentGroup: craftgate.PaymentGroup_LISTING_OR_SUBSCRIPTION,
ConversationId: "foo-bar",
Items: []craftgate.PaymentItem{
{
Name: "Item 1",
Price: 1,
ExternalId: "1",
},
{
Name: "Item 2",
Price: 0.25,
ExternalId: "2",
},
},
AdditionalParams: map[string]string{
"apmUserIdentity": "6375780115068760",
},
}
res, err := paymentClient.Payment.InitApmPayment(context.Background(), request)
_, _ = spew.Printf("%#v\n", res)

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

func TestPayment_CompleteMetropolApmPayment(t *testing.T) {
request := adapter.CompleteApmPaymentRequest{
PaymentId: 126,
AdditionalParams: map[string]string{
"otpCode": "00000",
"productId": "1",
"walletId": "1",
},
}
res, err := paymentClient.Payment.CompleteApmPayment(context.Background(), request)
_, _ = spew.Printf("%#v\n", res)

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

func TestPayment_InitKlarnaApmPayment(t *testing.T) {
request := adapter.InitApmPaymentRequest{
ApmType: craftgate.ApmType_KLARNA,
Expand Down
Loading