github.com/Ingenico-ePayments/connect-sdk-go@v0.0.0-20240318153750-1f8cd329b9c9/examples/merchant/mandates/CreateMandateExample.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/mandates" 11 ) 12 13 func createMandateExample() { 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 function newString to overcome this issue. 22 // http://stackoverflow.com/a/30716481 lists a few more alternatives. 23 // The code for this helper function can be found in file Helper.go 24 25 var bankAccountIban definitions.BankAccountIban 26 bankAccountIban.Iban = newString("DE46720200700359736690") 27 28 var contactDetails mandates.MandateContactDetails 29 contactDetails.EmailAddress = newString("wile.e.coyote@acmelabs.com") 30 31 var mandateAddress mandates.MandateAddress 32 mandateAddress.City = newString("Monumentenvallei") 33 mandateAddress.CountryCode = newString("NL") 34 mandateAddress.Street = newString("Woestijnweg") 35 mandateAddress.Zip = newString("1337XD") 36 37 var name mandates.MandatePersonalName 38 name.FirstName = newString("Wile") 39 name.Surname = newString("Coyote") 40 41 var personalInformation mandates.MandatePersonalInformation 42 personalInformation.Name = &name 43 personalInformation.Title = newString("Miss") 44 45 var customer mandates.MandateCustomer 46 customer.BankAccountIban = &bankAccountIban 47 customer.CompanyName = newString("Acme labs") 48 customer.ContactDetails = &contactDetails 49 customer.MandateAddress = &mandateAddress 50 customer.PersonalInformation = &personalInformation 51 52 var body mandates.CreateMandateRequest 53 body.Customer = &customer 54 body.CustomerReference = newString("idonthaveareference") 55 body.Language = newString("nl") 56 body.RecurrenceType = newString("UNIQUE") 57 body.SignatureType = newString("UNSIGNED") 58 59 response, err := client.Merchant("merchantId").Mandates().Create(body, nil) 60 61 fmt.Println(response, err) 62 }