diff --git a/adapter/model.go b/adapter/model.go index 48927d6..c1279c9 100644 --- a/adapter/model.go +++ b/adapter/model.go @@ -17,6 +17,7 @@ type CardAssociation string type CardExpiryStatus string type Currency string type LoyaltyType string +type MultiPaymentStatus string type PaymentRefundStatus string type RefundStatus string type RefundType string @@ -239,6 +240,12 @@ const ( LoyaltyType_POSTPONING_STATEMENT LoyaltyType = "POSTPONING_STATEMENT" ) +// multi payment status declaration +const ( + MultiPaymentStatus_CREATED MultiPaymentStatus = "CREATED" + MultiPaymentStatus_COMPLETED MultiPaymentStatus = "COMPLETED" +) + // payment refund status declaration const ( PaymentRefundStatus_NO_REFUND PaymentRefundStatus = "NO_REFUND" @@ -1450,6 +1457,7 @@ type CreateProductRequest struct { Price float64 `json:"price"` Currency Currency `json:"currency"` Description string `json:"description,omitempty"` + MultiPayment bool `json:"multiPayment,omitempty"` EnabledInstallments []int `json:"enabledInstallments"` } @@ -2109,6 +2117,18 @@ type MerchantPosCommissionResponse struct { MerchantCommissionRate float64 `json:"merchantCommissionRate"` } +type MultiPaymentResponse struct { + Id *int64 `json:"id"` + MultiPaymentStatus *MultiPaymentStatus `json:"multiPaymentStatus"` + Token *string `json:"token"` + ConversationId *string `json:"conversationId"` + ExternalId *string `json:"externalId"` + PaidPrice *float64 `json:"paidPrice"` + RemainingAmount *float64 `json:"remainingAmount"` + TokenExpireDate *TimeResponse `json:"tokenExpireDate"` + PaymentIds []int64 `json:"paymentIds"` +} + type CreateMerchantPosCommission struct { CardBrandName CardBrand `json:"cardBrandName,omitempty"` Installment int64 `json:"installment"` diff --git a/adapter/payment.go b/adapter/payment.go index e97eadd..1925616 100644 --- a/adapter/payment.go +++ b/adapter/payment.go @@ -598,6 +598,21 @@ func (api *Payment) CreateApplePayMerchantSession(ctx context.Context, request A return response.Data, nil } +func (api *Payment) RetrieveMultiPayment(ctx context.Context, token string) (*MultiPaymentResponse, error) { + newRequest, err := api.Client.NewRequest(ctx, http.MethodGet, fmt.Sprintf("/payment/v1/multi-payments/%s", token), nil) + if err != nil { + return nil, err + } + + response := &Response[MultiPaymentResponse]{} + err = api.Client.Do(ctx, newRequest, response) + if err != nil { + return nil, err + } + + return response.Data, nil +} + func (c *Payment) Is3DSecureCallbackVerified(threeDSecureCallbackKey string, params map[string]string) bool { hash := params["hash"] hashString := strings.Join([]string{threeDSecureCallbackKey, diff --git a/tests/payment_test.go b/tests/payment_test.go index f9a2349..9b1023b 100644 --- a/tests/payment_test.go +++ b/tests/payment_test.go @@ -950,3 +950,12 @@ func TestPayment_ApproveBnplPayment(t *testing.T) { t.Errorf("Error %s", err) } } + +func TestPayment_RetrieveMultiPayment(t *testing.T) { + res, err := paymentClient.Payment.RetrieveMultiPayment(context.Background(), "6d7e66b5-9b1c-4c1d-879a-2557b651096e") + _, _ = spew.Printf("%#v\n", res) + + if err != nil { + t.Errorf("Error %s", err) + } +}