github.com/Ingenico-ePayments/connect-sdk-go@v0.0.0-20240318153750-1f8cd329b9c9/examples/merchant/tokens/CreateTokenExample.go (about) 1 // This file was auto-generated from the API references found at 2 // https://epayments-api.developer-ingenico.com/ 3 4 package examples 5 6 import ( 7 "fmt" 8 9 "github.com/Ingenico-ePayments/connect-sdk-go/domain/definitions" 10 "github.com/Ingenico-ePayments/connect-sdk-go/domain/token" 11 ) 12 13 func createTokenExample() { 14 client, clientErr := getClient() 15 if clientErr != nil { 16 panic(clientErr) 17 } 18 defer client.Close() 19 20 // Assigning literals to pointer variables directly is not supported. 21 // The below code uses helper functions newInt32 and newString to overcome this issue. 22 // http://stackoverflow.com/a/30716481 lists a few more alternatives. 23 // The code for these helper functions can be found in file Helper.go 24 25 var billingAddress definitions.Address 26 billingAddress.AdditionalInfo = newString("Suite II") 27 billingAddress.City = newString("Monument Valley") 28 billingAddress.CountryCode = newString("US") 29 billingAddress.HouseNumber = newString("1") 30 billingAddress.State = newString("Utah") 31 billingAddress.Street = newString("Desertroad") 32 billingAddress.Zip = newString("84536") 33 34 var companyInformation definitions.CompanyInformation 35 companyInformation.Name = newString("Acme Labs") 36 37 var name token.PersonalNameToken 38 name.FirstName = newString("Wile") 39 name.Surname = newString("Coyote") 40 name.SurnamePrefix = newString("E.") 41 42 var personalInformation token.PersonalInformationToken 43 personalInformation.Name = &name 44 45 var customer token.CustomerToken 46 customer.BillingAddress = &billingAddress 47 customer.CompanyInformation = &companyInformation 48 customer.MerchantCustomerID = newString("1234") 49 customer.PersonalInformation = &personalInformation 50 51 var bankAccountBban definitions.BankAccountBban 52 bankAccountBban.AccountNumber = newString("000000123456") 53 bankAccountBban.BankCode = newString("05428") 54 bankAccountBban.BranchCode = newString("11101") 55 bankAccountBban.CheckDigit = newString("X") 56 bankAccountBban.CountryCode = newString("IT") 57 58 var paymentProduct705SpecificData token.NonSepaDirectDebitPaymentProduct705SpecificData 59 paymentProduct705SpecificData.AuthorisationID = newString("123456") 60 paymentProduct705SpecificData.BankAccountBban = &bankAccountBban 61 62 var mandate token.MandateNonSepaDirectDebit 63 mandate.PaymentProduct705SpecificData = &paymentProduct705SpecificData 64 65 var nonSepaDirectDebit token.NonSepaDirectDebit 66 nonSepaDirectDebit.Customer = &customer 67 nonSepaDirectDebit.Mandate = &mandate 68 69 var body token.CreateRequest 70 body.NonSepaDirectDebit = &nonSepaDirectDebit 71 body.PaymentProductID = newInt32(705) 72 73 response, err := client.Merchant("merchantId").Tokens().Create(body, nil) 74 75 fmt.Println(response, err) 76 }