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
Ingenico ePayments
committed
Jul 12, 2018
1 parent
910fb89
commit 234c9e4
Showing
13 changed files
with
336 additions
and
2 deletions.
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 hostedmandatemanagement | ||
|
||
// CreateRequest represents class CreateHostedMandateManagementRequest | ||
type CreateRequest struct { | ||
CreateMandateInfo *HostedMandateInfo `json:"createMandateInfo,omitempty"` | ||
HostedMandateManagementSpecificInput *SpecificInput `json:"hostedMandateManagementSpecificInput,omitempty"` | ||
} | ||
|
||
// NewCreateRequest constructs a new CreateRequest | ||
func NewCreateRequest() *CreateRequest { | ||
return &CreateRequest{} | ||
} |
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 hostedmandatemanagement | ||
|
||
// CreateResponse represents class CreateHostedMandateManagementResponse | ||
type CreateResponse struct { | ||
RETURNMAC *string `json:"RETURNMAC,omitempty"` | ||
HostedMandateManagementID *string `json:"hostedMandateManagementId,omitempty"` | ||
PartialRedirectURL *string `json:"partialRedirectUrl,omitempty"` | ||
} | ||
|
||
// NewCreateResponse constructs a new CreateResponse | ||
func NewCreateResponse() *CreateResponse { | ||
return &CreateResponse{} | ||
} |
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,17 @@ | ||
// This class was auto-generated from the API references found at | ||
// https://epayments-api.developer-ingenico.com/s2sapi/v1/ | ||
|
||
package hostedmandatemanagement | ||
|
||
import "github.com/Ingenico-ePayments/connect-sdk-go/domain/mandates" | ||
|
||
// GetResponse represents class GetHostedMandateManagementResponse | ||
type GetResponse struct { | ||
Mandate *mandates.MandateResponse `json:"mandate,omitempty"` | ||
Status *string `json:"status,omitempty"` | ||
} | ||
|
||
// NewGetResponse constructs a new GetResponse | ||
func NewGetResponse() *GetResponse { | ||
return &GetResponse{} | ||
} |
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,21 @@ | ||
// This class was auto-generated from the API references found at | ||
// https://epayments-api.developer-ingenico.com/s2sapi/v1/ | ||
|
||
package hostedmandatemanagement | ||
|
||
import "github.com/Ingenico-ePayments/connect-sdk-go/domain/mandates" | ||
|
||
// HostedMandateInfo represents class HostedMandateInfo | ||
type HostedMandateInfo struct { | ||
Alias *string `json:"alias,omitempty"` | ||
Customer *mandates.MandateCustomer `json:"customer,omitempty"` | ||
CustomerReference *string `json:"customerReference,omitempty"` | ||
RecurrenceType *string `json:"recurrenceType,omitempty"` | ||
SignatureType *string `json:"signatureType,omitempty"` | ||
UniqueMandateReference *string `json:"uniqueMandateReference,omitempty"` | ||
} | ||
|
||
// NewHostedMandateInfo constructs a new HostedMandateInfo | ||
func NewHostedMandateInfo() *HostedMandateInfo { | ||
return &HostedMandateInfo{} | ||
} |
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,17 @@ | ||
// This class was auto-generated from the API references found at | ||
// https://epayments-api.developer-ingenico.com/s2sapi/v1/ | ||
|
||
package hostedmandatemanagement | ||
|
||
// SpecificInput represents class HostedMandateManagementSpecificInput | ||
type SpecificInput struct { | ||
Locale *string `json:"locale,omitempty"` | ||
ReturnURL *string `json:"returnUrl,omitempty"` | ||
ShowResultPage *bool `json:"showResultPage,omitempty"` | ||
Variant *string `json:"variant,omitempty"` | ||
} | ||
|
||
// NewSpecificInput constructs a new SpecificInput | ||
func NewSpecificInput() *SpecificInput { | ||
return &SpecificInput{} | ||
} |
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
41 changes: 41 additions & 0 deletions
41
examples/merchant/hostedmandatemanagements/CreateHostedMandateManagementExample.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,41 @@ | ||
// 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/hostedmandatemanagement" | ||
) | ||
|
||
func createHostedMandateManagementExample() { | ||
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 function newString to overcome this issue. | ||
// http://stackoverflow.com/a/30716481 lists a few more alternatives. | ||
// The code for this helper function can be found in file Helper.go | ||
|
||
var createMandateInfo hostedmandatemanagement.HostedMandateInfo | ||
createMandateInfo.CustomerReference = newString("idonthaveareference") | ||
createMandateInfo.RecurrenceType = newString("RECURRING") | ||
createMandateInfo.SignatureType = newString("UNSIGNED") | ||
|
||
var hostedMandateManagementSpecificInput hostedmandatemanagement.SpecificInput | ||
hostedMandateManagementSpecificInput.Locale = newString("fr_FR") | ||
hostedMandateManagementSpecificInput.ReturnURL = newString("http://www.example.com") | ||
hostedMandateManagementSpecificInput.Variant = newString("101") | ||
|
||
var body hostedmandatemanagement.CreateRequest | ||
body.CreateMandateInfo = &createMandateInfo | ||
body.HostedMandateManagementSpecificInput = &hostedMandateManagementSpecificInput | ||
|
||
response, err := client.Merchant("merchantId").Hostedmandatemanagements().Create(body, nil) | ||
|
||
fmt.Println(response, err) | ||
} |
18 changes: 18 additions & 0 deletions
18
examples/merchant/hostedmandatemanagements/GetHostedMandateManagementExample.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,18 @@ | ||
// This file was auto-generated from the API references found at | ||
// https://epayments-api.developer-ingenico.com/s2sapi/v1/ | ||
|
||
package examples | ||
|
||
import "fmt" | ||
|
||
func getHostedMandateManagementExample() { | ||
client, clientErr := getClient() | ||
if clientErr != nil { | ||
panic(clientErr) | ||
} | ||
defer client.Close() | ||
|
||
response, err := client.Merchant("merchantId").Hostedmandatemanagements().Get("hostedMandateManagementId", 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
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,130 @@ | ||
// This class was auto-generated from the API references found at | ||
// https://epayments-api.developer-ingenico.com/s2sapi/v1/ | ||
|
||
package hostedmandatemanagements | ||
|
||
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/hostedmandatemanagement" | ||
sdkErrors "github.com/Ingenico-ePayments/connect-sdk-go/errors" | ||
"github.com/Ingenico-ePayments/connect-sdk-go/internal/apiresource" | ||
) | ||
|
||
// Client represents a hostedmandatemanagements client. Thread-safe. | ||
type Client struct { | ||
apiResource *apiresource.APIResource | ||
} | ||
|
||
// Create represents the resource /{merchantId}/hostedmandatemanagements | ||
// Create hosted mandate management | ||
// Documentation can be found at https://epayments-api.developer-ingenico.com/s2sapi/v1/en_US/go/hostedmandatemanagements/create.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) Create(body hostedmandatemanagement.CreateRequest, context communication.CallContext) (hostedmandatemanagement.CreateResponse, error) { | ||
var resultObject hostedmandatemanagement.CreateResponse | ||
|
||
uri, err := c.apiResource.InstantiateURIWithContext("/{apiVersion}/{merchantId}/hostedmandatemanagements", 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 | ||
} | ||
|
||
// Get represents the resource /{merchantId}/hostedmandatemanagements/{hostedMandateManagementId} | ||
// Get hosted mandate management status | ||
// Documentation can be found at https://epayments-api.developer-ingenico.com/s2sapi/v1/en_US/go/hostedmandatemanagements/get.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) Get(hostedMandateManagementID string, context communication.CallContext) (hostedmandatemanagement.GetResponse, error) { | ||
var resultObject hostedmandatemanagement.GetResponse | ||
|
||
pathContext := map[string]string{ | ||
"hostedMandateManagementId": hostedMandateManagementID, | ||
} | ||
|
||
uri, err := c.apiResource.InstantiateURIWithContext("/{apiVersion}/{merchantId}/hostedmandatemanagements/{hostedMandateManagementId}", pathContext) | ||
if err != nil { | ||
return resultObject, err | ||
} | ||
|
||
clientHeaders := c.apiResource.ClientHeaders() | ||
|
||
getErr := c.apiResource.Communicator().Get(uri, clientHeaders, nil, context, &resultObject) | ||
if getErr != nil { | ||
responseError, isResponseError := getErr.(*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, getErr | ||
} | ||
|
||
return resultObject, nil | ||
} | ||
|
||
// NewClient constructs a Hostedmandatemanagements Client | ||
// | ||
// parent is the *apiresource.APIResource on top of which we want to build the new Hostedmandatemanagements Client | ||
func NewClient(parent *apiresource.APIResource, pathContext map[string]string) *Client { | ||
apiResource := apiresource.NewAPIResourceWithParent(parent, pathContext) | ||
|
||
return &Client{apiResource} | ||
} |