{"version":3,"file":"daffodil-authorizenet-driver-magento-2.4.7.mjs","names":["i1.DaffMagentoAuthorizeNetService"],"sources":["../../../libs/authorizenet/driver/magento/2.4.7/src/authorize-net-payment-id.ts","../../../libs/authorizenet/driver/magento/2.4.7/src/transformers/authorize-net-transformer.ts","../../../libs/authorizenet/driver/magento/2.4.7/src/authorize-net.service.ts","../../../libs/authorizenet/driver/magento/2.4.7/src/payment.service.ts","../../../libs/authorizenet/driver/magento/2.4.7/src/provider.ts","../../../libs/authorizenet/driver/magento/2.4.7/src/authorize-net.module.ts"],"sourcesContent":["export const MAGENTO_AUTHORIZE_NET_PAYMENT_ID = 'authorizenet_acceptjs';\n","import {\n  DaffAuthorizeNetTokenRequest,\n  AuthorizeNetResponse,\n  AuthorizeNetRequest,\n} from '@daffodil/authorizenet';\nimport { DaffAuthorizeNetConfig } from '@daffodil/authorizenet/driver';\n\nimport { MagentoAuthorizeNetPayment } from '../models/authorize-net-payment';\n\nexport function transformMagentoAuthorizeNetRequest(\n  request: DaffAuthorizeNetTokenRequest,\n  config: DaffAuthorizeNetConfig,\n): AuthorizeNetRequest {\n  return {\n    cardData: {\n      cardNumber: request.creditCard.cardnumber,\n      cardCode: request.creditCard.securitycode,\n      month: request.creditCard.month,\n      year: request.creditCard.year,\n    },\n    authData: {\n      clientKey: config.clientKey,\n      apiLoginID: config.apiLoginID,\n    },\n  };\n};\n\nexport function transformMagentoAuthorizeNetResponse(response: AuthorizeNetResponse, ccNumber: string): MagentoAuthorizeNetPayment {\n  return {\n    code: 'authorizenet_acceptjs',\n    authorizenet_acceptjs: {\n      cc_last_4: parseInt(ccNumber.slice(ccNumber.length - 4), 10),\n      opaque_data_descriptor: 'COMMON.ACCEPT.INAPP.PAYMENT',\n      opaque_data_value: response.opaqueData.dataValue,\n    },\n  };\n}\n","import {\n  Injectable,\n  Inject,\n} from '@angular/core';\nimport { Observable } from 'rxjs';\n\nimport {\n  DaffAuthorizeNetTokenRequest,\n  AuthorizeNetResponse,\n  DaffAcceptJsLoadingService,\n} from '@daffodil/authorizenet';\nimport {\n  DaffAuthorizeNetService,\n  DaffAuthorizeNetConfigToken,\n  DaffAuthorizeNetConfig,\n  DAFF_AUTHORIZE_NET_ERROR_CODE_MAP,\n  DaffAuthorizeNetUnconfiguredError,\n} from '@daffodil/authorizenet/driver';\n\nimport { MagentoAuthorizeNetPayment } from './models/authorize-net-payment';\nimport {\n  transformMagentoAuthorizeNetRequest,\n  transformMagentoAuthorizeNetResponse,\n} from './transformers/authorize-net-transformer';\n\n@Injectable({\n  providedIn: 'root',\n})\nexport class DaffMagentoAuthorizeNetService implements DaffAuthorizeNetService {\n\n  constructor(\n    @Inject(DaffAuthorizeNetConfigToken) public config: DaffAuthorizeNetConfig,\n    private acceptJsLoader: DaffAcceptJsLoadingService,\n  ) {\n    if (!this.config?.apiLoginID || !this.config?.clientKey) {\n      throw new DaffAuthorizeNetUnconfiguredError(\n        '`apiLoginID` and `clientKey` are empty, are you missing your Authorize.net Credentials?',\n      );\n    }\n  }\n\n  generateToken(paymentTokenRequest: DaffAuthorizeNetTokenRequest): Observable<MagentoAuthorizeNetPayment> {\n    return new Observable(observer => {\n      this.acceptJsLoader.getAccept().dispatchData(\n        transformMagentoAuthorizeNetRequest(paymentTokenRequest, this.config),\n        (response: AuthorizeNetResponse) => {\n          if (response.messages.resultCode === 'Error') {\n            const MappedError = DAFF_AUTHORIZE_NET_ERROR_CODE_MAP[response.messages.message[0].code];\n            const message = response.messages.message[0].code + ': ' + response.messages.message[0].text;\n\n            throw MappedError ? new MappedError(message) : new Error(message);\n          } else {\n            observer.next(transformMagentoAuthorizeNetResponse(response, paymentTokenRequest.creditCard.cardnumber));\n          }\n        },\n      );\n    });\n  }\n}\n","import { Injectable } from '@angular/core';\nimport {\n  map,\n  Observable,\n} from 'rxjs';\n\nimport {\n  DaffAuthorizenetPaymentRequest,\n  DaffAuthorizenetPaymentResponse,\n} from '@daffodil/authorizenet';\nimport { DaffAuthorizeNetPaymentDriverInterface } from '@daffodil/authorizenet/driver';\n\nimport { DaffMagentoAuthorizeNetService } from './authorize-net.service';\n\n@Injectable({\n  providedIn: 'root',\n})\nexport class DaffMagentoAuthorizeNetPaymentService implements DaffAuthorizeNetPaymentDriverInterface {\n  constructor(\n    private authorizenetService: DaffMagentoAuthorizeNetService,\n  ) {}\n\n  generateToken(request: DaffAuthorizenetPaymentRequest): Observable<DaffAuthorizenetPaymentResponse> {\n    return this.authorizenetService.generateToken(request.data).pipe(\n      map(response => ({\n        method: 'anet',\n        data: response,\n      })),\n    );\n  }\n}\n","import {\n  EnvironmentProviders,\n  makeEnvironmentProviders,\n} from '@angular/core';\n\nimport {\n  DaffAuthorizeNetConfig,\n  provideDaffAuthorizeNetConfigToken,\n  provideDaffAuthorizeNetDriver,\n  provideDaffAuthorizeNetPaymentDriver,\n  provideDaffAuthorizeNetPaymentId,\n} from '@daffodil/authorizenet/driver';\n\nimport { MAGENTO_AUTHORIZE_NET_PAYMENT_ID } from './authorize-net-payment-id';\nimport { DaffMagentoAuthorizeNetService } from './authorize-net.service';\nimport { DaffMagentoAuthorizeNetPaymentService } from './payment.service';\n\n/**\n * Provides the Magento implementations of the `@daffodil/authorizenet/driver` interfaces.\n *\n * Throws if `config` does not contain an `apiLoginID` and `clientKey`.\n */\nexport const provideDaffAuthorizeNetMagentoDriver = (config: DaffAuthorizeNetConfig): EnvironmentProviders => {\n  if(!config.apiLoginID || !config.clientKey) {\n    throw Error('You must provide an apiLoginID and clientKey for Authorize.Net configuration.');\n  }\n\n  return makeEnvironmentProviders([\n    provideDaffAuthorizeNetConfigToken(config),\n    provideDaffAuthorizeNetDriver(DaffMagentoAuthorizeNetService),\n    provideDaffAuthorizeNetPaymentDriver(DaffMagentoAuthorizeNetPaymentService),\n    provideDaffAuthorizeNetPaymentId(MAGENTO_AUTHORIZE_NET_PAYMENT_ID),\n  ]);\n};\n","import { CommonModule } from '@angular/common';\nimport {\n  NgModule,\n  ModuleWithProviders,\n} from '@angular/core';\n\nimport { DaffAuthorizeNetConfig } from '@daffodil/authorizenet/driver';\n\nimport { provideDaffAuthorizeNetMagentoDriver } from './provider';\n\n/**\n * @deprecated in favor of {@link provideDaffAuthorizeNetMagentoDriver} Deprecated in version 0.95.0. Will be removed in version 0.98.0.\n */\n@NgModule({\n  imports: [\n    CommonModule,\n  ],\n})\nexport class DaffMagentoAuthorizeNetDriverModule {\n  static forRoot(config: DaffAuthorizeNetConfig): ModuleWithProviders<DaffMagentoAuthorizeNetDriverModule> {\n    return {\n      ngModule: DaffMagentoAuthorizeNetDriverModule,\n      providers: [\n        provideDaffAuthorizeNetMagentoDriver(config),\n      ],\n    };\n  }\n}\n"],"mappings":";;;;;;AAAA,MAAa,mCAAmC;ACShD,SAAgB,oCACd,SACA,QAA8B;CAE9B,OAAO;EACL,UAAU;GACR,YAAY,QAAQ,WAAW;GAC/B,UAAU,QAAQ,WAAW;GAC7B,OAAO,QAAQ,WAAW;GAC1B,MAAM,QAAQ,WAAW;EAC1B;EACD,UAAU;GACR,WAAW,OAAO;GAClB,YAAY,OAAO;EACpB;CACF;AACH;AAEA,SAAgB,qCAAqC,UAAgC,UAAgB;CACnG,OAAO;EACL,MAAM;EACN,uBAAuB;GACrB,WAAW,SAAS,SAAS,MAAM,SAAS,SAAS,CAAC,GAAG,EAAE;GAC3D,wBAAwB;GACxB,mBAAmB,SAAS,WAAW;EACxC;CACF;AACH;ACRA,IAAa,iCAAb,MAAa,+BAA8B;CAEzC,YAC8C,QACpC,gBAA0C;EADN,KAAA,SAAA;EACpC,KAAA,iBAAA;EAER,IAAI,CAAC,KAAK,QAAQ,cAAc,CAAC,KAAK,QAAQ,WAC5C,MAAM,IAAI,kCACR,yFAAyF;CAG/F;CAEA,cAAc,qBAAiD;EAC7D,OAAO,IAAI,YAAW,aAAW;GAC/B,KAAK,eAAe,UAAS,CAAE,CAAC,aAC9B,oCAAoC,qBAAqB,KAAK,MAAM,IACnE,aAAkC;IACjC,IAAI,SAAS,SAAS,eAAe,SAAS;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