diff --git a/README.md b/README.md index e325cc7..49bb91f 100644 --- a/README.md +++ b/README.md @@ -148,6 +148,13 @@ assessment, err := client.RegisterPayment(&incognia.Payment{ AccountID: "account-id", ExternalID: "external-id", PolicyID: "policy-id", + Coupon: &incognia.CouponType{ + Type: "coupon-type", //it should be percent_off or fixed_value + Value: 55.02, + MaxDiscount: 30, + Id: "identifier", + Name: "coupon-name", + }, CustomProperties: myCustomPropertiesMap Addresses: []*incognia.TransactionAddress{ { diff --git a/incognia.go b/incognia.go index 36b8064..91cef97 100644 --- a/incognia.go +++ b/incognia.go @@ -51,6 +51,7 @@ type Payment struct { AccountID string ExternalID string PolicyID string + Coupon *CouponType Addresses []*TransactionAddress Value *PaymentValue Methods []*PaymentMethod @@ -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, diff --git a/incognia_test.go b/incognia_test.go index c2c8197..d19da74 100644 --- a/incognia_test.go +++ b/incognia_test.go @@ -178,11 +178,18 @@ var ( }, } postPaymentRequestBodyFixture = &postTransactionRequestBody{ - InstallationID: &installationId, - AccountID: "account-id", - ExternalID: "external-id", - PolicyID: "policy-id", - Type: paymentType, + InstallationID: &installationId, + AccountID: "account-id", + ExternalID: "external-id", + PolicyID: "policy-id", + Type: paymentType, + Coupon: &CouponType{ + Type: "coupon_type", + Value: 55.02, + MaxDiscount: 30, + Id: "identifier", + Name: "CouponName", + }, CustomProperties: customProperty, Addresses: []*TransactionAddress{ { @@ -229,7 +236,14 @@ var ( AccountID: "account-id", ExternalID: "external-id", PolicyID: "policy-id", - Type: paymentType, + Coupon: &CouponType{ + Type: "coupon_type", + Value: 55.02, + MaxDiscount: 30, + Id: "identifier", + Name: "CouponName", + }, + Type: paymentType, Addresses: []*TransactionAddress{ { Type: Billing, @@ -276,10 +290,17 @@ var ( Type: paymentType, } paymentFixture = &Payment{ - InstallationID: &installationId, - AccountID: "account-id", - ExternalID: "external-id", - PolicyID: "policy-id", + InstallationID: &installationId, + AccountID: "account-id", + ExternalID: "external-id", + PolicyID: "policy-id", + Coupon: &CouponType{ + Type: "coupon_type", + Value: 55.02, + MaxDiscount: 30, + Id: "identifier", + Name: "CouponName", + }, CustomProperties: customProperty, Addresses: []*TransactionAddress{ { @@ -326,6 +347,13 @@ var ( AccountID: "account-id", ExternalID: "external-id", PolicyID: "policy-id", + Coupon: &CouponType{ + Type: "coupon_type", + Value: 55.02, + MaxDiscount: 30, + Id: "identifier", + Name: "CouponName", + }, Addresses: []*TransactionAddress{ { Type: Billing, diff --git a/request_types.go b/request_types.go index 84eb31a..3d1f592 100644 --- a/request_types.go +++ b/request_types.go @@ -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 ( @@ -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"`