wallee-models.go (23748B)
1 // This file is part of taler-cashless2ecash. 2 // Copyright (C) 2024 Joel Häberli 3 // 4 // taler-cashless2ecash is free software: you can redistribute it and/or modify it 5 // under the terms of the GNU Affero General Public License as published 6 // by the Free Software Foundation, either version 3 of the License, 7 // or (at your option) any later version. 8 // 9 // taler-cashless2ecash is distributed in the hope that it will be useful, but 10 // WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 // Affero General Public License for more details. 13 // 14 // You should have received a copy of the GNU Affero General Public License 15 // along with this program. If not, see <http://www.gnu.org/licenses/>. 16 // 17 // SPDX-License-Identifier: AGPL3.0-or-later 18 19 package internal_provider_wallee 20 21 import ( 22 "c2ec/pkg/provider" 23 "time" 24 ) 25 26 type WalleeSearchOperator string 27 28 type WalleeSearchType string 29 30 const ( 31 LEAF WalleeSearchType = "LEAF" 32 ) 33 34 const ( 35 EQUALS WalleeSearchOperator = "EQUALS" 36 ) 37 38 type WalleeSearchFilter struct { 39 FieldName string `json:"fieldName"` 40 Operator WalleeSearchOperator `json:"operator"` 41 Type WalleeSearchType `json:"type"` 42 Value string `json:"value"` 43 } 44 45 type WalleeTransactionSearchRequest struct { 46 Filter WalleeSearchFilter `json:"filter"` 47 Language string `json:"language"` 48 NumberOfEntities int `json:"numberOfEntities"` 49 StartingEntity int `json:"startingEntity"` 50 } 51 52 type WalleeTransactionCompletion struct { 53 Amount float64 `json:"amount"` 54 BaseLineItems []WalleeLineItem `json:"baseLineItems"` 55 CreatedBy int64 `json:"createdBy"` 56 CreatedOn time.Time `json:"createdOn"` 57 ExternalID string `json:"externalId"` 58 FailedOn time.Time `json:"failedOn"` 59 FailureReason string `json:"failureReason"` 60 ID int64 `json:"id"` 61 InvoiceMerchantRef string `json:"invoiceMerchantReference"` 62 Labels []WalleeLabel `json:"labels"` 63 Language string `json:"language"` 64 LastCompletion bool `json:"lastCompletion"` 65 LineItemVersion string `json:"lineItemVersion"` 66 LineItems []WalleeLineItem `json:"lineItems"` 67 LinkedSpaceID int64 `json:"linkedSpaceId"` 68 LinkedTransaction int64 `json:"linkedTransaction"` 69 Mode string `json:"mode"` 70 NextUpdateOn time.Time `json:"nextUpdateOn"` 71 PaymentInformation string `json:"paymentInformation"` 72 PlannedPurgeDate time.Time `json:"plannedPurgeDate"` 73 ProcessingOn time.Time `json:"processingOn"` 74 ProcessorReference string `json:"processorReference"` 75 RemainingLineItems []WalleeLineItem `json:"remainingLineItems"` 76 SpaceViewID int64 `json:"spaceViewId"` 77 State string `json:"state"` 78 StatementDescriptor string `json:"statementDescriptor"` 79 SucceededOn time.Time `json:"succeededOn"` 80 TaxAmount float64 `json:"taxAmount"` 81 TimeZone string `json:"timeZone"` 82 TimeoutOn time.Time `json:"timeoutOn"` 83 Version int `json:"version"` 84 } 85 86 /* 87 { 88 "amount": "14.00", 89 "externalId": "1", 90 "merchantReference": "1BQMAGTYTQVM0B1EM40PDS4H4REVMNCEN9867SJQ26Q43C38RDDG", 91 "transaction": { 92 "id": 213103343 93 }, 94 "type": "MERCHANT_INITIATED_ONLINE" 95 } 96 */ 97 type WalleeRefund struct { 98 Amount string `json:"amount"` 99 ExternalID string `json:"externalId"` // idempotence support 100 MerchantReference string `json:"merchantReference"` 101 Transaction WalleeRefundTransaction `json:"transaction"` 102 /* 103 Refund Type (for testing (not triggered at processor): MERCHANT_INITIATED_OFFLINE 104 For real world (triggering at the processor): MERCHANT_INITIATED_ONLINE 105 */ 106 Type string `json:"type"` 107 } 108 109 type WalleeRefundTransaction struct { 110 Id int64 `json:"id"` 111 } 112 113 // type WalleeRefund struct { 114 // Amount float64 `json:"amount"` 115 // Completion int64 `json:"completion"` // ID of WalleeTransactionCompletion 116 // ExternalID string `json:"externalId"` // Unique per transaction 117 // MerchantReference string `json:"merchantReference"` 118 // Reductions []WalleeLineItemReduction `json:"reductions"` 119 // Transaction int64 `json:"transaction"` // ID of WalleeTransaction 120 // Type string `json:"type"` // Refund Type 121 // } 122 123 type WalleeLabel struct { 124 Content []byte `json:"content"` 125 ContentAsString string `json:"contentAsString"` 126 Descriptor WalleeLabelDescriptor `json:"descriptor"` 127 ID int64 `json:"id"` 128 Version int `json:"version"` 129 } 130 131 type WalleeLabelDescriptor struct { 132 Category string `json:"category"` 133 Description map[string]string `json:"description"` 134 Features []int64 `json:"features"` 135 Group int64 `json:"group"` 136 ID int64 `json:"id"` 137 Name map[string]string `json:"name"` 138 Type int64 `json:"type"` 139 Weight int `json:"weight"` 140 } 141 142 type WalleeLineItemReduction struct { 143 LineItemUniqueId string 144 QuantityReduction float64 145 UnitPriceReduction float64 146 } 147 148 type WalleeLineItemAttribute struct { 149 Label string 150 Value string 151 } 152 153 type WalleeTax struct { 154 Rate float64 155 Title string 156 } 157 158 type WalleeLineItem struct { 159 AggregatedTaxRate float64 `json:"aggregatedTaxRate"` 160 AmountExcludingTax float64 `json:"amountExcludingTax"` 161 AmountIncludingTax float64 `json:"amountIncludingTax"` 162 Attributes map[string]WalleeLineItemAttribute `json:"attributes"` 163 DiscountExcludingTax float64 `json:"discountExcludingTax"` 164 DiscountIncludingTax float64 `json:"discountIncludingTax"` 165 Name string `json:"name"` 166 Quantity float64 `json:"quantity"` 167 ShippingRequired bool `json:"shippingRequired"` 168 SKU string `json:"sku"` 169 TaxAmount float64 `json:"taxAmount"` 170 TaxAmountPerUnit float64 `json:"taxAmountPerUnit"` 171 Taxes []WalleeTax `json:"taxes"` 172 Type string `json:"type"` 173 UndiscountedAmountExcludingTax float64 `json:"undiscountedAmountExcludingTax"` 174 UndiscountedAmountIncludingTax float64 `json:"undiscountedAmountIncludingTax"` 175 UndiscountedUnitPriceExclTax float64 `json:"undiscountedUnitPriceExcludingTax"` 176 UndiscountedUnitPriceInclTax float64 `json:"undiscountedUnitPriceIncludingTax"` 177 UniqueID string `json:"uniqueId"` 178 UnitPriceExcludingTax float64 `json:"unitPriceExcludingTax"` 179 UnitPriceIncludingTax float64 `json:"unitPriceIncludingTax"` 180 } 181 182 type WalleeTransactionState string 183 184 const ( 185 StateCreate WalleeTransactionState = "CREATE" 186 StatePending WalleeTransactionState = "PENDING" 187 StateConfirmed WalleeTransactionState = "CONFIRMED" 188 StateProcessing WalleeTransactionState = "PROCESSING" 189 StateFailed WalleeTransactionState = "FAILED" 190 StateAuthorized WalleeTransactionState = "AUTHORIZED" 191 StateCompleted WalleeTransactionState = "COMPLETED" 192 StateFulfill WalleeTransactionState = "FULFILL" 193 StateDecline WalleeTransactionState = "DECLINE" 194 StateVoided WalleeTransactionState = "VOIDED" 195 ) 196 197 type WalleeTransaction struct { 198 provider.ProviderTransaction 199 AcceptHeader interface{} `json:"acceptHeader"` 200 AcceptLanguageHeader interface{} `json:"acceptLanguageHeader"` 201 AllowedPaymentMethodBrands []interface{} `json:"allowedPaymentMethodBrands"` 202 AllowedPaymentMethodConfigurations []interface{} `json:"allowedPaymentMethodConfigurations"` 203 AuthorizationAmount float64 `json:"authorizationAmount"` 204 AuthorizationEnvironment string `json:"authorizationEnvironment"` 205 AuthorizationSalesChannel int64 `json:"authorizationSalesChannel"` 206 AuthorizationTimeoutOn time.Time `json:"authorizationTimeoutOn"` 207 AuthorizedOn time.Time `json:"authorizedOn"` 208 AutoConfirmationEnabled bool `json:"autoConfirmationEnabled"` 209 BillingAddress interface{} `json:"billingAddress"` 210 ChargeRetryEnabled bool `json:"chargeRetryEnabled"` 211 CompletedAmount float64 `json:"completedAmount"` 212 CompletedOn interface{} `json:"completedOn"` 213 CompletionBehavior string `json:"completionBehavior"` 214 CompletionTimeoutOn interface{} `json:"completionTimeoutOn"` 215 ConfirmedBy int `json:"confirmedBy"` 216 ConfirmedOn time.Time `json:"confirmedOn"` 217 CreatedBy int `json:"createdBy"` 218 CreatedOn time.Time `json:"createdOn"` 219 Currency string `json:"currency"` 220 CustomerEmailAddress interface{} `json:"customerEmailAddress"` 221 CustomerId interface{} `json:"customerId"` 222 CustomersPresence string `json:"customersPresence"` 223 DeliveryDecisionMadeOn interface{} `json:"deliveryDecisionMadeOn"` 224 DeviceSessionIdentifier interface{} `json:"deviceSessionIdentifier"` 225 EmailsDisabled bool `json:"emailsDisabled"` 226 EndOfLife time.Time `json:"endOfLife"` 227 Environment string `json:"environment"` 228 EnvironmentSelectionStrategy string `json:"environmentSelectionStrategy"` 229 FailedOn interface{} `json:"failedOn"` 230 FailedUrl interface{} `json:"failedUrl"` 231 FailureReason interface{} `json:"failureReason"` 232 Group WalleeGroup `json:"group"` 233 Id int64 `json:"id"` 234 InternetProtocolAddress interface{} `json:"internetProtocolAddress"` 235 InternetProtocolAddressCountry interface{} `json:"internetProtocolAddressCountry"` 236 InvoiceMerchantReference string `json:"invoiceMerchantReference"` 237 JavaEnabled interface{} `json:"javaEnabled"` 238 Language string `json:"language"` 239 LineItems []WalleeLineItem `json:"lineItems"` 240 LinkedSpaceId int `json:"linkedSpaceId"` 241 MerchantReference string `json:"merchantReference"` 242 MetaData struct{} `json:"metaData"` 243 Parent interface{} `json:"parent"` 244 PaymentConnectorConfiguration WalleePaymentConnectorConfiguration `json:"paymentConnectorConfiguration"` 245 PlannedPurgeDate time.Time `json:"plannedPurgeDate"` 246 ProcessingOn time.Time `json:"processingOn"` 247 RefundedAmount float64 `json:"refundedAmount"` 248 ScreenColorDepth interface{} `json:"screenColorDepth"` 249 ScreenHeight interface{} `json:"screenHeight"` 250 ScreenWidth interface{} `json:"screenWidth"` 251 ShippingAddress interface{} `json:"shippingAddress"` 252 ShippingMethod interface{} `json:"shippingMethod"` 253 SpaceViewId interface{} `json:"spaceViewId"` 254 State string `json:"state"` 255 SuccessUrl interface{} `json:"successUrl"` 256 Terminal WalleeTerminal `json:"terminal"` 257 TimeZone interface{} `json:"timeZone"` 258 Token interface{} `json:"token"` 259 TokenizationMode interface{} `json:"tokenizationMode"` 260 TotalAppliedFees float64 `json:"totalAppliedFees"` 261 TotalSettledAmount float64 `json:"totalSettledAmount"` 262 UserAgentHeader interface{} `json:"userAgentHeader"` 263 UserFailureMessage interface{} `json:"userFailureMessage"` 264 UserInterfaceType string `json:"userInterfaceType"` 265 Version int `json:"version"` 266 WindowHeight interface{} `json:"windowHeight"` 267 WindowWidth interface{} `json:"windowWidth"` 268 YearsToKeep int `json:"yearsToKeep"` 269 } 270 271 type WalleeGroup struct { 272 BeginDate time.Time `json:"beginDate"` 273 CustomerId interface{} `json:"customerId"` 274 EndDate time.Time `json:"endDate"` 275 Id int `json:"id"` 276 LinkedSpaceId int `json:"linkedSpaceId"` 277 PlannedPurgeDate time.Time `json:"plannedPurgeDate"` 278 State string `json:"state"` 279 Version int `json:"version"` 280 } 281 282 type WalleePaymentConnectorConfiguration struct { 283 ApplicableForTransactionProcessing bool `json:"applicableForTransactionProcessing"` 284 Conditions []interface{} `json:"conditions"` 285 Connector int64 `json:"connector"` 286 EnabledSalesChannels []WalleeEnabledSalesChannels `json:"enabledSalesChannels"` 287 EnabledSpaceViews []interface{} `json:"enabledSpaceViews"` 288 Id int `json:"id"` 289 ImagePath string `json:"imagePath"` 290 LinkedSpaceId int `json:"linkedSpaceId"` 291 Name string `json:"name"` 292 PaymentMethodConfiguration WalleePaymentMethodConfiguration `json:"paymentMethodConfiguration"` 293 PlannedPurgeDate interface{} `json:"plannedPurgeDate"` 294 Priority int `json:"priority"` 295 ProcessorConfiguration WalleeProcessorConfiguration `json:"processorConfiguration"` 296 State string `json:"state"` 297 Version int `json:"version"` 298 } 299 300 type WalleeEnabledSalesChannels struct { 301 Description WalleeMultilangProperty `json:"description"` 302 Icon string `json:"icon"` 303 Id int64 `json:"id"` 304 Name WalleeMultilangProperty `json:"name"` 305 SortOrder int `json:"sortOrder"` 306 } 307 308 type WalleeMultilangProperty struct { 309 DeDE string `json:"de-DE"` 310 EnUS string `json:"en-US"` 311 FrFR string `json:"fr-FR"` 312 ItIT string `json:"it-IT"` 313 } 314 315 type WalleePaymentMethodConfiguration struct { 316 DataCollectionType string `json:"dataCollectionType"` 317 Description struct{} `json:"description"` 318 Id int `json:"id"` 319 ImageResourcePath interface{} `json:"imageResourcePath"` 320 LinkedSpaceId int `json:"linkedSpaceId"` 321 Name string `json:"name"` 322 OneClickPaymentMode string `json:"oneClickPaymentMode"` 323 PaymentMethod int64 `json:"paymentMethod"` 324 PlannedPurgeDate interface{} `json:"plannedPurgeDate"` 325 ResolvedDescription WalleeMultilangProperty `json:"resolvedDescription"` 326 ResolvedImageUrl string `json:"resolvedImageUrl"` 327 ResolvedTitle WalleeMultilangProperty `json:"resolvedTitle"` 328 SortOrder int `json:"sortOrder"` 329 SpaceId int `json:"spaceId"` 330 State string `json:"state"` 331 Title struct{} `json:"title"` 332 Version int `json:"version"` 333 } 334 335 type WalleeProcessorConfiguration struct { 336 ApplicationManaged bool `json:"applicationManaged"` 337 ContractId interface{} `json:"contractId"` 338 Id int `json:"id"` 339 LinkedSpaceId int `json:"linkedSpaceId"` 340 Name string `json:"name"` 341 PlannedPurgeDate interface{} `json:"plannedPurgeDate"` 342 Processor int64 `json:"processor"` 343 State string `json:"state"` 344 Version int `json:"version"` 345 } 346 347 type WalleeTerminal struct { 348 ConfigurationVersion WalleeConfigurationVersion `json:"configurationVersion"` 349 DefaultCurrency string `json:"defaultCurrency"` 350 DeviceName interface{} `json:"deviceName"` 351 DeviceSerialNumber string `json:"deviceSerialNumber"` 352 ExternalId string `json:"externalId"` 353 Id int `json:"id"` 354 Identifier string `json:"identifier"` 355 LinkedSpaceId int `json:"linkedSpaceId"` 356 LocationVersion WalleeLocationVersion `json:"locationVersion"` 357 Name string `json:"name"` 358 PlannedPurgeDate interface{} `json:"plannedPurgeDate"` 359 State string `json:"state"` 360 Type WalleeType `json:"type"` 361 Version int `json:"version"` 362 } 363 364 type WalleeConfigurationVersion struct { 365 Configuration WalleeConfiguration `json:"configuration"` 366 ConnectorConfigurations []int `json:"connectorConfigurations"` 367 CreatedBy int `json:"createdBy"` 368 CreatedOn time.Time `json:"createdOn"` 369 DefaultCurrency interface{} `json:"defaultCurrency"` 370 Id int `json:"id"` 371 LinkedSpaceId int `json:"linkedSpaceId"` 372 MaintenanceWindowDuration string `json:"maintenanceWindowDuration"` 373 MaintenanceWindowStart string `json:"maintenanceWindowStart"` 374 PlannedPurgeDate interface{} `json:"plannedPurgeDate"` 375 State string `json:"state"` 376 TimeZone string `json:"timeZone"` 377 Version int `json:"version"` 378 VersionAppliedImmediately bool `json:"versionAppliedImmediately"` 379 } 380 381 type WalleeConfiguration struct { 382 Id int `json:"id"` 383 LinkedSpaceId int `json:"linkedSpaceId"` 384 Name string `json:"name"` 385 PlannedPurgeDate interface{} `json:"plannedPurgeDate"` 386 State string `json:"state"` 387 Type WalleeType `json:"type"` 388 Version int `json:"version"` 389 } 390 391 type WalleeType struct { 392 Description WalleeMultilangProperty `json:"description"` 393 Id int64 `json:"id"` 394 Name WalleeMultilangProperty `json:"name"` 395 } 396 397 type WalleeLocationVersion struct { 398 Address WalleeAddress `json:"address"` 399 ContactAddress interface{} `json:"contactAddress"` 400 CreatedBy int `json:"createdBy"` 401 CreatedOn time.Time `json:"createdOn"` 402 Id int `json:"id"` 403 LinkedSpaceId int `json:"linkedSpaceId"` 404 Location WalleeLocation `json:"location"` 405 PlannedPurgeDate interface{} `json:"plannedPurgeDate"` 406 State string `json:"state"` 407 Version int `json:"version"` 408 VersionAppliedImmediately bool `json:"versionAppliedImmediately"` 409 } 410 411 type WalleeAddress struct { 412 City string `json:"city"` 413 Country string `json:"country"` 414 DependentLocality string `json:"dependentLocality"` 415 EmailAddress string `json:"emailAddress"` 416 FamilyName string `json:"familyName"` 417 GivenName string `json:"givenName"` 418 MobilePhoneNumber string `json:"mobilePhoneNumber"` 419 OrganizationName string `json:"organizationName"` 420 PhoneNumber string `json:"phoneNumber"` 421 PostalState interface{} `json:"postalState"` 422 Postcode string `json:"postcode"` 423 PostCode string `json:"postCode"` 424 Salutation string `json:"salutation"` 425 SortingCode string `json:"sortingCode"` 426 Street string `json:"street"` 427 } 428 429 type WalleeLocation struct { 430 ExternalId string `json:"externalId"` 431 Id int `json:"id"` 432 LinkedSpaceId int `json:"linkedSpaceId"` 433 Name string `json:"name"` 434 PlannedPurgeDate interface{} `json:"plannedPurgeDate"` 435 State string `json:"state"` 436 Version int `json:"version"` 437 }