GithubHelp home page GithubHelp logo

ingenico-epayments / connect-sdk-go Goto Github PK

View Code? Open in Web Editor NEW
8.0 11.0 6.0 566 KB

Ingenico Connect Go Server SDK

Home Page: https://docs.connect.worldline-solutions.com/documentation/sdk/server/go/

License: Other

Go 100.00%
go-sdk ingenico globalcollect ingenico-connect

connect-sdk-go's Introduction

Ingenico Connect Go SDK

This SDK has been rebranded to Worldline. As part of the rebranding the SDK has moved to https://github.com/Worldline-Global-Collect/connect-sdk-go.

Introduction

The Go SDK helps you to communicate with the Ingenico Connect Server API. Its primary features are:

  • convenient go wrapper around the API calls and responses
    • marshalls Go request structs to HTTP requests
    • unmarshalls HTTP responses to Go response structs or Go exceptions
  • handling of all the details concerning authentication
  • handling of required meta data

Its use is demonstrated by an example for each possible call. The examples execute a call using the provided API keys.

See the Ingenico Connect Developer Hub for more information on how to use the SDK.

Requirements

Go version 1.11 or higher is required. No additional packages are required.

Examples

This repository also contains some example code. This code is contained in the examples folder.

Installation

Source

To install the latest version of this repository, run the following command from a terminal:

go get github.com/Ingenico-ePayments/connect-sdk-go

Release

Go 1.11 added module support and with that support for versions in go get. This means that, if your project uses modules, you can add @version to the go get command to get a specific version. For example, go get github.com/Ingenico-ePayments/[email protected] will download version 2.9.0 of the SDK. See the releases page for an overview of available releases.

If your project does not use modules yet, you will need to use the instructions above to install from source. Note that new major versions may introduce breaking changes. We therefore recommend using modules in your project. See Migrating to Go Modules for more information.

Running tests

There are two types of tests: unit tests and integration tests. The unit tests will work out-of-the-box; for the integration tests some configuration is required. First, some environment variables need to be set:

  • connect.api.apiKeyId for the API key id to use. This can be retrieved from the Configuration Center.
  • connect.api.secretApiKey for the secret API key to use. This can be retrieved from the Configuration Center.
  • connect.api.merchantId for your merchant ID.
  • connect.api.proxyUrl for the URL to the proxy to use (optional). If set, it should be in the form scheme://[userinfo@]host[:port]. Examples: http://proxy.example.org, http://user:[email protected], http://proxy.example.org:3128.

The following commands can now be executed from the root directory of the SDK folder to execute the tests:

  • Unit tests:

    go test ./...
    
  • Both unit and integration tests:

    go test -tags=integration  ./...
    

connect-sdk-go's People

Contributors

ingenicoepayments avatar rikvanthof avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

connect-sdk-go's Issues

Problems with test connection

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

CreatePayment timeout

I am trying to post a create payment request using the GO SDK in sandbox environment. I already created my sandbox account, and my merchantID is: 1095. The payment method I'm trying to use is WechatPay, QRCode integration. however I'm getting a timeout when I post the payment request. The exact message I'm getting is:

There was an error in the communication with the Ingenico ePayments platform Post "https://world.preprod.api-ingenico.com/v1/1095/payments": context deadline exceeded (Client.Timeout exceeded while awaiting headers)

I already checked network block, but I don't seem to have any blocking rule on my side.

Here is my code:

`package main

import (
"fmt"

"github.com/BurntSushi/toml"

connectsdk "github.com/Ingenico-ePayments/connect-sdk-go"
"github.com/Ingenico-ePayments/connect-sdk-go/domain/definitions"
"github.com/Ingenico-ePayments/connect-sdk-go/domain/payment"

)

func main() {

conf, _ := connectsdk.CreateConfiguration("3ceafe4f45172802", "iZEVVw538LC3Tqt2NcOdwWS4MSejPV0cFR9aYlgIiMw=", "integrator")
tomlData := `
ConnectTimeout = 5000
SocketTimeout = 3000
MaxConnections = 10
AuthorizationType = "v1HMAC"
[APIEndpoint]
	host = "eu.sandbox.api-ingenico.com"
`
toml.Decode(tomlData, conf)
client, clientErr := connectsdk.CreateClientFromConfiguration(conf)
if clientErr != nil {
	panic(clientErr)
}

client, _ = client.WithClientMetaInfo(`{"platformIdentifier":"Android/4.4","appIdentifier":"Examplemobileapp/1.1","sdkIdentifier":"AndroidClientSDK/v1.2","screenSize":"800x600","deviceBrand":"Samsung","deviceType":"GT9300","ipAddress":"123.123.123.123"}`)

defer client.Close()

var payment863SpecificInput payment.RedirectPaymentProduct863SpecificInput
payment863SpecificInput.IntegrationType = newString("desktopQRCode")

var paymentSpecificInput payment.RedirectPaymentMethodSpecificInput
paymentSpecificInput.PaymentProduct863SpecificInput = &payment863SpecificInput

var fraudFields definitions.FraudFields
fraudFields.CustomerIPAddress = newString("190.57.88.226")

var amountOfMoney definitions.AmountOfMoney
amountOfMoney.Amount = newInt64(234)
amountOfMoney.CurrencyCode = newString("USD")

var billingAddress definitions.Address
billingAddress.CountryCode = newString("US")
billingAddress.StateCode = newString("TX")
billingAddress.City = newString("Grapevine")

var customer payment.Customer
customer.BillingAddress = &billingAddress
customer.MerchantCustomerID = newString("134183783095")

var order payment.Order
order.AmountOfMoney = &amountOfMoney
order.Customer = &customer

var body payment.CreateRequest
body.RedirectPaymentMethodSpecificInput = &paymentSpecificInput
body.FraudFields = &fraudFields
body.Order = &order

response, err := client.Merchant("1095").Payments().Create(body, nil)

fmt.Println(response, err)

}

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
}
`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.