graycoreio/daffodil

View on GitHub
libs/customer-payment-authorizenet/driver/magento/src/payment.service.ts

Summary

Maintainability
A
0 mins
Test Coverage
import {
  Inject,
  Injectable,
} from '@angular/core';
import {
  Observable,
  of,
} from 'rxjs';

import { DaffAuthorizeNetPaymentId } from '@daffodil/authorizenet/driver';
import { DaffCustomerPaymentAuthorizeNetApplyRequest } from '@daffodil/customer-payment-authorizenet';
import { DaffCustomerPaymentAuthorizeNetPaymentDriverInterface } from '@daffodil/customer-payment-authorizenet/driver';
import { DaffPaymentResponse } from '@daffodil/payment';

@Injectable({
  providedIn: 'root',
})
export class DaffCustomerPaymentAuthorizeNetMagentoPaymentService implements DaffCustomerPaymentAuthorizeNetPaymentDriverInterface {
  constructor(
    @Inject(DaffAuthorizeNetPaymentId) private authorizeNetPaymentId: string,
  ) {}

  generateToken(request: DaffCustomerPaymentAuthorizeNetApplyRequest): Observable<DaffPaymentResponse> {
    return of({
      method: this.authorizeNetPaymentId,
      data: {
        code: this.authorizeNetPaymentId,
        tokenbase_data: {
          card_id: request.data.id,
          cc_cid: request.data.securityCode,
        },
      },
    });
  }
}