Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
Release 1.5.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ingenico ePayments committed Jun 27, 2017
1 parent eb47e16 commit e45c823
Show file tree
Hide file tree
Showing 309 changed files with 1,760 additions and 1,505 deletions.
2 changes: 1 addition & 1 deletion Client.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// This class was auto-generated from the API references found at
// https://developer.globalcollect.com/documentation/api/server/
// https://epayments-api.developer-ingenico.com/s2sapi/v1/

package connectsdk

Expand Down
206 changes: 206 additions & 0 deletions Client_Logging_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net/http"
"net/url"
"strconv"
"strings"
"testing"
"time"

Expand All @@ -25,6 +26,50 @@ var convertAmountJSON = `{
"convertedAmount": 4547504
}`

var createPaymentUnicodeJSON = `{
"creationOutput": {
"additionalReference": "00000012341000059598",
"externalReference": "000000123410000595980000100001"
},
"payment": {
"id": "000000123410000595980000100001",
"paymentOutput": {
"amountOfMoney": {
"amount": 2345,
"currencyCode": "CAD"
},
"references": {
"paymentReference": "0"
},
"paymentMethod": "redirect",
"redirectPaymentMethodSpecificOutput":{
"paymentProductId":840,
"paymentProduct840SpecificOutput":{
"customerAccount":{
"firstName":"Theresa",
"surname":"Schröder"
},
"customerAddress":{
"city":"sittensen",
"countryCode":"DE",
"street":"Westerberg 25",
"zip":"27419"
}
}
}
},
"status": "PENDING_APPROVAL",
"statusOutput": {
"isCancellable": true,
"statusCategory": "PENDING_MERCHANT",
"statusCode": 600,
"statusCodeChangeDateTime": "20160310094054",
"isAuthorized": true
}
}
}
`

var createPaymentJSON = `{
"creationOutput": {
"additionalReference": "00000012341000059598",
Expand Down Expand Up @@ -525,6 +570,167 @@ func TestDeleteToken(t *testing.T) {
}
}

func TestLoggingCreatePaymentUnicode(t *testing.T) {
logPrefix := "TestLoggingCreatePayment"

responseHeaders := map[string]string{
"Content-Type": "application/json",
"Dummy": "dummy",
"Location": "http://localhost/v1/1234/payments/000000123410000595980000100001",
}
requestHeaders := map[string][]string{}

listener, sl, client, err := createTestEnvironment(
"/v1/1234/payments",
createRecordRequest(http.StatusCreated, createPaymentUnicodeJSON, responseHeaders, requestHeaders))
if err != nil {
t.Fatalf("%v: %v", logPrefix, err)
}
defer listener.Close()
defer sl.Close()
defer client.Close()

logger := &testLogger{}
client.EnableLogging(logger)

var card definitions.Card
card.CardNumber = newString("1234567890123456")
card.Cvv = newString("123")
card.ExpiryDate = newString("1220")

var cardPaymentMethodSpecificInput payment.CardPaymentMethodSpecificInput
cardPaymentMethodSpecificInput.Card = &card
cardPaymentMethodSpecificInput.PaymentProductID = newInt32(1)

var amountOfMoney definitions.AmountOfMoney
amountOfMoney.Amount = newInt64(2345)
amountOfMoney.CurrencyCode = newString("CAD")

var billingAddress definitions.Address
billingAddress.CountryCode = newString("CA")

var customer payment.Customer
customer.BillingAddress = &billingAddress

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

var reqBody payment.CreateRequest
reqBody.CardPaymentMethodSpecificInput = &cardPaymentMethodSpecificInput
reqBody.Order = &order

response, err := client.Merchant("1234").Payments().Create(reqBody, nil)
if err != nil {
t.Fatalf("%v: %v", logPrefix, err)
}

if len(logger.entries) != 2 {
t.Fatalf("%v: loggerEntries %v", logPrefix, len(logger.entries))
}

if response.Payment == nil {
t.Fatalf("%v: responsePayment nil", logPrefix)
}
if response.Payment.ID == nil {
t.Fatalf("%v: responsePaymentID nil", logPrefix)
}

firstEntry := logger.entries[0]
if firstEntry.request == nil {
t.Fatalf("%v: firstEntryRequest %v", logPrefix, firstEntry.request)
}
if firstEntry.request.Method() != "POST" {
t.Fatalf("%v: firstEntryRequestMethod %v", logPrefix, firstEntry.request.Method())
}
if firstEntry.request.URL().Path != "/v1/1234/payments" {
t.Fatalf("%v: firstEntryRequestURL %v", logPrefix, firstEntry.request.URL().Path)
}
if firstEntry.request.Headers() == nil {
t.Fatalf("%v: firstEntryRequestHeaders %v", logPrefix, firstEntry.request.Headers())
}
foundDate, foundMetainfo := false, false
for k, v := range firstEntry.request.Headers() {
switch k {
case "Authorization":
{
if v[0] != "********" {
t.Fatalf("%v: authorizationHeader %v", logPrefix, v)
}

break
}
case "Date":
{
foundDate = true

break
}
case "X-GCS-ServerMetaInfo":
{
foundMetainfo = true

break
}
}
}
if !foundDate {
t.Fatalf("%v: date header not found", logPrefix)
}
if !foundMetainfo {
t.Fatalf("%v: meta info header not found", logPrefix)
}
if firstEntry.err != nil {
t.Fatalf("%v: firstEntryErr %v", logPrefix, firstEntry.err)
}

secondEntry := logger.entries[1]
if !strings.Contains(secondEntry.response.Body(), "Schröder") {
t.Fatalf("%v: secondEntryResponse %v", logPrefix, secondEntry.response)
}
if secondEntry.response == nil {
t.Fatalf("%v: secondEntryResponse %v", logPrefix, secondEntry.response)
}
if secondEntry.response.StatusCode() != http.StatusCreated {
t.Fatalf("%v: secondEntryResponseStatusCode %v", logPrefix, secondEntry.response.StatusCode())
}
if secondEntry.response.ContentType() != "application/json" {
t.Fatalf("%v: secondEntryResponseContentType %v", logPrefix, secondEntry.response.ContentType())
}
if secondEntry.response.Headers() == nil {
t.Fatalf("%v: secondEntryResponseHeaders %v", logPrefix, secondEntry.response.Headers())
}
if secondEntry.response.Body() == "" {
t.Fatalf("%v: secondEntryResponseBody %v", logPrefix, secondEntry.response.Body())
}

foundDate, foundDummy := false, false
for k := range secondEntry.response.Headers() {
switch k {
case "Date":
{
foundDate = true

break
}
case "Dummy":
{
foundDummy = true

break
}
}
}
if !foundDate {
t.Fatalf("%v: date header not found", logPrefix)
}
if !foundDummy {
t.Fatalf("%v: dummy header not found", logPrefix)
}
if secondEntry.err != nil {
t.Fatalf("%v: secondEntryErr %v", logPrefix, secondEntry.err)
}
}
func TestLoggingCreatePayment(t *testing.T) {
logPrefix := "TestLoggingCreatePayment"

Expand Down
2 changes: 1 addition & 1 deletion communicator/MetaDataProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func getPlatformIdentifier() string {
}

const sdkIdentifier = "GoServerSDK/v" + sdkVersion
const sdkVersion = "1.4.0"
const sdkVersion = "1.5.0"
const serverMetaInfoHeader = "X-GCS-ServerMetaInfo"

// NewMetaDataProviderWithBuilder creates a MetaDataProvider with the given MetaDataProviderBuilder
Expand Down
17 changes: 17 additions & 0 deletions domain/capture/Capture.go
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 capture

// Capture represents class Capture
type Capture struct {
CaptureOutput *Output `json:"captureOutput,omitempty"`
ID *string `json:"id,omitempty"`
Status *string `json:"status,omitempty"`
StatusOutput *StatusOutput `json:"statusOutput,omitempty"`
}

// NewCapture constructs a new Capture
func NewCapture() *Capture {
return &Capture{}
}
14 changes: 14 additions & 0 deletions domain/capture/CapturesResponse.go
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 capture

// CapturesResponse represents class CapturesResponse
type CapturesResponse struct {
Captures *[]Capture `json:"captures,omitempty"`
}

// NewCapturesResponse constructs a new CapturesResponse
func NewCapturesResponse() *CapturesResponse {
return &CapturesResponse{}
}
30 changes: 30 additions & 0 deletions domain/capture/Output.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// This class was auto-generated from the API references found at
// https://epayments-api.developer-ingenico.com/s2sapi/v1/

package capture

import (
"github.com/Ingenico-ePayments/connect-sdk-go/domain/definitions"
"github.com/Ingenico-ePayments/connect-sdk-go/domain/payment"
)

// Output represents class CaptureOutput
type Output struct {
AmountOfMoney *definitions.AmountOfMoney `json:"amountOfMoney,omitempty"`
AmountPaid *int64 `json:"amountPaid,omitempty"`
BankTransferPaymentMethodSpecificOutput *payment.BankTransferPaymentMethodSpecificOutput `json:"bankTransferPaymentMethodSpecificOutput,omitempty"`
CardPaymentMethodSpecificOutput *payment.CardPaymentMethodSpecificOutput `json:"cardPaymentMethodSpecificOutput,omitempty"`
CashPaymentMethodSpecificOutput *payment.CashPaymentMethodSpecificOutput `json:"cashPaymentMethodSpecificOutput,omitempty"`
DirectDebitPaymentMethodSpecificOutput *payment.NonSepaDirectDebitPaymentMethodSpecificOutput `json:"directDebitPaymentMethodSpecificOutput,omitempty"`
InvoicePaymentMethodSpecificOutput *payment.InvoicePaymentMethodSpecificOutput `json:"invoicePaymentMethodSpecificOutput,omitempty"`
MobilePaymentMethodSpecificOutput *payment.MobilePaymentMethodSpecificOutput `json:"mobilePaymentMethodSpecificOutput,omitempty"`
PaymentMethod *string `json:"paymentMethod,omitempty"`
RedirectPaymentMethodSpecificOutput *payment.RedirectPaymentMethodSpecificOutput `json:"redirectPaymentMethodSpecificOutput,omitempty"`
References *payment.References `json:"references,omitempty"`
SepaDirectDebitPaymentMethodSpecificOutput *payment.SepaDirectDebitPaymentMethodSpecificOutput `json:"sepaDirectDebitPaymentMethodSpecificOutput,omitempty"`
}

// NewOutput constructs a new Output
func NewOutput() *Output {
return &Output{}
}
17 changes: 17 additions & 0 deletions domain/capture/Response.go
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 capture

// Response represents class CaptureResponse
type Response struct {
CaptureOutput *Output `json:"captureOutput,omitempty"`
ID *string `json:"id,omitempty"`
Status *string `json:"status,omitempty"`
StatusOutput *StatusOutput `json:"statusOutput,omitempty"`
}

// NewResponse constructs a new Response
func NewResponse() *Response {
return &Response{}
}
14 changes: 14 additions & 0 deletions domain/capture/StatusOutput.go
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 capture

// StatusOutput represents class CaptureStatusOutput
type StatusOutput struct {
StatusCode *int32 `json:"statusCode,omitempty"`
}

// NewStatusOutput constructs a new StatusOutput
func NewStatusOutput() *StatusOutput {
return &StatusOutput{}
}
3 changes: 1 addition & 2 deletions domain/definitions/AbstractOrderStatus.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// This class was auto-generated from the API references found at
// https://developer.globalcollect.com/documentation/api/server/
// https://epayments-api.developer-ingenico.com/s2sapi/v1/

package definitions

// AbstractOrderStatus represents class AbstractOrderStatus
// Documentation can be found at https://developer.globalcollect.com/documentation/api/server/#schema_AbstractOrderStatus
type AbstractOrderStatus struct {
ID *string `json:"id,omitempty"`
}
Expand Down
3 changes: 1 addition & 2 deletions domain/definitions/AbstractPaymentMethodSpecificInput.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// This class was auto-generated from the API references found at
// https://developer.globalcollect.com/documentation/api/server/
// https://epayments-api.developer-ingenico.com/s2sapi/v1/

package definitions

// AbstractPaymentMethodSpecificInput represents class AbstractPaymentMethodSpecificInput
// Documentation can be found at https://developer.globalcollect.com/documentation/api/server/#schema_AbstractPaymentMethodSpecificInput
type AbstractPaymentMethodSpecificInput struct {
PaymentProductID *int32 `json:"paymentProductId,omitempty"`
}
Expand Down
3 changes: 1 addition & 2 deletions domain/definitions/AdditionalOrderInputAirlineData.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// This class was auto-generated from the API references found at
// https://developer.globalcollect.com/documentation/api/server/
// https://epayments-api.developer-ingenico.com/s2sapi/v1/

package definitions

// AdditionalOrderInputAirlineData represents class AdditionalOrderInputAirlineData
// Documentation can be found at https://developer.globalcollect.com/documentation/api/server/#schema_AdditionalOrderInputAirlineData
type AdditionalOrderInputAirlineData struct {
AirlineData *AirlineData `json:"airlineData,omitempty"`
}
Expand Down
3 changes: 1 addition & 2 deletions domain/definitions/Address.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// This class was auto-generated from the API references found at
// https://developer.globalcollect.com/documentation/api/server/
// https://epayments-api.developer-ingenico.com/s2sapi/v1/

package definitions

// Address represents class Address
// Documentation can be found at https://developer.globalcollect.com/documentation/api/server/#schema_Address
type Address struct {
AdditionalInfo *string `json:"additionalInfo,omitempty"`
City *string `json:"city,omitempty"`
Expand Down
3 changes: 1 addition & 2 deletions domain/definitions/AirlineData.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// This class was auto-generated from the API references found at
// https://developer.globalcollect.com/documentation/api/server/
// https://epayments-api.developer-ingenico.com/s2sapi/v1/

package definitions

// AirlineData represents class AirlineData
// Documentation can be found at https://developer.globalcollect.com/documentation/api/server/#schema_AirlineData
type AirlineData struct {
AgentNumericCode *string `json:"agentNumericCode,omitempty"`
Code *string `json:"code,omitempty"`
Expand Down
Loading

0 comments on commit e45c823

Please sign in to comment.