Commit c56519ad authored by Vadym Abramchuk's avatar Vadym Abramchuk
Browse files

Issue #3270758 by abramm: Store payment methods for anonymous users as not...

Issue #3270758 by abramm: Store payment methods for anonymous users as not reusable since they are not associated with any Omise account
parent 0e860a77
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -352,9 +352,13 @@ class Omise extends OnsitePaymentGatewayBase implements OmiseInterface {
    $payment_method->card_number = $remote_payment_method['last_digits'];
    $payment_method->card_exp_month = $remote_payment_method['expiration_month'];
    $payment_method->card_exp_year = $remote_payment_method['expiration_year'];
    $remote_id = $remote_payment_method['id'];
    $expires = CreditCard::calculateExpirationTimestamp($remote_payment_method['expiration_month'], $remote_payment_method['expiration_year']);
    $payment_method->setRemoteId($remote_id);
    $payment_method->setRemoteId($remote_payment_method['id']);
    if (isset($remote_payment_method['token'])) {
      // Handle one-time / non-reusable card.
      $payment_method->setRemoteId($remote_payment_method['token']);
      $payment_method->setReusable(FALSE);
    }
    $payment_method->setExpiresTime($expires);
    $payment_method->save();
  }
@@ -442,8 +446,9 @@ class Omise extends OnsitePaymentGatewayBase implements OmiseInterface {
   *
   * @return array
   *   The payment method information returned by the gateway. Notable keys:
   *   - id: The remote ID. This could be either one-time token (for anonymous)
   *     or the stored card ID.
   *   - id: The remote card ID. This is a remote REUSABLE card object ID which
   *     should be only used for authorized users.
   *   - token: The ONE TIME card token.
   *   Credit card specific keys:
   *   - card_type: The card type.
   *   - last4: The last 4 digits of the credit card number.
@@ -528,8 +533,7 @@ class Omise extends OnsitePaymentGatewayBase implements OmiseInterface {
        $this->configuration['secret_key']
      );
      $cardByToken = $existingCard['card'];
      // TODO: Pass token instead of card ID?
      $cardByToken['id'] = $payment_details['omise_token'];
      $cardByToken['token'] = $payment_details['omise_token'];
      return $cardByToken;
    }