Ingenico-ePayments / connect-sdk-go

Ingenico Connect Go Server SDK
https://docs.connect.worldline-solutions.com/documentation/sdk/server/go/
Other
8 stars 6 forks source link

Problems with test connection #4

Closed zuttrax closed 2 years ago

zuttrax commented 2 years ago

I have been having troubles with the function to test connection, always I receive the error with code 9002, and when I test with the SDK for node js this works

image

response

image

rob-spoor commented 2 years ago

When you use connectsdk.CreateClient, the default configuration will be used: CommunicatorConfiguration.go#L63. This includes a hard-coded URL: https://world.api-ingenico.com. Is this the same URL you're using in the Node.js SDK?

If not, you'll need to create a configuration.CommunicatorConfiguration instance in combination with connectsdk.CreateClientFromConfiguration. This is explained at Initialization of the Go SDK, subsection "Using CommunicatorConfiguration". That uses TOML to set the configuration, but you can also just set the configuration properties directly:

conf, err := connectsdk.CreateConfiguration(apiKeyID, secretAPIKey, "Ingenico");
// omitted: error handling

// for another https URL:
conf.APIEndpoint.Host = "<other host>"
// or to overwrite the URL completely:
//conf.APIEndpoint = URL{ ... }

return connectsdk.CreateClientFromConfiguration(conf)