Skip to content

Commit

Permalink
Adds tom finance
Browse files Browse the repository at this point in the history
  • Loading branch information
abalikci committed Nov 24, 2023
1 parent 90b67da commit bebf46c
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 21 deletions.
43 changes: 22 additions & 21 deletions adapter/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const (
ApmType_TOMPAY ApmType = "TOMPAY"
ApmType_MASLAK ApmType = "MASLAK"
ApmType_ALFABANK ApmType = "ALFABANK"
ApmType_TOM_FINANCE ApmType = "TOM_FINANCE"
ApmType_STRIPE ApmType = "STRIPE"
ApmType_FUND_TRANSFER ApmType = "FUND_TRANSFER"
ApmType_CASH_ON_DELIVERY ApmType = "CASH_ON_DELIVERY"
Expand Down Expand Up @@ -807,27 +808,27 @@ type MasterpassPaymentThreeDSCompleteRequest struct {
}

type InitBnplPaymentRequest struct {
ApmType ApmType `json:"apmType"`
MerchantApmId int64 `json:"merchantApmId,omitempty"`
Price float64 `json:"price"`
PaidPrice float64 `json:"paidPrice"`
CommissionRate float64 `json:"commissionRate,omitempty"`
Currency Currency `json:"currency"`
PaymentType PaymentType `json:"paymentType"`
PaymentGroup PaymentGroup `json:"paymentGroup"`
PaymentSource PaymentSource `json:"paymentSource,omitempty"`
PaymentChannel string `json:"paymentChannel,omitempty"`
ConversationId string `json:"conversationId,omitempty"`
ExternalId string `json:"externalId,omitempty"`
CallbackUrl string `json:"callbackUrl"`
BuyerMemberId int64 `json:"buyerMemberId,omitempty"`
ApmOrderId string `json:"apmOrderId,omitempty"`
ClientIp string `json:"clientIp,omitempty"`
ApmUserIdentity string `json:"apmUserIdentity,omitempty"`
AdditionalParams map[string]interface{} `json:"additionalParams"`
Items []PaymentItem `json:"items"`
BankCode string `json:"bankCode"`
CartItems []BnplPaymentCartItem `json:"cartItems"`
ApmType ApmType `json:"apmType"`
MerchantApmId int64 `json:"merchantApmId,omitempty"`
Price float64 `json:"price"`
PaidPrice float64 `json:"paidPrice"`
CommissionRate float64 `json:"commissionRate,omitempty"`
Currency Currency `json:"currency"`
PaymentType PaymentType `json:"paymentType"`
PaymentGroup PaymentGroup `json:"paymentGroup"`
PaymentSource PaymentSource `json:"paymentSource,omitempty"`
PaymentChannel string `json:"paymentChannel,omitempty"`
ConversationId string `json:"conversationId,omitempty"`
ExternalId string `json:"externalId,omitempty"`
CallbackUrl string `json:"callbackUrl"`
BuyerMemberId int64 `json:"buyerMemberId,omitempty"`
ApmOrderId string `json:"apmOrderId,omitempty"`
ClientIp string `json:"clientIp,omitempty"`
ApmUserIdentity string `json:"apmUserIdentity,omitempty"`
AdditionalParams map[string]string `json:"additionalParams"`
Items []PaymentItem `json:"items"`
BankCode string `json:"bankCode,omitempty"`
CartItems []BnplPaymentCartItem `json:"cartItems"`
}

type BnplPaymentCartItem struct {
Expand Down
42 changes: 42 additions & 0 deletions tests/payment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,48 @@ func TestPayment_InitBnplPayment(t *testing.T) {
}
}

func TestPayment_InitTomFinanceBnplPayment(t *testing.T) {
request := adapter.InitBnplPaymentRequest{
ApmType: craftgate.ApmType_TOM_FINANCE,
Price: 100,
PaidPrice: 100,
PaymentType: craftgate.PaymentType_APM,
Currency: craftgate.Currency_TRY,
ApmOrderId: "myUniqueApmOrderId",
PaymentGroup: craftgate.PaymentGroup_PRODUCT,
ConversationId: "conversationId",
ExternalId: "externalId",
CallbackUrl: "https://www.your-website.com/callback",
Items: []craftgate.PaymentItem{
{
Name: "Item 1",
Price: 100,
ExternalId: "externalId",
},
},
AdditionalParams: map[string]string{
"buyerName": "John Doe",
"buyerPhoneNumber": "5554443322",
},
CartItems: []craftgate.BnplPaymentCartItem{
{
Id: "26020874",
Name: "Test Item 1",
BrandName: "26010303",
Type: craftgate.BnplCartItemType_OTHER,
UnitPrice: 100,
Quantity: 1,
},
},
}
res, err := paymentClient.Payment.InitBnplPayment(context.Background(), request)
_, _ = spew.Printf("%#v\n", res)

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

func TestPayment_ApproveBnplPayment(t *testing.T) {
err := paymentClient.Payment.ApproveBnplPayment(context.Background(), 1)
if err != nil {
Expand Down

0 comments on commit bebf46c

Please sign in to comment.