From 10884102ae1e600fb1228113ee4517a02a77731f Mon Sep 17 00:00:00 2001 From: Victor Hugo Avelar Ossorio Date: Fri, 24 May 2024 13:56:21 +0000 Subject: [PATCH 1/2] feat(payments): add support for lines in payments --- mollie/payments.go | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/mollie/payments.go b/mollie/payments.go index 74cf420..a5176ee 100644 --- a/mollie/payments.go +++ b/mollie/payments.go @@ -74,6 +74,9 @@ type CreatePayment struct { Method []PaymentMethod `json:"method,omitempty"` Metadata any `json:"metadata,omitempty"` + // Beta fields + Lines []PaymentLines `json:"lines,omitempty"` + // PaymentMethods specific fields DigitalGoods bool `json:"digitalGoods,omitempty"` ApplePayPaymentToken string `json:"applePayPaymentToken,omitempty"` @@ -137,6 +140,37 @@ type CreateMollieConnectPaymentFields struct { Routing []*PaymentRouting `json:"routing,omitempty"` } +// PaymentLineType reflects the type of product bought. +type PaymentLineType string + +// Supported payment line types. +const ( + PhysicalProductLine PaymentLineType = "physical" + DiscountProductLine PaymentLineType = "discount" + DigitalProductLine PaymentLineType = "digital" + ShippingFeeLine PaymentLineType = "shipping_fee" + StoreCreditLine PaymentLineType = "store_credit" + GiftCardLine PaymentLineType = "gift_card" + SurchargeLine PaymentLineType = "surcharge" +) + +// PaymentLines describes the payment lines to be sent to the Mollie API when +// creating a new payment. +type PaymentLines struct { + Quantity int `json:"quantity,omitempty"` + Description string `json:"description,omitempty"` + QuantityUnit string `json:"quantityUnit,omitempty"` + SKU string `json:"sku,omitempty"` + ImageURL string `json:"imageUrl,omitempty"` + ProductURL string `json:"productUrl,omitempty"` + VATRate string `json:"vatRate,omitempty"` + UnitPrice *Amount `json:"unitPrice,omitempty"` + DiscountAmount *Amount `json:"discountAmount,omitempty"` + TotalAmount *Amount `json:"totalAmount,omitempty"` + VATAmount *Amount `json:"vatAmount,omitempty"` + Type PaymentLineType `json:"type,omitempty"` +} + // UpdatePayment describes the payload to be sent to the Mollie API when // updating a payment. // @@ -191,6 +225,9 @@ type Payment struct { AmountChargedBack *Amount `json:"amountChargeback,omitempty"` SettlementAmount *Amount `json:"settlementAmount,omitempty"` + // Beta fields + Lines []PaymentLines `json:"lines,omitempty"` + // PaymentMethods specific fields Details PaymentDetails `json:"details,omitempty"` From 236e3eee2b1755334cd75b3772dbd63e6aa588bc Mon Sep 17 00:00:00 2001 From: Victor Hugo Avelar Ossorio Date: Fri, 24 May 2024 15:03:38 +0000 Subject: [PATCH 2/2] chore(docs): update generated docs --- docs/README.md | 95 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 74 insertions(+), 21 deletions(-) diff --git a/docs/README.md b/docs/README.md index 3ffc747..bf1a087 100644 --- a/docs/README.md +++ b/docs/README.md @@ -239,6 +239,8 @@ REST also implies a nice and clean structure for URLs or endpoints. This means y - [type PaymentDestination](<#PaymentDestination>) - [type PaymentDetails](<#PaymentDetails>) - [type PaymentDetailsAddress](<#PaymentDetailsAddress>) +- [type PaymentLineType](<#PaymentLineType>) +- [type PaymentLines](<#PaymentLines>) - [type PaymentLink](<#PaymentLink>) - [type PaymentLinkLinks](<#PaymentLinkLinks>) - [type PaymentLinkOptions](<#PaymentLinkOptions>) @@ -422,7 +424,7 @@ func CheckResponse(r *Response) error CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range. API error responses are expected to have either no response body, or a JSON response body. -## type [AccessTokenPaymentFields]() +## type [AccessTokenPaymentFields]() AccessTokenPaymentFields describes the fields specific to payments created using an access token. @@ -1882,7 +1884,7 @@ type CreateMandateAccessTokenFields struct { ``` -## type [CreateMollieConnectPaymentFields]() +## type [CreateMollieConnectPaymentFields]() CreateMollieConnectPaymentFields describes the fields to be sent to the Mollie API when creating a new payment using Mollie Connect. @@ -1954,7 +1956,7 @@ type CreateOrderRefund struct { ``` -## type [CreatePayment]() +## type [CreatePayment]() CreatePayment describes the payload to be sent to the Mollie API when creating or updating a new payment. @@ -1974,6 +1976,9 @@ type CreatePayment struct { Method []PaymentMethod `json:"method,omitempty"` Metadata any `json:"metadata,omitempty"` + // Beta fields + Lines []PaymentLines `json:"lines,omitempty"` + // PaymentMethods specific fields DigitalGoods bool `json:"digitalGoods,omitempty"` ApplePayPaymentToken string `json:"applePayPaymentToken,omitempty"` @@ -2002,7 +2007,7 @@ type CreatePayment struct { ``` -## type [CreatePaymentAccessTokenFields]() +## type [CreatePaymentAccessTokenFields]() CreatePaymentAccessTokenFields describes the fields to be sent to the Mollie API when creating a new payment using an access token. @@ -2031,7 +2036,7 @@ type CreatePaymentRefund struct { ``` -## type [CreatePreAuthorizedPaymentFields]() +## type [CreatePreAuthorizedPaymentFields]() CreatePreAuthorizedPaymentFields describes the fields to be sent to the Mollie API when creating a new pre\-authorized payment. @@ -2045,7 +2050,7 @@ type CreatePreAuthorizedPaymentFields struct { ``` -## type [CreateRecurrentPaymentFields]() +## type [CreateRecurrentPaymentFields]() CreateRecurrentPaymentFields describes the fields to be sent to the Mollie API when creating a new recurrent payment. @@ -2819,7 +2824,7 @@ type ListPaymentMethodsOptions struct { ``` -## type [ListPaymentsOptions]() +## type [ListPaymentsOptions]() ListPaymentsOptions describes list payments endpoint valid query string parameters. @@ -3116,7 +3121,7 @@ const ( ``` -## type [MollieConnectPaymentFields]() +## type [MollieConnectPaymentFields]() MollieConnectPaymentFields describes the fields specific to Mollie Connect payments. @@ -3895,7 +3900,7 @@ const ( ``` -## type [Payment]() +## type [Payment]() Payment describes a transaction between a customer and a merchant. @@ -3932,6 +3937,9 @@ type Payment struct { AmountChargedBack *Amount `json:"amountChargeback,omitempty"` SettlementAmount *Amount `json:"settlementAmount,omitempty"` + // Beta fields + Lines []PaymentLines `json:"lines,omitempty"` + // PaymentMethods specific fields Details PaymentDetails `json:"details,omitempty"` @@ -4029,6 +4037,51 @@ type PaymentDetailsAddress struct { } ``` + +## type [PaymentLineType]() + +PaymentLineType reflects the type of product bought. + +```go +type PaymentLineType string +``` + +Supported payment line types. + +```go +const ( + PhysicalProductLine PaymentLineType = "physical" + DiscountProductLine PaymentLineType = "discount" + DigitalProductLine PaymentLineType = "digital" + ShippingFeeLine PaymentLineType = "shipping_fee" + StoreCreditLine PaymentLineType = "store_credit" + GiftCardLine PaymentLineType = "gift_card" + SurchargeLine PaymentLineType = "surcharge" +) +``` + + +## type [PaymentLines]() + +PaymentLines describes the payment lines to be sent to the Mollie API when creating a new payment. + +```go +type PaymentLines struct { + Quantity int `json:"quantity,omitempty"` + Description string `json:"description,omitempty"` + QuantityUnit string `json:"quantityUnit,omitempty"` + SKU string `json:"sku,omitempty"` + ImageURL string `json:"imageUrl,omitempty"` + ProductURL string `json:"productUrl,omitempty"` + VATRate string `json:"vatRate,omitempty"` + UnitPrice *Amount `json:"unitPrice,omitempty"` + DiscountAmount *Amount `json:"discountAmount,omitempty"` + TotalAmount *Amount `json:"totalAmount,omitempty"` + VATAmount *Amount `json:"vatAmount,omitempty"` + Type PaymentLineType `json:"type,omitempty"` +} +``` + ## type [PaymentLink]() @@ -4085,7 +4138,7 @@ type PaymentLinkOptions struct { ``` -## type [PaymentLinks]() +## type [PaymentLinks]() PaymentLinks describes all the possible links to be returned with a payment object. @@ -4167,7 +4220,7 @@ List retrieves all payments links created with the current website profile, orde See: https://docs.mollie.com/reference/v2/payment-links-api/list-payment-links -## type [PaymentList]() +## type [PaymentList]() PaymentList describes how a list of payments will be retrieved by Mollie. @@ -4359,7 +4412,7 @@ The results are not paginated. See: https://docs.mollie.com/reference/v2/methods-api/list-methods -## type [PaymentOptions]() +## type [PaymentOptions]() PaymentOptions describes payments endpoint valid query string parameters. @@ -4420,7 +4473,7 @@ type PaymentRouting struct { ``` -## type [PaymentsService]() +## type [PaymentsService]() PaymentsService instance operates over payment resources. @@ -4429,7 +4482,7 @@ type PaymentsService service ``` -### func \(\*PaymentsService\) [Cancel]() +### func \(\*PaymentsService\) [Cancel]() ```go func (ps *PaymentsService) Cancel(ctx context.Context, id string) (res *Response, p *Payment, err error) @@ -4440,7 +4493,7 @@ Cancel removes a payment \(if possible\) from your Mollie account. See: https://docs.mollie.com/reference/v2/payments-api/cancel-payment -### func \(\*PaymentsService\) [Create]() +### func \(\*PaymentsService\) [Create]() ```go func (ps *PaymentsService) Create(ctx context.Context, p CreatePayment, opts *PaymentOptions) (res *Response, np *Payment, err error) @@ -4451,7 +4504,7 @@ Create stores a new payment object attached to your Mollie account. See: https://docs.mollie.com/reference/v2/payments-api/create-payment# -### func \(\*PaymentsService\) [Get]() +### func \(\*PaymentsService\) [Get]() ```go func (ps *PaymentsService) Get(ctx context.Context, id string, opts *PaymentOptions) (res *Response, p *Payment, err error) @@ -4460,7 +4513,7 @@ func (ps *PaymentsService) Get(ctx context.Context, id string, opts *PaymentOpti Get retrieves a single payment object by its payment token. -### func \(\*PaymentsService\) [List]() +### func \(\*PaymentsService\) [List]() ```go func (ps *PaymentsService) List(ctx context.Context, opts *ListPaymentsOptions) (res *Response, pl *PaymentList, err error) @@ -4471,7 +4524,7 @@ List retrieves a list of payments associated with your account/organization. See: https://docs.mollie.com/reference/v2/payments-api/list-payments -### func \(\*PaymentsService\) [Update]() +### func \(\*PaymentsService\) [Update]() ```go func (ps *PaymentsService) Update(ctx context.Context, id string, up UpdatePayment) (res *Response, p *Payment, err error) @@ -4607,7 +4660,7 @@ type PhoneNumber string ``` -## type [PreAuthorizedPaymentFields]() +## type [PreAuthorizedPaymentFields]() PreAuthorizedPaymentFields describes the fields specific to pre\-authorized payments. @@ -4939,7 +4992,7 @@ type Rate struct { ``` -## type [RecurrentPaymentFields]() +## type [RecurrentPaymentFields]() RecurrentPaymentFields describes the fields specific to recurrent payments. @@ -5961,7 +6014,7 @@ type UpdateOrderLine struct { ``` -## type [UpdatePayment]() +## type [UpdatePayment]() UpdatePayment describes the payload to be sent to the Mollie API when updating a payment.