From af4dd343d956542e97c2e81512744660ccceb4bc Mon Sep 17 00:00:00 2001 From: Ingenico ePayments Date: Mon, 16 Oct 2023 13:39:48 +0200 Subject: [PATCH] Release 2.43.0. --- communicator/MetaDataProvider.go | 2 +- domain/hostedcheckout/Frequency.go | 15 ++++ .../hostedcheckout/RecurringPaymentsData.go | 15 ++++ domain/hostedcheckout/SpecificInput.go | 1 + domain/hostedcheckout/TrialInformation.go | 20 +++++ domain/hostedcheckout/TrialPeriod.go | 15 ++++ domain/installments/GetInstallmentRequest.go | 19 +++++ .../installments/InstallmentDisplayHints.go | 16 ++++ domain/installments/InstallmentOptions.go | 18 +++++ .../InstallmentOptionsResponse.go | 14 ++++ domain/payment/Installments.go | 1 + .../GetInstallmentsInfoExample.go | 38 ++++++++++ examples/merchant/installments/Helper.go | 51 +++++++++++++ merchant/Client.go | 6 ++ merchant/installments/Client.go | 75 +++++++++++++++++++ 15 files changed, 305 insertions(+), 1 deletion(-) create mode 100644 domain/hostedcheckout/Frequency.go create mode 100644 domain/hostedcheckout/RecurringPaymentsData.go create mode 100644 domain/hostedcheckout/TrialInformation.go create mode 100644 domain/hostedcheckout/TrialPeriod.go create mode 100644 domain/installments/GetInstallmentRequest.go create mode 100644 domain/installments/InstallmentDisplayHints.go create mode 100644 domain/installments/InstallmentOptions.go create mode 100644 domain/installments/InstallmentOptionsResponse.go create mode 100644 examples/merchant/installments/GetInstallmentsInfoExample.go create mode 100644 examples/merchant/installments/Helper.go create mode 100644 merchant/installments/Client.go diff --git a/communicator/MetaDataProvider.go b/communicator/MetaDataProvider.go index 0738424..e98c4a7 100644 --- a/communicator/MetaDataProvider.go +++ b/communicator/MetaDataProvider.go @@ -40,7 +40,7 @@ func getPlatformIdentifier() string { } const sdkIdentifier = "GoServerSDK/v" + sdkVersion -const sdkVersion = "2.42.0" +const sdkVersion = "2.43.0" const serverMetaInfoHeader = "X-GCS-ServerMetaInfo" // NewMetaDataProviderWithBuilder creates a MetaDataProvider with the given MetaDataProviderBuilder diff --git a/domain/hostedcheckout/Frequency.go b/domain/hostedcheckout/Frequency.go new file mode 100644 index 0000000..1f4bf06 --- /dev/null +++ b/domain/hostedcheckout/Frequency.go @@ -0,0 +1,15 @@ +// This class was auto-generated from the API references found at +// https://epayments-api.developer-ingenico.com/s2sapi/v1/ + +package hostedcheckout + +// Frequency represents class Frequency +type Frequency struct { + Interval *string `json:"interval,omitempty"` + IntervalFrequency *int32 `json:"intervalFrequency,omitempty"` +} + +// NewFrequency constructs a new Frequency +func NewFrequency() *Frequency { + return &Frequency{} +} diff --git a/domain/hostedcheckout/RecurringPaymentsData.go b/domain/hostedcheckout/RecurringPaymentsData.go new file mode 100644 index 0000000..c1af77b --- /dev/null +++ b/domain/hostedcheckout/RecurringPaymentsData.go @@ -0,0 +1,15 @@ +// This class was auto-generated from the API references found at +// https://epayments-api.developer-ingenico.com/s2sapi/v1/ + +package hostedcheckout + +// RecurringPaymentsData represents class RecurringPaymentsData +type RecurringPaymentsData struct { + RecurringInterval *Frequency `json:"recurringInterval,omitempty"` + TrialInformation *TrialInformation `json:"trialInformation,omitempty"` +} + +// NewRecurringPaymentsData constructs a new RecurringPaymentsData +func NewRecurringPaymentsData() *RecurringPaymentsData { + return &RecurringPaymentsData{} +} diff --git a/domain/hostedcheckout/SpecificInput.go b/domain/hostedcheckout/SpecificInput.go index 9c54a6e..683113b 100644 --- a/domain/hostedcheckout/SpecificInput.go +++ b/domain/hostedcheckout/SpecificInput.go @@ -8,6 +8,7 @@ type SpecificInput struct { IsRecurring *bool `json:"isRecurring,omitempty"` Locale *string `json:"locale,omitempty"` PaymentProductFilters *PaymentProductFiltersHostedCheckout `json:"paymentProductFilters,omitempty"` + RecurringPaymentsData *RecurringPaymentsData `json:"recurringPaymentsData,omitempty"` ReturnCancelState *bool `json:"returnCancelState,omitempty"` ReturnURL *string `json:"returnUrl,omitempty"` ShowResultPage *bool `json:"showResultPage,omitempty"` diff --git a/domain/hostedcheckout/TrialInformation.go b/domain/hostedcheckout/TrialInformation.go new file mode 100644 index 0000000..3f642d9 --- /dev/null +++ b/domain/hostedcheckout/TrialInformation.go @@ -0,0 +1,20 @@ +// This class was auto-generated from the API references found at +// https://epayments-api.developer-ingenico.com/s2sapi/v1/ + +package hostedcheckout + +import "github.com/Ingenico-ePayments/connect-sdk-go/domain/definitions" + +// TrialInformation represents class TrialInformation +type TrialInformation struct { + AmountOfMoneyAfterTrial *definitions.AmountOfMoney `json:"amountOfMoneyAfterTrial,omitempty"` + EndDate *string `json:"endDate,omitempty"` + IsRecurring *bool `json:"isRecurring,omitempty"` + TrialPeriod *TrialPeriod `json:"trialPeriod,omitempty"` + TrialPeriodRecurring *Frequency `json:"trialPeriodRecurring,omitempty"` +} + +// NewTrialInformation constructs a new TrialInformation +func NewTrialInformation() *TrialInformation { + return &TrialInformation{} +} diff --git a/domain/hostedcheckout/TrialPeriod.go b/domain/hostedcheckout/TrialPeriod.go new file mode 100644 index 0000000..5c7fc7e --- /dev/null +++ b/domain/hostedcheckout/TrialPeriod.go @@ -0,0 +1,15 @@ +// This class was auto-generated from the API references found at +// https://epayments-api.developer-ingenico.com/s2sapi/v1/ + +package hostedcheckout + +// TrialPeriod represents class TrialPeriod +type TrialPeriod struct { + Duration *int32 `json:"duration,omitempty"` + Interval *string `json:"interval,omitempty"` +} + +// NewTrialPeriod constructs a new TrialPeriod +func NewTrialPeriod() *TrialPeriod { + return &TrialPeriod{} +} diff --git a/domain/installments/GetInstallmentRequest.go b/domain/installments/GetInstallmentRequest.go new file mode 100644 index 0000000..034c6c3 --- /dev/null +++ b/domain/installments/GetInstallmentRequest.go @@ -0,0 +1,19 @@ +// This class was auto-generated from the API references found at +// https://epayments-api.developer-ingenico.com/s2sapi/v1/ + +package installments + +import "github.com/Ingenico-ePayments/connect-sdk-go/domain/definitions" + +// GetInstallmentRequest represents class GetInstallmentRequest +type GetInstallmentRequest struct { + AmountOfMoney *definitions.AmountOfMoney `json:"amountOfMoney,omitempty"` + Bin *string `json:"bin,omitempty"` + CountryCode *string `json:"countryCode,omitempty"` + PaymentProductID *int32 `json:"paymentProductId,omitempty"` +} + +// NewGetInstallmentRequest constructs a new GetInstallmentRequest +func NewGetInstallmentRequest() *GetInstallmentRequest { + return &GetInstallmentRequest{} +} diff --git a/domain/installments/InstallmentDisplayHints.go b/domain/installments/InstallmentDisplayHints.go new file mode 100644 index 0000000..eaa879f --- /dev/null +++ b/domain/installments/InstallmentDisplayHints.go @@ -0,0 +1,16 @@ +// This class was auto-generated from the API references found at +// https://epayments-api.developer-ingenico.com/s2sapi/v1/ + +package installments + +// InstallmentDisplayHints represents class InstallmentDisplayHints +type InstallmentDisplayHints struct { + DisplayOrder *int32 `json:"displayOrder,omitempty"` + Label *string `json:"label,omitempty"` + Logo *string `json:"logo,omitempty"` +} + +// NewInstallmentDisplayHints constructs a new InstallmentDisplayHints +func NewInstallmentDisplayHints() *InstallmentDisplayHints { + return &InstallmentDisplayHints{} +} diff --git a/domain/installments/InstallmentOptions.go b/domain/installments/InstallmentOptions.go new file mode 100644 index 0000000..1153b70 --- /dev/null +++ b/domain/installments/InstallmentOptions.go @@ -0,0 +1,18 @@ +// This class was auto-generated from the API references found at +// https://epayments-api.developer-ingenico.com/s2sapi/v1/ + +package installments + +import "github.com/Ingenico-ePayments/connect-sdk-go/domain/payment" + +// InstallmentOptions represents class InstallmentOptions +type InstallmentOptions struct { + DisplayHints *InstallmentDisplayHints `json:"displayHints,omitempty"` + ID *string `json:"id,omitempty"` + InstallmentPlans *[]payment.Installments `json:"installmentPlans,omitempty"` +} + +// NewInstallmentOptions constructs a new InstallmentOptions +func NewInstallmentOptions() *InstallmentOptions { + return &InstallmentOptions{} +} diff --git a/domain/installments/InstallmentOptionsResponse.go b/domain/installments/InstallmentOptionsResponse.go new file mode 100644 index 0000000..ee26983 --- /dev/null +++ b/domain/installments/InstallmentOptionsResponse.go @@ -0,0 +1,14 @@ +// This class was auto-generated from the API references found at +// https://epayments-api.developer-ingenico.com/s2sapi/v1/ + +package installments + +// InstallmentOptionsResponse represents class InstallmentOptionsResponse +type InstallmentOptionsResponse struct { + InstallmentOptions *[]InstallmentOptions `json:"installmentOptions,omitempty"` +} + +// NewInstallmentOptionsResponse constructs a new InstallmentOptionsResponse +func NewInstallmentOptionsResponse() *InstallmentOptionsResponse { + return &InstallmentOptionsResponse{} +} diff --git a/domain/payment/Installments.go b/domain/payment/Installments.go index 7d78412..190ab27 100644 --- a/domain/payment/Installments.go +++ b/domain/payment/Installments.go @@ -8,6 +8,7 @@ import "github.com/Ingenico-ePayments/connect-sdk-go/domain/definitions" // Installments represents class Installments type Installments struct { AmountOfMoneyPerInstallment *definitions.AmountOfMoney `json:"amountOfMoneyPerInstallment,omitempty"` + AmountOfMoneyTotal *definitions.AmountOfMoney `json:"amountOfMoneyTotal,omitempty"` FrequencyOfInstallments *string `json:"frequencyOfInstallments,omitempty"` InstallmentPlanCode *int32 `json:"installmentPlanCode,omitempty"` InterestRate *string `json:"interestRate,omitempty"` diff --git a/examples/merchant/installments/GetInstallmentsInfoExample.go b/examples/merchant/installments/GetInstallmentsInfoExample.go new file mode 100644 index 0000000..a61a7a4 --- /dev/null +++ b/examples/merchant/installments/GetInstallmentsInfoExample.go @@ -0,0 +1,38 @@ +// This file was auto-generated from the API references found at +// https://epayments-api.developer-ingenico.com/s2sapi/v1/ + +package examples + +import ( + "fmt" + + "github.com/Ingenico-ePayments/connect-sdk-go/domain/definitions" + "github.com/Ingenico-ePayments/connect-sdk-go/domain/installments" +) + +func getInstallmentsInfoExample() { + client, clientErr := getClient() + if clientErr != nil { + panic(clientErr) + } + defer client.Close() + + // Assigning literals to pointer variables directly is not supported. + // The below code uses helper functions newInt32, newInt64 and newString to overcome this issue. + // http://stackoverflow.com/a/30716481 lists a few more alternatives. + // The code for these helper functions can be found in file Helper.go + + var amountOfMoney definitions.AmountOfMoney + amountOfMoney.Amount = newInt64(123) + amountOfMoney.CurrencyCode = newString("EUR") + + var body installments.GetInstallmentRequest + body.AmountOfMoney = &amountOfMoney + body.Bin = newString("123455") + body.CountryCode = newString("NL") + body.PaymentProductID = newInt32(123) + + response, err := client.Merchant("merchantId").Installments().GetInstallmentsInfo(body, nil) + + fmt.Println(response, err) +} diff --git a/examples/merchant/installments/Helper.go b/examples/merchant/installments/Helper.go new file mode 100644 index 0000000..cf74bb3 --- /dev/null +++ b/examples/merchant/installments/Helper.go @@ -0,0 +1,51 @@ +// This class was auto-generated from the API references found at +// https://epayments-api.developer-ingenico.com/s2sapi/v1/ + +package examples + +import ( + "github.com/Ingenico-ePayments/connect-sdk-go" + "github.com/Ingenico-ePayments/connect-sdk-go/domain/errors" + "github.com/Ingenico-ePayments/connect-sdk-go/domain/payment" + "github.com/Ingenico-ePayments/connect-sdk-go/domain/payout" + "github.com/Ingenico-ePayments/connect-sdk-go/domain/refund" +) + +func getClient() (*connectsdk.Client, error) { + apiKeyID := "someKey" + secretAPIKey := "someSecret" + + return connectsdk.CreateClient(apiKeyID, secretAPIKey, "Ingenico") +} + +func newBool(value bool) *bool { + return &value +} + +func newInt32(value int32) *int32 { + return &value +} + +func newInt64(value int64) *int64 { + return &value +} + +func newString(value string) *string { + return &value +} + +func handleDeclinedPayment(paymentResult *payment.CreateResult) { + // handle the result here +} + +func handleDeclinedPayout(payoutResult *payout.Result) { + // handle the result here +} + +func handleDeclinedRefund(refundResult *refund.Result) { + // handle the result here +} + +func handleAPIErrors(errors []errors.APIError) { + // handle the errors here +} diff --git a/merchant/Client.go b/merchant/Client.go index 4bb30d0..f1b3ac8 100644 --- a/merchant/Client.go +++ b/merchant/Client.go @@ -10,6 +10,7 @@ import ( "github.com/Ingenico-ePayments/connect-sdk-go/merchant/files" "github.com/Ingenico-ePayments/connect-sdk-go/merchant/hostedcheckouts" "github.com/Ingenico-ePayments/connect-sdk-go/merchant/hostedmandatemanagements" + "github.com/Ingenico-ePayments/connect-sdk-go/merchant/installments" "github.com/Ingenico-ePayments/connect-sdk-go/merchant/mandates" "github.com/Ingenico-ePayments/connect-sdk-go/merchant/payments" "github.com/Ingenico-ePayments/connect-sdk-go/merchant/payouts" @@ -97,6 +98,11 @@ func (c *Client) Sessions() *sessions.Client { return sessions.NewClient(c.apiResource, nil) } +// Installments represents the resource /{merchantId}/installments +func (c *Client) Installments() *installments.Client { + return installments.NewClient(c.apiResource, nil) +} + // Files represents the resource /{merchantId}/files func (c *Client) Files() *files.Client { return files.NewClient(c.apiResource, nil) diff --git a/merchant/installments/Client.go b/merchant/installments/Client.go new file mode 100644 index 0000000..6d16063 --- /dev/null +++ b/merchant/installments/Client.go @@ -0,0 +1,75 @@ +// This class was auto-generated from the API references found at +// https://epayments-api.developer-ingenico.com/s2sapi/v1/ + +package installments + +import ( + "github.com/Ingenico-ePayments/connect-sdk-go/communicator/communication" + "github.com/Ingenico-ePayments/connect-sdk-go/domain/errors" + "github.com/Ingenico-ePayments/connect-sdk-go/domain/installments" + sdkErrors "github.com/Ingenico-ePayments/connect-sdk-go/errors" + "github.com/Ingenico-ePayments/connect-sdk-go/internal/apiresource" +) + +// Client represents a installments client. Thread-safe. +type Client struct { + apiResource *apiresource.APIResource +} + +// GetInstallmentsInfo represents the resource /{merchantId}/installments/getInstallmentsInfo - Get Installment Info +// Documentation can be found at https://epayments-api.developer-ingenico.com/s2sapi/v1/en_US/go/installments/getInstallmentsInfo.html +// +// Can return any of the following errors: +// * ValidationError if the request was not correct and couldn't be processed (HTTP status code 400) +// * AuthorizationError if the request was not allowed (HTTP status code 403) +// * IdempotenceError if an idempotent request caused a conflict (HTTP status code 409) +// * ReferenceError if an object was attempted to be referenced that doesn't exist or has been removed, +// or there was a conflict (HTTP status code 404, 409 or 410) +// * GlobalCollectError if something went wrong at the Ingenico ePayments platform, +// the Ingenico ePayments platform was unable to process a message from a downstream partner/acquirer, +// or the service that you're trying to reach is temporary unavailable (HTTP status code 500, 502 or 503) +// * APIError if the Ingenico ePayments platform returned any other error +func (c *Client) GetInstallmentsInfo(body installments.GetInstallmentRequest, context communication.CallContext) (installments.InstallmentOptionsResponse, error) { + var resultObject installments.InstallmentOptionsResponse + + uri, err := c.apiResource.InstantiateURIWithContext("/v1/{merchantId}/installments/getInstallmentsInfo", nil) + if err != nil { + return resultObject, err + } + + clientHeaders := c.apiResource.ClientHeaders() + + postErr := c.apiResource.Communicator().Post(uri, clientHeaders, nil, body, context, &resultObject) + if postErr != nil { + responseError, isResponseError := postErr.(*sdkErrors.ResponseError) + if isResponseError { + var errorObject interface{} + + errorObject = &errors.ErrorResponse{} + err = c.apiResource.Communicator().Marshaller().Unmarshal(responseError.Body(), errorObject) + if err != nil { + return resultObject, err + } + + err, createErr := sdkErrors.CreateAPIError(responseError.StatusCode(), responseError.Body(), errorObject, context) + if createErr != nil { + return resultObject, createErr + } + + return resultObject, err + } + + return resultObject, postErr + } + + return resultObject, nil +} + +// NewClient constructs a Installments Client +// +// parent is the *apiresource.APIResource on top of which we want to build the new Installments Client +func NewClient(parent *apiresource.APIResource, pathContext map[string]string) *Client { + apiResource := apiresource.NewAPIResourceWithParent(parent, pathContext) + + return &Client{apiResource} +}