You are here

class StripePaymentEvent in Stripe 2.x

Wraps a stripe event for webhook.

Hierarchy

  • class \Drupal\stripe\Event\StripePaymentEvent extends \Symfony\Component\EventDispatcher\Event

Expanded class hierarchy of StripePaymentEvent

2 files declare their use of StripePaymentEvent
StripeBase.php in src/Element/StripeBase.php
StripeExamplesEventSubscriber.php in modules/stripe_examples/src/EventSubscriber/StripeExamplesEventSubscriber.php

File

src/Event/StripePaymentEvent.php, line 11

Namespace

Drupal\stripe\Event
View source
class StripePaymentEvent extends Event {

  /**
   * The form.
   *
   * @var array
   */
  private $form;

  /**
   * The form state.
   *
   * @var \Drupal\Core\Form\FormStateInterface
   */
  private $formState;

  /**
   * Stripe element name
   *
   * @var array
   */
  private $element;

  /**
   * Total label and amounts
   *
   * @var array
   */
  private $total = [];

  /**
   * Total label and amounts
   *
   * @var array
   */
  private $billing = [];

  /**
   * Metadata key-value array
   *
   * @var array
   */
  private $metadata = [];

  /**
   * Constructor.
   *
   * @param array $form
   *   Nested array of form elements that comprise the form.
   * @param \Drupal\Core\Form\FormStateInterface $formState
   *   The current state of the form. The arguments that
   *   \Drupal::formBuilder()->getForm() was originally called with are
   *   available in the array $form_state->getBuildInfo()['args'].
   */
  public function __construct(array &$form, FormStateInterface $formState, $element) {
    $this->form =& $form;
    $this->formState = $formState;
    $this->element = $element;
  }

  /**
   * Get the form.
   *
   * @return array
   *   The form.
   */
  public function &getForm() : array {
    return $this->form;
  }

  /**
   * Get the form state.
   *
   * @return \Drupal\Core\Form\FormStateInterface
   *   The form state.
   */
  public function getFormState() : FormStateInterface {
    return $this->formState;
  }
  public function getFormElement() : string {
    return $this->element;
  }

  /**
   * Get the form id.
   *
   * @return string
   *   The form id.
   */
  public function getFormId() : string {
    return $this->formId;
  }
  public function setTotal(int $amount, string $label) {
    $this->total['amount'] = $amount;
    $this->total['label'] = $label;
  }
  public function setBillingCity(string $city) {
    $this->billing['address']['city'] = $city;
  }
  public function setBillingCountry(string $country) {
    $this->billing['address']['country'] = $country;
  }
  public function setBillingAddress1(string $address1) {
    $this->billing['address']['line1'] = $address1;
  }
  public function setBillingAddress2(string $address2) {
    $this->billing['address']['line2'] = $address2;
  }
  public function setBillingPostalCode(string $postal_code) {
    $this->billing['address']['postal_code'] = $postal_code;
  }
  public function setBillingState(string $state) {
    $this->billing['address']['state'] = $state;
  }
  public function setBillingEmail(string $email) {
    $this->billing['email'] = $email;
  }
  public function setBillingName(string $name) {
    $this->billing['name'] = $name;
  }
  public function setBillingPhone(string $phone) {
    $this->billing['phone'] = $phone;
  }
  public function setMetadata(string $key, $value) {
    $this->metadata[$key] = $value;
  }
  public function getMetadata() : array {
    return $this->metadata;
  }
  public function getBillingDetails() : array {
    return $this->billing;
  }
  public function getTotal() : array {
    return $this->total;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
StripePaymentEvent::$billing private property Total label and amounts
StripePaymentEvent::$element private property Stripe element name
StripePaymentEvent::$form private property The form.
StripePaymentEvent::$formState private property The form state.
StripePaymentEvent::$metadata private property Metadata key-value array
StripePaymentEvent::$total private property Total label and amounts
StripePaymentEvent::getBillingDetails public function
StripePaymentEvent::getForm public function Get the form.
StripePaymentEvent::getFormElement public function
StripePaymentEvent::getFormId public function Get the form id.
StripePaymentEvent::getFormState public function Get the form state.
StripePaymentEvent::getMetadata public function
StripePaymentEvent::getTotal public function
StripePaymentEvent::setBillingAddress1 public function
StripePaymentEvent::setBillingAddress2 public function
StripePaymentEvent::setBillingCity public function
StripePaymentEvent::setBillingCountry public function
StripePaymentEvent::setBillingEmail public function
StripePaymentEvent::setBillingName public function
StripePaymentEvent::setBillingPhone public function
StripePaymentEvent::setBillingPostalCode public function
StripePaymentEvent::setBillingState public function
StripePaymentEvent::setMetadata public function
StripePaymentEvent::setTotal public function
StripePaymentEvent::__construct public function Constructor.