This repository has been archived by the owner on Mar 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3bc2216
commit af4dd34
Showing
15 changed files
with
305 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
examples/merchant/installments/GetInstallmentsInfoExample.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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} | ||
} |