You are here

protected function AcceptJsPaymentMethodTest::createDataDescriptor in Commerce Authorize.Net 8

Creates data descriptor information.

Replicates the JS calls.

@link https://community.developer.authorize.net/t5/Integration-and-Testing/Acc...

Return value

object The response.

Throws

\CommerceGuys\AuthNet\Exception\AuthNetException

5 calls to AcceptJsPaymentMethodTest::createDataDescriptor()
AcceptJsPaymentMethodTest::testCreatePaymentMethodForAnonymous in tests/src/Kernel/AcceptJsPaymentMethodTest.php
Tests creating the payment method for an anonymous users.
AcceptJsPaymentMethodTest::testCreatePaymentMethodForAuthenticated in tests/src/Kernel/AcceptJsPaymentMethodTest.php
Tests creating the payment method for an authenticated users.
AcceptJsPaymentMethodTest::testDuplicateProfiles in tests/src/Kernel/AcceptJsPaymentMethodTest.php
Tests creating a duplicate profile.
AcceptJsPaymentMethodTest::testUpdatePaymentMethod in tests/src/Kernel/AcceptJsPaymentMethodTest.php
Tests creating the payment method for an authenticated users.
AcceptJsPaymentMethodTest::testWithDataWhichHasDelimeter in tests/src/Kernel/AcceptJsPaymentMethodTest.php
Tests creating a payment method which has the delimeter in the address.

File

tests/src/Kernel/AcceptJsPaymentMethodTest.php, line 101

Class

AcceptJsPaymentMethodTest
Tests creating a payment method with AcceptJS.

Namespace

Drupal\Tests\commerce_authnet\Kernel

Code

protected function createDataDescriptor() {
  $configuration = $this
    ->createApiConfiguration();
  $request = new JsonRequest($configuration, $this->container
    ->get('http_client'), 'securePaymentContainerRequest');
  $request
    ->addDataType(new MerchantAuthentication([
    'name' => $configuration
      ->getApiLogin(),
    'transactionKey' => $configuration
      ->getTransactionKey(),
  ]));
  $request
    ->addData('refId', '12345');
  $request
    ->addData('data', [
    'type' => 'TOKEN',
    'id' => $this
      ->randomString(),
    'token' => [
      'cardNumber' => '5424000000000015',
      'expirationDate' => '122027',
      'cardCode' => '900',
      'fullName' => 'Testy McTesterson',
    ],
  ]);
  $response = $request
    ->sendRequest();
  $this
    ->assertTrue($response
    ->getResultCode() == 'Ok');
  $opaque_data = $response->opaqueData;
  $this
    ->assertNotEmpty($opaque_data);
  return $opaque_data;
}