Preview:
// This is the first function in which we get data from a request.
// After that we return a multidimensional array with that data.

/**
   * {@inheritDoc}
   */
  public function buildPaymentReportTable(Request $request) {
    $order_id = $request->request->get('oid');
    $authorization_code = $request->request->get('AuthCode');
    $payment_status = $request->request->get('Response');
    $transaction_status_code = $request->request->get('ProcReturnCode');
    $transaction_id = $request->request->get('TransId');
    $transaction_date = $request->request->get('EXTRA_TRXDATE');
    $status_code_3d = $request->request->get('mdStatus');

    // Add transaction data to order field.
    $order = $this->entityTypeManager
      ->getStorage('commerce_order')
      ->load($order_id);
    $order_data = [
      'order_id' => $order_id,
      'authorization_code' => $authorization_code,
      'payment_status' => $payment_status,
      'transaction_status_code' => $transaction_status_code,
      'transaction_id' => $transaction_id,
      'transaction_date' => $transaction_date,
      'status_code_3d' => $status_code_3d,
    ];
    $order->field_banca_intesa_data = json_encode($order_data);
    $order->save();

    return [
      ['name' => $this->t('Order ID'), 'value' => $order_id],
      ['name' => $this->t('Authorization code'), 'value' => $authorization_code],
      ['name' => $this->t('Payment status'), 'value' => $payment_status],
      ['name' => $this->t('Transaction status code'), 'value' => $transaction_status_code],
      ['name' => $this->t('Transaction ID'), 'value' => $transaction_id],
      ['name' => $this->t('Transaction date'), 'value' => $transaction_date],
      ['name' => $this->t('Status code for the 3D transaction'), 'value' => $status_code_3d],
    ];
  }



// This is the second function

  /**
   * {@inheritDoc}
   */
  public function getRenderedPaymentReportTable(Request $request) {
    $info_table_data = $this->buildPaymentReportTable($request);

    $info_table = [
      '#type' => 'table',
      '#header' => [$this->t('Parameter name'), $this->t('Parameter value')],
      '#rows' => $info_table_data,
    ];

    return $this->renderer->render($info_table);
  }
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter