github.com/Ingenico-ePayments/connect-sdk-go@v0.0.0-20240318153750-1f8cd329b9c9/examples/merchant/tokens/UpdateTokenExample.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 updateTokenExample() { 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("b") 27 billingAddress.City = newString("Monument Valley") 28 billingAddress.CountryCode = newString("US") 29 billingAddress.HouseNumber = newString("13") 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 cardWithoutCvv definitions.CardWithoutCvv 52 cardWithoutCvv.CardNumber = newString("4567350000427977") 53 cardWithoutCvv.CardholderName = newString("Wile E. Coyote") 54 cardWithoutCvv.ExpiryDate = newString("1299") 55 cardWithoutCvv.IssueNumber = newString("12") 56 57 var data token.CardData 58 data.CardWithoutCvv = &cardWithoutCvv 59 60 var card token.Card 61 card.Customer = &customer 62 card.Data = &data 63 64 var body token.UpdateRequest 65 body.Card = &card 66 body.PaymentProductID = newInt32(1) 67 68 err := client.Merchant("merchantId").Tokens().Update("tokenId", body, nil) 69 70 fmt.Println(err) 71 }