Commit fe486656 authored by Vadym Abramchuk's avatar Vadym Abramchuk Committed by Vadym Abramchuk
Browse files

Issue #3270758 by abramm: Reformat long lines

parent fc2c9a88
Loading
Loading
Loading
Loading
+44 −10
Original line number Diff line number Diff line
@@ -202,8 +202,11 @@ class Omise extends OnsitePaymentGatewayBase implements OmiseInterface {
    $amount = $amount ?: $payment->getAmount();

    try {
      $remote_id = $payment->getRemoteId();
      $charge = \OmiseCharge::retrieve($remote_id, $this->configuration['public_key'], $this->configuration['secret_key']);
      $charge = \OmiseCharge::retrieve(
        $payment->getRemoteId(),
        $this->configuration['public_key'],
        $this->configuration['secret_key']
      );
      $charge->capture();
    }
    catch (\OmiseException $e) {
@@ -224,7 +227,11 @@ class Omise extends OnsitePaymentGatewayBase implements OmiseInterface {
    // Void Omise payment - release uncaptured payment.
    try {
      $remote_id = $payment->getRemoteId();
      $charge = \OmiseCharge::retrieve($remote_id, $this->configuration['public_key'], $this->configuration['secret_key']);
      $charge = \OmiseCharge::retrieve(
        $remote_id,
        $this->configuration['public_key'],
        $this->configuration['secret_key']
      );
      $data = [
        'amount' => $this->util->formatNumber($amount),
        'void' => TRUE,
@@ -256,7 +263,11 @@ class Omise extends OnsitePaymentGatewayBase implements OmiseInterface {
      $data = [
        'amount' => $this->util->formatNumber($amount),
      ];
      $charge = \OmiseCharge::retrieve($remote_id, $this->configuration['public_key'], $this->configuration['secret_key']);
      $charge = \OmiseCharge::retrieve(
        $remote_id,
        $this->configuration['public_key'],
        $this->configuration['secret_key']
      );
      $charge->refunds()->create($data);
    }
    catch (\OmiseException $e) {
@@ -311,7 +322,11 @@ class Omise extends OnsitePaymentGatewayBase implements OmiseInterface {
    try {
      $owner = $payment_method->getOwner();
      if ($owner && $remote_id = $this->getRemoteCustomerId($owner)) {
        $customer = \OmiseCustomer::retrieve($remote_id, $this->configuration['public_key'], $this->configuration['secret_key']);
        $customer = \OmiseCustomer::retrieve(
          $remote_id,
          $this->configuration['public_key'],
          $this->configuration['secret_key']
        );
        $customer->cards()->retrieve($payment_method->getRemoteId())->destroy();
      }
    }
@@ -349,14 +364,22 @@ class Omise extends OnsitePaymentGatewayBase implements OmiseInterface {
    if ($customer_id) {
      // If the customer id already exists
      // use the Omise form token to create the new card.
      $customer = \OmiseCustomer::retrieve($customer_id, $this->configuration['public_key'], $this->configuration['secret_key']);
      $customer = \OmiseCustomer::retrieve(
        $customer_id,
        $this->configuration['public_key'],
        $this->configuration['secret_key']
      );
      // Create a payment method for an existing customer.
      $customer->update(['card' => $payment_details['omise_token']]);

      // Unfortunately, there's no way to fetch the card we've just created so
      // the best we can do here is to extract the newest one.
      // Retrieve the list of cards, starting with the newest first.
      $cards = \OmiseCustomer::retrieve($customer['id'], $this->configuration['public_key'], $this->configuration['secret_key'])
      $cards = \OmiseCustomer::retrieve(
        $customer['id'],
        $this->configuration['public_key'],
        $this->configuration['secret_key']
      )
        ->cards(['order' => 'reverse_chronological']);

      foreach ($cards['data'] as $card) {
@@ -370,9 +393,16 @@ class Omise extends OnsitePaymentGatewayBase implements OmiseInterface {
          'email' => $owner->getEmail(),
          'description' => $this->t('Customer for :mail', [':mail' => $owner->getEmail()]),
          'card' => $payment_details['omise_token'],
        ], $this->configuration['public_key'], $this->configuration['secret_key']);
        ],
          $this->configuration['public_key'],
          $this->configuration['secret_key']
        );

        $cards = \OmiseCustomer::retrieve($customer['id'], $this->configuration['public_key'], $this->configuration['secret_key'])->cards();
        $cards = \OmiseCustomer::retrieve(
          $customer['id'],
          $this->configuration['public_key'],
          $this->configuration['secret_key']
        )->cards();

        $this->setRemoteCustomerId($owner, $customer['id']);
        $owner->save();
@@ -385,7 +415,11 @@ class Omise extends OnsitePaymentGatewayBase implements OmiseInterface {
      }
    }
    else {
      $card_token = \OmiseToken::retrieve($payment_details['omise_token'], $this->configuration['public_key'], $this->configuration['secret_key']);
      $card_token = \OmiseToken::retrieve(
        $payment_details['omise_token'],
        $this->configuration['public_key'],
        $this->configuration['secret_key']
      );
      $card = $card_token['card'];
      $card['id'] = $payment_details['omise_token'];
      return $card;