Skip to content

Commit

Permalink
Add coupon property to payment request body
Browse files Browse the repository at this point in the history
  • Loading branch information
soareswallace committed Jan 22, 2025
1 parent e20e806 commit 9c38f5d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@ assessment, err := client.RegisterPayment(&incognia.Payment{
AccountID: "account-id",
ExternalID: "external-id",
PolicyID: "policy-id",
Coupon: &incognia.Coupon{
Type: "coupon-type",
Value: 55.02,
MaxDiscount: 30,
Id: "identifier",
Name: "coupon-name",
},
CustomProperties: myCustomPropertiesMap
Addresses: []*incognia.TransactionAddress{
{
Expand Down
2 changes: 2 additions & 0 deletions incognia.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type Payment struct {
AccountID string
ExternalID string
PolicyID string
Coupon *CouponType
Addresses []*TransactionAddress
Value *PaymentValue
Methods []*PaymentMethod
Expand Down Expand Up @@ -290,6 +291,7 @@ func (c *Client) registerPayment(payment *Payment) (ret *TransactionAssessment,
Type: paymentType,
AccountID: payment.AccountID,
PolicyID: payment.PolicyID,
Coupon: payment.Coupon,
ExternalID: payment.ExternalID,
Addresses: payment.Addresses,
PaymentValue: payment.Value,
Expand Down
9 changes: 9 additions & 0 deletions request_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ type PaymentValue struct {
Currency string `json:"currency"`
}

type CouponType struct {
Type string `json:"type"`
Value float64 `json:"value"`
MaxDiscount float64 `json:"max_discount"`
Id string `json:"id"`
Name string `json:"name"`
}

type paymentMethodType string

const (
Expand Down Expand Up @@ -136,6 +144,7 @@ type PaymentMethod struct {
type postTransactionRequestBody struct {
ExternalID string `json:"external_id,omitempty"`
PolicyID string `json:"policy_id,omitempty"`
Coupon *CouponType `json:"coupon,omitempty"`
InstallationID *string `json:"installation_id,omitempty"`
PaymentMethodIdentifier string `json:"payment_method_identifier,omitempty"`
Type transactionType `json:"type"`
Expand Down

0 comments on commit 9c38f5d

Please sign in to comment.