diff --git a/CRM/Stripe/DAO/StripeCustomer.php b/CRM/Stripe/DAO/StripeCustomer.php index 6cc55b2e4fbbba61a3659eb33c83e0d5345a2104..f842980b2220527cdfd464652d2072e5d5bf3880 100644 --- a/CRM/Stripe/DAO/StripeCustomer.php +++ b/CRM/Stripe/DAO/StripeCustomer.php @@ -1,274 +1,25 @@ <?php /** - * @package CRM - * @copyright CiviCRM LLC https://civicrm.org/licensing + * DAOs provide an OOP-style facade for reading and writing database records. * - * Generated from com.drastikbydesign.stripe/xml/schema/CRM/Stripe/StripeCustomer.xml - * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:dd1ed7f28d02b0186afd06a69db33b83) - */ -use CRM_Stripe_ExtensionUtil as E; - -/** - * Database access object for the StripeCustomer entity. + * DAOs are a primary source for metadata in older versions of CiviCRM (<5.74) + * and are required for some subsystems (such as APIv3). + * + * This stub provides compatibility. It is not intended to be modified in a + * substantive way. Property annotations may be added, but are not required. + * @property string $id + * @property string $customer_id + * @property string $contact_id + * @property string $processor_id + * @property string $currency */ -class CRM_Stripe_DAO_StripeCustomer extends CRM_Core_DAO { - const EXT = E::LONG_NAME; - const TABLE_ADDED = ''; +class CRM_Stripe_DAO_StripeCustomer extends CRM_Stripe_DAO_Base { /** - * Static instance to hold the table name. - * + * Required by older versions of CiviCRM (<5.74). * @var string */ public static $_tableName = 'civicrm_stripe_customers'; - /** - * Should CiviCRM log any modifications to this table in the civicrm_log table. - * - * @var bool - */ - public static $_log = TRUE; - - /** - * Unique ID - * - * @var int|string|null - * (SQL type: int unsigned) - * Note that values will be retrieved from the database as a string. - */ - public $id; - - /** - * Stripe Customer ID - * - * @var string|null - * (SQL type: varchar(255)) - * Note that values will be retrieved from the database as a string. - */ - public $customer_id; - - /** - * FK to Contact - * - * @var int|string|null - * (SQL type: int unsigned) - * Note that values will be retrieved from the database as a string. - */ - public $contact_id; - - /** - * ID from civicrm_payment_processor - * - * @var int|string|null - * (SQL type: int unsigned) - * Note that values will be retrieved from the database as a string. - */ - public $processor_id; - - /** - * 3 character string, value from Stripe customer. - * - * @var string|null - * (SQL type: varchar(3)) - * Note that values will be retrieved from the database as a string. - */ - public $currency; - - /** - * Class constructor. - */ - public function __construct() { - $this->__table = 'civicrm_stripe_customers'; - parent::__construct(); - } - - /** - * Returns localized title of this entity. - * - * @param bool $plural - * Whether to return the plural version of the title. - */ - public static function getEntityTitle($plural = FALSE) { - return $plural ? E::ts('Stripe Customers') : E::ts('Stripe Customer'); - } - - /** - * Returns all the column names of this table - * - * @return array - */ - public static function &fields() { - if (!isset(Civi::$statics[__CLASS__]['fields'])) { - Civi::$statics[__CLASS__]['fields'] = [ - 'id' => [ - 'name' => 'id', - 'type' => CRM_Utils_Type::T_INT, - 'title' => E::ts('ID'), - 'description' => E::ts('Unique ID'), - 'required' => TRUE, - 'usage' => [ - 'import' => FALSE, - 'export' => FALSE, - 'duplicate_matching' => FALSE, - 'token' => FALSE, - ], - 'where' => 'civicrm_stripe_customers.id', - 'table_name' => 'civicrm_stripe_customers', - 'entity' => 'StripeCustomer', - 'bao' => 'CRM_Stripe_DAO_StripeCustomer', - 'localizable' => 0, - 'readonly' => TRUE, - 'add' => NULL, - ], - 'customer_id' => [ - 'name' => 'customer_id', - 'type' => CRM_Utils_Type::T_STRING, - 'title' => E::ts('Stripe Customer ID'), - 'description' => E::ts('Stripe Customer ID'), - 'maxlength' => 255, - 'size' => CRM_Utils_Type::HUGE, - 'usage' => [ - 'import' => FALSE, - 'export' => FALSE, - 'duplicate_matching' => FALSE, - 'token' => FALSE, - ], - 'where' => 'civicrm_stripe_customers.customer_id', - 'table_name' => 'civicrm_stripe_customers', - 'entity' => 'StripeCustomer', - 'bao' => 'CRM_Stripe_DAO_StripeCustomer', - 'localizable' => 0, - 'html' => [ - 'type' => 'Text', - ], - 'add' => NULL, - ], - 'contact_id' => [ - 'name' => 'contact_id', - 'type' => CRM_Utils_Type::T_INT, - 'title' => E::ts('Contact ID'), - 'description' => E::ts('FK to Contact'), - 'usage' => [ - 'import' => FALSE, - 'export' => FALSE, - 'duplicate_matching' => FALSE, - 'token' => FALSE, - ], - 'where' => 'civicrm_stripe_customers.contact_id', - 'table_name' => 'civicrm_stripe_customers', - 'entity' => 'StripeCustomer', - 'bao' => 'CRM_Stripe_DAO_StripeCustomer', - 'localizable' => 0, - 'FKClassName' => 'CRM_Contact_DAO_Contact', - 'html' => [ - 'type' => 'EntityRef', - ], - 'add' => NULL, - ], - 'processor_id' => [ - 'name' => 'processor_id', - 'type' => CRM_Utils_Type::T_INT, - 'title' => E::ts('Payment Processor ID'), - 'description' => E::ts('ID from civicrm_payment_processor'), - 'usage' => [ - 'import' => FALSE, - 'export' => FALSE, - 'duplicate_matching' => FALSE, - 'token' => FALSE, - ], - 'where' => 'civicrm_stripe_customers.processor_id', - 'table_name' => 'civicrm_stripe_customers', - 'entity' => 'StripeCustomer', - 'bao' => 'CRM_Stripe_DAO_StripeCustomer', - 'localizable' => 0, - 'html' => [ - 'type' => 'EntityRef', - ], - 'pseudoconstant' => [ - 'table' => 'civicrm_payment_processor', - 'keyColumn' => 'id', - 'labelColumn' => 'name', - ], - 'add' => NULL, - ], - 'currency' => [ - 'name' => 'currency', - 'type' => CRM_Utils_Type::T_STRING, - 'title' => E::ts('Currency'), - 'description' => E::ts('3 character string, value from Stripe customer.'), - 'maxlength' => 3, - 'size' => CRM_Utils_Type::FOUR, - 'usage' => [ - 'import' => FALSE, - 'export' => FALSE, - 'duplicate_matching' => FALSE, - 'token' => FALSE, - ], - 'where' => 'civicrm_stripe_customers.currency', - 'headerPattern' => '/cur(rency)?/i', - 'dataPattern' => '/^[A-Z]{3}$/i', - 'default' => NULL, - 'table_name' => 'civicrm_stripe_customers', - 'entity' => 'StripeCustomer', - 'bao' => 'CRM_Stripe_DAO_StripeCustomer', - 'localizable' => 0, - 'html' => [ - 'type' => 'Text', - ], - 'add' => NULL, - ], - ]; - CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); - } - return Civi::$statics[__CLASS__]['fields']; - } - - /** - * Returns the list of fields that can be imported - * - * @param bool $prefix - * - * @return array - */ - public static function &import($prefix = FALSE) { - $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'stripe_customers', $prefix, []); - return $r; - } - - /** - * Returns the list of fields that can be exported - * - * @param bool $prefix - * - * @return array - */ - public static function &export($prefix = FALSE) { - $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'stripe_customers', $prefix, []); - return $r; - } - - /** - * Returns the list of indices - * - * @param bool $localize - * - * @return array - */ - public static function indices($localize = TRUE) { - $indices = [ - 'customer_id' => [ - 'name' => 'customer_id', - 'field' => [ - 0 => 'customer_id', - ], - 'localizable' => FALSE, - 'unique' => TRUE, - 'sig' => 'civicrm_stripe_customers::1::customer_id', - ], - ]; - return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices; - } - } diff --git a/CRM/Stripe/DAO/StripePaymentintent.php b/CRM/Stripe/DAO/StripePaymentintent.php index 17dd296db34aa7fc0c84c65ca913cfc51e888149..fe57746397b829d3fbb20f3747bc92f5433d8451 100644 --- a/CRM/Stripe/DAO/StripePaymentintent.php +++ b/CRM/Stripe/DAO/StripePaymentintent.php @@ -1,466 +1,32 @@ <?php /** - * @package CRM - * @copyright CiviCRM LLC https://civicrm.org/licensing + * DAOs provide an OOP-style facade for reading and writing database records. * - * Generated from com.drastikbydesign.stripe/xml/schema/CRM/Stripe/StripePaymentintent.xml - * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:b67646ad6a172031ee010ed01449d20e) - */ -use CRM_Stripe_ExtensionUtil as E; - -/** - * Database access object for the StripePaymentintent entity. + * DAOs are a primary source for metadata in older versions of CiviCRM (<5.74) + * and are required for some subsystems (such as APIv3). + * + * This stub provides compatibility. It is not intended to be modified in a + * substantive way. Property annotations may be added, but are not required. + * @property string $id + * @property string $stripe_intent_id + * @property string $contribution_id + * @property string $payment_processor_id + * @property string $description + * @property string $status + * @property string $identifier + * @property string $contact_id + * @property string $created_date + * @property string $flags + * @property string $referrer + * @property string $extra_data */ -class CRM_Stripe_DAO_StripePaymentintent extends CRM_Core_DAO { - const EXT = E::LONG_NAME; - const TABLE_ADDED = ''; +class CRM_Stripe_DAO_StripePaymentintent extends CRM_Stripe_DAO_Base { /** - * Static instance to hold the table name. - * + * Required by older versions of CiviCRM (<5.74). * @var string */ public static $_tableName = 'civicrm_stripe_paymentintent'; - /** - * Should CiviCRM log any modifications to this table in the civicrm_log table. - * - * @var bool - */ - public static $_log = TRUE; - - /** - * Unique ID - * - * @var int|string|null - * (SQL type: int unsigned) - * Note that values will be retrieved from the database as a string. - */ - public $id; - - /** - * The Stripe PaymentIntent/SetupIntent/PaymentMethod ID - * - * @var string|null - * (SQL type: varchar(255)) - * Note that values will be retrieved from the database as a string. - */ - public $stripe_intent_id; - - /** - * FK ID from civicrm_contribution - * - * @var int|string|null - * (SQL type: int unsigned) - * Note that values will be retrieved from the database as a string. - */ - public $contribution_id; - - /** - * Foreign key to civicrm_payment_processor.id - * - * @var int|string|null - * (SQL type: int unsigned) - * Note that values will be retrieved from the database as a string. - */ - public $payment_processor_id; - - /** - * Description of this paymentIntent - * - * @var string - * (SQL type: varchar(255)) - * Note that values will be retrieved from the database as a string. - */ - public $description; - - /** - * The status of the paymentIntent - * - * @var string - * (SQL type: varchar(25)) - * Note that values will be retrieved from the database as a string. - */ - public $status; - - /** - * An identifier that we can use in CiviCRM to find the paymentIntent if we do not have the ID (eg. session key) - * - * @var string - * (SQL type: varchar(255)) - * Note that values will be retrieved from the database as a string. - */ - public $identifier; - - /** - * FK to Contact - * - * @var int|string|null - * (SQL type: int unsigned) - * Note that values will be retrieved from the database as a string. - */ - public $contact_id; - - /** - * When was paymentIntent created - * - * @var string|null - * (SQL type: timestamp) - * Note that values will be retrieved from the database as a string. - */ - public $created_date; - - /** - * Flags associated with this PaymentIntent (NC=no contributionID when doPayment called) - * - * @var string - * (SQL type: varchar(100)) - * Note that values will be retrieved from the database as a string. - */ - public $flags; - - /** - * HTTP referrer of this paymentIntent - * - * @var string - * (SQL type: varchar(255)) - * Note that values will be retrieved from the database as a string. - */ - public $referrer; - - /** - * Extra data collected to help with diagnostics (such as email, name) - * - * @var string - * (SQL type: varchar(255)) - * Note that values will be retrieved from the database as a string. - */ - public $extra_data; - - /** - * Class constructor. - */ - public function __construct() { - $this->__table = 'civicrm_stripe_paymentintent'; - parent::__construct(); - } - - /** - * Returns localized title of this entity. - * - * @param bool $plural - * Whether to return the plural version of the title. - */ - public static function getEntityTitle($plural = FALSE) { - return $plural ? E::ts('Stripe Paymentintents') : E::ts('Stripe Paymentintent'); - } - - /** - * Returns all the column names of this table - * - * @return array - */ - public static function &fields() { - if (!isset(Civi::$statics[__CLASS__]['fields'])) { - Civi::$statics[__CLASS__]['fields'] = [ - 'id' => [ - 'name' => 'id', - 'type' => CRM_Utils_Type::T_INT, - 'title' => E::ts('ID'), - 'description' => E::ts('Unique ID'), - 'required' => TRUE, - 'usage' => [ - 'import' => FALSE, - 'export' => FALSE, - 'duplicate_matching' => FALSE, - 'token' => FALSE, - ], - 'where' => 'civicrm_stripe_paymentintent.id', - 'table_name' => 'civicrm_stripe_paymentintent', - 'entity' => 'StripePaymentintent', - 'bao' => 'CRM_Stripe_DAO_StripePaymentintent', - 'localizable' => 0, - 'readonly' => TRUE, - 'add' => NULL, - ], - 'stripe_intent_id' => [ - 'name' => 'stripe_intent_id', - 'type' => CRM_Utils_Type::T_STRING, - 'title' => E::ts('Stripe Intent ID'), - 'description' => E::ts('The Stripe PaymentIntent/SetupIntent/PaymentMethod ID'), - 'maxlength' => 255, - 'size' => CRM_Utils_Type::HUGE, - 'usage' => [ - 'import' => FALSE, - 'export' => FALSE, - 'duplicate_matching' => FALSE, - 'token' => FALSE, - ], - 'where' => 'civicrm_stripe_paymentintent.stripe_intent_id', - 'table_name' => 'civicrm_stripe_paymentintent', - 'entity' => 'StripePaymentintent', - 'bao' => 'CRM_Stripe_DAO_StripePaymentintent', - 'localizable' => 0, - 'add' => NULL, - ], - 'contribution_id' => [ - 'name' => 'contribution_id', - 'type' => CRM_Utils_Type::T_INT, - 'title' => E::ts('Contribution ID'), - 'description' => E::ts('FK ID from civicrm_contribution'), - 'usage' => [ - 'import' => FALSE, - 'export' => FALSE, - 'duplicate_matching' => FALSE, - 'token' => FALSE, - ], - 'where' => 'civicrm_stripe_paymentintent.contribution_id', - 'table_name' => 'civicrm_stripe_paymentintent', - 'entity' => 'StripePaymentintent', - 'bao' => 'CRM_Stripe_DAO_StripePaymentintent', - 'localizable' => 0, - 'add' => NULL, - ], - 'payment_processor_id' => [ - 'name' => 'payment_processor_id', - 'type' => CRM_Utils_Type::T_INT, - 'title' => E::ts('Payment Processor'), - 'description' => E::ts('Foreign key to civicrm_payment_processor.id'), - 'usage' => [ - 'import' => FALSE, - 'export' => FALSE, - 'duplicate_matching' => FALSE, - 'token' => FALSE, - ], - 'where' => 'civicrm_stripe_paymentintent.payment_processor_id', - 'table_name' => 'civicrm_stripe_paymentintent', - 'entity' => 'StripePaymentintent', - 'bao' => 'CRM_Stripe_DAO_StripePaymentintent', - 'localizable' => 0, - 'FKClassName' => 'CRM_Financial_DAO_PaymentProcessor', - 'pseudoconstant' => [ - 'table' => 'civicrm_payment_processor', - 'keyColumn' => 'id', - 'labelColumn' => 'name', - ], - 'add' => NULL, - ], - 'description' => [ - 'name' => 'description', - 'type' => CRM_Utils_Type::T_STRING, - 'title' => E::ts('Description'), - 'description' => E::ts('Description of this paymentIntent'), - 'required' => FALSE, - 'maxlength' => 255, - 'size' => CRM_Utils_Type::HUGE, - 'usage' => [ - 'import' => FALSE, - 'export' => FALSE, - 'duplicate_matching' => FALSE, - 'token' => FALSE, - ], - 'where' => 'civicrm_stripe_paymentintent.description', - 'table_name' => 'civicrm_stripe_paymentintent', - 'entity' => 'StripePaymentintent', - 'bao' => 'CRM_Stripe_DAO_StripePaymentintent', - 'localizable' => 0, - 'add' => NULL, - ], - 'status' => [ - 'name' => 'status', - 'type' => CRM_Utils_Type::T_STRING, - 'title' => E::ts('Status'), - 'description' => E::ts('The status of the paymentIntent'), - 'required' => FALSE, - 'maxlength' => 25, - 'size' => CRM_Utils_Type::MEDIUM, - 'usage' => [ - 'import' => FALSE, - 'export' => FALSE, - 'duplicate_matching' => FALSE, - 'token' => FALSE, - ], - 'where' => 'civicrm_stripe_paymentintent.status', - 'table_name' => 'civicrm_stripe_paymentintent', - 'entity' => 'StripePaymentintent', - 'bao' => 'CRM_Stripe_DAO_StripePaymentintent', - 'localizable' => 0, - 'add' => NULL, - ], - 'identifier' => [ - 'name' => 'identifier', - 'type' => CRM_Utils_Type::T_STRING, - 'title' => E::ts('Identifier'), - 'description' => E::ts('An identifier that we can use in CiviCRM to find the paymentIntent if we do not have the ID (eg. session key)'), - 'required' => FALSE, - 'maxlength' => 255, - 'size' => CRM_Utils_Type::HUGE, - 'usage' => [ - 'import' => FALSE, - 'export' => FALSE, - 'duplicate_matching' => FALSE, - 'token' => FALSE, - ], - 'where' => 'civicrm_stripe_paymentintent.identifier', - 'table_name' => 'civicrm_stripe_paymentintent', - 'entity' => 'StripePaymentintent', - 'bao' => 'CRM_Stripe_DAO_StripePaymentintent', - 'localizable' => 0, - 'add' => NULL, - ], - 'contact_id' => [ - 'name' => 'contact_id', - 'type' => CRM_Utils_Type::T_INT, - 'title' => E::ts('Contact ID'), - 'description' => E::ts('FK to Contact'), - 'usage' => [ - 'import' => FALSE, - 'export' => FALSE, - 'duplicate_matching' => FALSE, - 'token' => FALSE, - ], - 'where' => 'civicrm_stripe_paymentintent.contact_id', - 'table_name' => 'civicrm_stripe_paymentintent', - 'entity' => 'StripePaymentintent', - 'bao' => 'CRM_Stripe_DAO_StripePaymentintent', - 'localizable' => 0, - 'FKClassName' => 'CRM_Contact_DAO_Contact', - 'add' => NULL, - ], - 'created_date' => [ - 'name' => 'created_date', - 'type' => CRM_Utils_Type::T_TIMESTAMP, - 'title' => E::ts('Created Date'), - 'description' => E::ts('When was paymentIntent created'), - 'usage' => [ - 'import' => FALSE, - 'export' => FALSE, - 'duplicate_matching' => FALSE, - 'token' => FALSE, - ], - 'where' => 'civicrm_stripe_paymentintent.created_date', - 'default' => 'CURRENT_TIMESTAMP', - 'table_name' => 'civicrm_stripe_paymentintent', - 'entity' => 'StripePaymentintent', - 'bao' => 'CRM_Stripe_DAO_StripePaymentintent', - 'localizable' => 0, - 'add' => NULL, - ], - 'flags' => [ - 'name' => 'flags', - 'type' => CRM_Utils_Type::T_STRING, - 'title' => E::ts('Flags'), - 'description' => E::ts('Flags associated with this PaymentIntent (NC=no contributionID when doPayment called)'), - 'required' => FALSE, - 'maxlength' => 100, - 'size' => CRM_Utils_Type::HUGE, - 'usage' => [ - 'import' => FALSE, - 'export' => FALSE, - 'duplicate_matching' => FALSE, - 'token' => FALSE, - ], - 'where' => 'civicrm_stripe_paymentintent.flags', - 'table_name' => 'civicrm_stripe_paymentintent', - 'entity' => 'StripePaymentintent', - 'bao' => 'CRM_Stripe_DAO_StripePaymentintent', - 'localizable' => 0, - 'add' => NULL, - ], - 'referrer' => [ - 'name' => 'referrer', - 'type' => CRM_Utils_Type::T_STRING, - 'title' => E::ts('Referrer'), - 'description' => E::ts('HTTP referrer of this paymentIntent'), - 'required' => FALSE, - 'maxlength' => 255, - 'size' => CRM_Utils_Type::HUGE, - 'usage' => [ - 'import' => FALSE, - 'export' => FALSE, - 'duplicate_matching' => FALSE, - 'token' => FALSE, - ], - 'where' => 'civicrm_stripe_paymentintent.referrer', - 'table_name' => 'civicrm_stripe_paymentintent', - 'entity' => 'StripePaymentintent', - 'bao' => 'CRM_Stripe_DAO_StripePaymentintent', - 'localizable' => 0, - 'add' => NULL, - ], - 'extra_data' => [ - 'name' => 'extra_data', - 'type' => CRM_Utils_Type::T_STRING, - 'title' => E::ts('Extra Data'), - 'description' => E::ts('Extra data collected to help with diagnostics (such as email, name)'), - 'required' => FALSE, - 'maxlength' => 255, - 'size' => CRM_Utils_Type::HUGE, - 'usage' => [ - 'import' => FALSE, - 'export' => FALSE, - 'duplicate_matching' => FALSE, - 'token' => FALSE, - ], - 'where' => 'civicrm_stripe_paymentintent.extra_data', - 'table_name' => 'civicrm_stripe_paymentintent', - 'entity' => 'StripePaymentintent', - 'bao' => 'CRM_Stripe_DAO_StripePaymentintent', - 'localizable' => 0, - 'add' => NULL, - ], - ]; - CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); - } - return Civi::$statics[__CLASS__]['fields']; - } - - /** - * Returns the list of fields that can be imported - * - * @param bool $prefix - * - * @return array - */ - public static function &import($prefix = FALSE) { - $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'stripe_paymentintent', $prefix, []); - return $r; - } - - /** - * Returns the list of fields that can be exported - * - * @param bool $prefix - * - * @return array - */ - public static function &export($prefix = FALSE) { - $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'stripe_paymentintent', $prefix, []); - return $r; - } - - /** - * Returns the list of indices - * - * @param bool $localize - * - * @return array - */ - public static function indices($localize = TRUE) { - $indices = [ - 'UI_stripe_intent_id' => [ - 'name' => 'UI_stripe_intent_id', - 'field' => [ - 0 => 'stripe_intent_id', - ], - 'localizable' => FALSE, - 'unique' => TRUE, - 'sig' => 'civicrm_stripe_paymentintent::1::stripe_intent_id', - ], - ]; - return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices; - } - } diff --git a/info.xml b/info.xml index 428322114812b13cb1c4532976bf3c486a093a78..bb209bb8460cfa76836877d99246ee5f24fb5904 100644 --- a/info.xml +++ b/info.xml @@ -31,7 +31,7 @@ </requires> <civix> <namespace>CRM/Stripe</namespace> - <format>23.02.1</format> + <format>24.09.1</format> </civix> <classloader> <psr0 prefix="CRM_" path="."/> @@ -41,9 +41,9 @@ <mixin>menu-xml@1.0.0</mixin> <mixin>mgd-php@1.0.0</mixin> <mixin>setting-php@1.0.0</mixin> - <mixin>smarty-v2@1.0.1</mixin> - <mixin>entity-types-php@1.0.0</mixin> <mixin>setting-admin@1.0.1</mixin> + <mixin>entity-types-php@2.0.0</mixin> + <mixin>smarty@1.0.3</mixin> </mixins> - <upgrader>CRM_Stripe_Upgrader</upgrader> + <upgrader>CiviMix\Schema\Stripe\AutomaticUpgrader</upgrader> </extension> diff --git a/mixin/lib/civimix-schema@5.78.beta1.phar b/mixin/lib/civimix-schema@5.78.beta1.phar new file mode 100644 index 0000000000000000000000000000000000000000..079ec3621bbf0b61249d15b6934ec3a0ac19dc65 Binary files /dev/null and b/mixin/lib/civimix-schema@5.78.beta1.phar differ diff --git a/schema/StripeCustomer.entityType.php b/schema/StripeCustomer.entityType.php new file mode 100644 index 0000000000000000000000000000000000000000..b5a97b7c78392037d877de5ef34fefeb8d2a5315 --- /dev/null +++ b/schema/StripeCustomer.entityType.php @@ -0,0 +1,67 @@ +<?php +use CRM_Stripe_ExtensionUtil as E; +return [ + 'name' => 'StripeCustomer', + 'table' => 'civicrm_stripe_customers', + 'class' => 'CRM_Stripe_DAO_StripeCustomer', + 'getInfo' => fn() => [ + 'title' => E::ts('Stripe Customer'), + 'title_plural' => E::ts('Stripe Customers'), + 'description' => E::ts('Stripe Customers'), + 'log' => TRUE, + ], + 'getIndices' => fn() => [ + 'customer_id' => [ + 'fields' => [ + 'customer_id' => TRUE, + ], + 'unique' => TRUE, + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => E::ts('ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => E::ts('Unique ID'), + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'customer_id' => [ + 'title' => E::ts('Stripe Customer ID'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => E::ts('Stripe Customer ID'), + ], + 'contact_id' => [ + 'title' => E::ts('Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => E::ts('FK to Contact'), + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'processor_id' => [ + 'title' => E::ts('Payment Processor ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => E::ts('ID from civicrm_payment_processor'), + 'pseudoconstant' => [ + 'table' => 'civicrm_payment_processor', + 'key_column' => 'id', + 'label_column' => 'name', + ], + ], + 'currency' => [ + 'title' => E::ts('Currency'), + 'sql_type' => 'varchar(3)', + 'input_type' => 'Text', + 'description' => E::ts('3 character string, value from Stripe customer.'), + 'default' => NULL, + ], + ], +]; diff --git a/schema/StripePaymentintent.entityType.php b/schema/StripePaymentintent.entityType.php new file mode 100644 index 0000000000000000000000000000000000000000..99ea17be8bbd07feafa79b2f8d76a9383bd42b03 --- /dev/null +++ b/schema/StripePaymentintent.entityType.php @@ -0,0 +1,114 @@ +<?php +use CRM_Stripe_ExtensionUtil as E; +return [ + 'name' => 'StripePaymentintent', + 'table' => 'civicrm_stripe_paymentintent', + 'class' => 'CRM_Stripe_DAO_StripePaymentintent', + 'getInfo' => fn() => [ + 'title' => E::ts('Stripe Paymentintent'), + 'title_plural' => E::ts('Stripe Paymentintents'), + 'description' => E::ts('Stripe PaymentIntents'), + 'log' => TRUE, + ], + 'getIndices' => fn() => [ + 'UI_stripe_intent_id' => [ + 'fields' => [ + 'stripe_intent_id' => TRUE, + ], + 'unique' => TRUE, + ], + ], + 'getFields' => fn() => [ + 'id' => [ + 'title' => E::ts('ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'required' => TRUE, + 'description' => E::ts('Unique ID'), + 'primary_key' => TRUE, + 'auto_increment' => TRUE, + ], + 'stripe_intent_id' => [ + 'title' => E::ts('Stripe Intent ID'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => E::ts('The Stripe PaymentIntent/SetupIntent/PaymentMethod ID'), + ], + 'contribution_id' => [ + 'title' => E::ts('Contribution ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'Number', + 'description' => E::ts('FK ID from civicrm_contribution'), + ], + 'payment_processor_id' => [ + 'title' => E::ts('Payment Processor'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => E::ts('Foreign key to civicrm_payment_processor.id'), + 'pseudoconstant' => [ + 'table' => 'civicrm_payment_processor', + 'key_column' => 'id', + 'label_column' => 'name', + ], + 'entity_reference' => [ + 'entity' => 'PaymentProcessor', + 'key' => 'id', + 'on_delete' => 'SET NULL', + ], + ], + 'description' => [ + 'title' => E::ts('Description'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => E::ts('Description of this paymentIntent'), + ], + 'status' => [ + 'title' => E::ts('Status'), + 'sql_type' => 'varchar(25)', + 'input_type' => 'Text', + 'description' => E::ts('The status of the paymentIntent'), + ], + 'identifier' => [ + 'title' => E::ts('Identifier'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => E::ts('An identifier that we can use in CiviCRM to find the paymentIntent if we do not have the ID (eg. session key)'), + ], + 'contact_id' => [ + 'title' => E::ts('Contact ID'), + 'sql_type' => 'int unsigned', + 'input_type' => 'EntityRef', + 'description' => E::ts('FK to Contact'), + 'entity_reference' => [ + 'entity' => 'Contact', + 'key' => 'id', + 'on_delete' => 'CASCADE', + ], + ], + 'created_date' => [ + 'title' => E::ts('Created Date'), + 'sql_type' => 'timestamp', + 'input_type' => NULL, + 'description' => E::ts('When was paymentIntent created'), + 'default' => 'CURRENT_TIMESTAMP', + ], + 'flags' => [ + 'title' => E::ts('Flags'), + 'sql_type' => 'varchar(100)', + 'input_type' => 'Text', + 'description' => E::ts('Flags associated with this PaymentIntent (NC=no contributionID when doPayment called)'), + ], + 'referrer' => [ + 'title' => E::ts('Referrer'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => E::ts('HTTP referrer of this paymentIntent'), + ], + 'extra_data' => [ + 'title' => E::ts('Extra Data'), + 'sql_type' => 'varchar(255)', + 'input_type' => 'Text', + 'description' => E::ts('Extra data collected to help with diagnostics (such as email, name)'), + ], + ], +]; diff --git a/sql/auto_uninstall.sql b/sql/auto_uninstall.sql deleted file mode 100644 index 58e53bec6a1b76b75e699798808c6683d6c98f06..0000000000000000000000000000000000000000 --- a/sql/auto_uninstall.sql +++ /dev/null @@ -1,23 +0,0 @@ --- +--------------------------------------------------------------------+ --- | Copyright CiviCRM LLC. All rights reserved. | --- | | --- | This work is published under the GNU AGPLv3 license with some | --- | permitted exceptions and without any warranty. For full license | --- | and copyright information, see https://civicrm.org/licensing | --- +--------------------------------------------------------------------+ --- --- Generated from drop.tpl --- DO NOT EDIT. Generated by CRM_Core_CodeGen --- --- /******************************************************* --- * --- * Clean up the existing tables --- * --- *******************************************************/ - -SET FOREIGN_KEY_CHECKS=0; - -DROP TABLE IF EXISTS `civicrm_stripe_paymentintent`; -DROP TABLE IF EXISTS `civicrm_stripe_customers`; - -SET FOREIGN_KEY_CHECKS=1; \ No newline at end of file diff --git a/sql/customers_install.sql b/sql/customers_install.sql deleted file mode 100644 index 4a6632b5850160d66371fe0fb85bc3dc5ebc0d89..0000000000000000000000000000000000000000 --- a/sql/customers_install.sql +++ /dev/null @@ -1,18 +0,0 @@ --- /******************************************************* --- * --- * civicrm_stripe_customers --- * --- * Stripe Customers --- * --- *******************************************************/ -CREATE TABLE `civicrm_stripe_customers` ( - `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Unique ID', - `customer_id` varchar(255) COMMENT 'Stripe Customer ID', - `contact_id` int unsigned COMMENT 'FK to Contact', - `processor_id` int unsigned COMMENT 'ID from civicrm_payment_processor', - `currency` varchar(3) DEFAULT NULL COMMENT '3 character string, value from Stripe customer.', - PRIMARY KEY (`id`), - UNIQUE INDEX `customer_id`(customer_id), - CONSTRAINT FK_civicrm_stripe_customers_contact_id FOREIGN KEY (`contact_id`) REFERENCES `civicrm_contact`(`id`) ON DELETE CASCADE -) -ENGINE=InnoDB; diff --git a/sql/paymentintent_install.sql b/sql/paymentintent_install.sql deleted file mode 100644 index 185bb5883a4b851c8b0e6d586aa1e1821742c6e8..0000000000000000000000000000000000000000 --- a/sql/paymentintent_install.sql +++ /dev/null @@ -1,26 +0,0 @@ --- /******************************************************* --- * --- * civicrm_stripe_paymentintent --- * --- * Stripe PaymentIntents --- * --- *******************************************************/ -CREATE TABLE `civicrm_stripe_paymentintent` ( - `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'Unique ID', - `stripe_intent_id` varchar(255) COMMENT 'The Stripe PaymentIntent/SetupIntent/PaymentMethod ID', - `contribution_id` int unsigned COMMENT 'FK ID from civicrm_contribution', - `payment_processor_id` int unsigned COMMENT 'Foreign key to civicrm_payment_processor.id', - `description` varchar(255) NULL COMMENT 'Description of this paymentIntent', - `status` varchar(25) NULL COMMENT 'The status of the paymentIntent', - `identifier` varchar(255) NULL COMMENT 'An identifier that we can use in CiviCRM to find the paymentIntent if we do not have the ID (eg. session key)', - `contact_id` int unsigned COMMENT 'FK to Contact', - `created_date` timestamp DEFAULT CURRENT_TIMESTAMP COMMENT 'When was paymentIntent created', - `flags` varchar(100) NULL COMMENT 'Flags associated with this PaymentIntent (NC=no contributionID when doPayment called)', - `referrer` varchar(255) NULL COMMENT 'HTTP referrer of this paymentIntent', - `extra_data` varchar(255) NULL COMMENT 'Extra data collected to help with diagnostics (such as email, name)', - PRIMARY KEY (`id`), - UNIQUE INDEX `UI_stripe_intent_id`(stripe_intent_id), - CONSTRAINT FK_civicrm_stripe_paymentintent_payment_processor_id FOREIGN KEY (`payment_processor_id`) REFERENCES `civicrm_payment_processor`(`id`) ON DELETE SET NULL, - CONSTRAINT FK_civicrm_stripe_paymentintent_contact_id FOREIGN KEY (`contact_id`) REFERENCES `civicrm_contact`(`id`) ON DELETE CASCADE -) -ENGINE=InnoDB; diff --git a/stripe.civix.php b/stripe.civix.php index 15253e855d46800329dd579a5a5035db5b58bbfb..f91697497b295d12daf6c4eabcebe6af7d7c0007 100644 --- a/stripe.civix.php +++ b/stripe.civix.php @@ -75,10 +75,46 @@ class CRM_Stripe_ExtensionUtil { return self::CLASS_PREFIX . '_' . str_replace('\\', '_', $suffix); } + /** + * @return \CiviMix\Schema\SchemaHelperInterface + */ + public static function schema() { + if (!isset($GLOBALS['CiviMixSchema'])) { + pathload()->loadPackage('civimix-schema@5', TRUE); + } + return $GLOBALS['CiviMixSchema']->getHelper(static::LONG_NAME); + } + } use CRM_Stripe_ExtensionUtil as E; +pathload()->addSearchDir(__DIR__ . '/mixin/lib'); +spl_autoload_register('_stripe_civix_class_loader', TRUE, TRUE); + +function _stripe_civix_class_loader($class) { + if ($class === 'CRM_Stripe_DAO_Base') { + if (version_compare(CRM_Utils_System::version(), '5.74.beta', '>=')) { + class_alias('CRM_Core_DAO_Base', 'CRM_Stripe_DAO_Base'); + // ^^ Materialize concrete names -- encourage IDE's to pick up on this association. + } + else { + $realClass = 'CiviMix\\Schema\\Stripe\\DAO'; + class_alias($realClass, $class); + // ^^ Abstract names -- discourage IDE's from picking up on this association. + } + return; + } + + // This allows us to tap-in to the installation process (without incurring real file-reads on typical requests). + if (strpos($class, 'CiviMix\\Schema\\Stripe\\') === 0) { + // civimix-schema@5 is designed for backported use in download/activation workflows, + // where new revisions may become dynamically available. + pathload()->loadPackage('civimix-schema@5', TRUE); + CiviMix\Schema\loadClass($class); + } +} + /** * (Delegated) Implements hook_civicrm_config(). * diff --git a/tests/civicarrot.json b/tests/civicarrot.json index b809162b3070c1ec33a35554ab1276d574aa9215..acc3585f74a5340e9cfa91c47f1d2dc584d0c713 100644 --- a/tests/civicarrot.json +++ b/tests/civicarrot.json @@ -9,7 +9,7 @@ { "php-versions": "7.4", "drupal": "9.5.*", - "civicrm": "5.65.*" + "civicrm": "5.74.*" } ] } diff --git a/xml/schema/CRM/Stripe/StripeCustomer.entityType.php b/xml/schema/CRM/Stripe/StripeCustomer.entityType.php deleted file mode 100644 index 923ead6499b395dec66e005ca23d84e138ba76eb..0000000000000000000000000000000000000000 --- a/xml/schema/CRM/Stripe/StripeCustomer.entityType.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php -// This file declares a new entity type. For more details, see "hook_civicrm_entityTypes" at: -// https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_entityTypes -return [ - [ - 'name' => 'StripeCustomer', - 'class' => 'CRM_Stripe_DAO_StripeCustomer', - 'table' => 'civicrm_stripe_customers', - ], -]; diff --git a/xml/schema/CRM/Stripe/StripeCustomer.xml b/xml/schema/CRM/Stripe/StripeCustomer.xml deleted file mode 100644 index 1da63da8465ddf047d7aee141feb8ded01362d33..0000000000000000000000000000000000000000 --- a/xml/schema/CRM/Stripe/StripeCustomer.xml +++ /dev/null @@ -1,80 +0,0 @@ -<?xml version="1.0" encoding="iso-8859-1" ?> - -<table> - <base>CRM/Stripe</base> - <class>StripeCustomer</class> - <name>civicrm_stripe_customers</name> - <comment>Stripe Customers</comment> - <log>true</log> - - <field> - <name>id</name> - <type>int unsigned</type> - <required>true</required> - <comment>Unique ID</comment> - </field> - <primaryKey> - <name>id</name> - <autoincrement>true</autoincrement> - </primaryKey> - - <field> - <name>customer_id</name> - <title>Stripe Customer ID</title> - <type>varchar</type> - <length>255</length> - <comment>Stripe Customer ID</comment> - <html> - <type>Text</type> - </html> - </field> - <index> - <name>customer_id</name> - <fieldName>customer_id</fieldName> - <unique>true</unique> - </index> - - <field> - <name>contact_id</name> - <type>int unsigned</type> - <comment>FK to Contact</comment> - <html> - <type>EntityRef</type> - </html> - </field> - <foreignKey> - <name>contact_id</name> - <table>civicrm_contact</table> - <key>id</key> - <onDelete>CASCADE</onDelete> - </foreignKey> - - <field> - <name>processor_id</name> - <title>Payment Processor ID</title> - <type>int unsigned</type> - <comment>ID from civicrm_payment_processor</comment> - <html> - <type>EntityRef</type> - </html> - <pseudoconstant> - <table>civicrm_payment_processor</table> - <keyColumn>id</keyColumn> - <labelColumn>name</labelColumn> - </pseudoconstant> - </field> - <field> - <name>currency</name> - <type>varchar</type> - <length>3</length> - <default>NULL</default> - <headerPattern>/cur(rency)?/i</headerPattern> - <dataPattern>/^[A-Z]{3}$/i</dataPattern> - <comment>3 character string, value from Stripe customer.</comment> - <html> - <type>Text</type> - </html> - </field> - - -</table> diff --git a/xml/schema/CRM/Stripe/StripePaymentintent.entityType.php b/xml/schema/CRM/Stripe/StripePaymentintent.entityType.php deleted file mode 100644 index 999e2947592e5ff12da38733b10576bace0ffd65..0000000000000000000000000000000000000000 --- a/xml/schema/CRM/Stripe/StripePaymentintent.entityType.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php -// This file declares a new entity type. For more details, see "hook_civicrm_entityTypes" at: -// http://wiki.civicrm.org/confluence/display/CRMDOC/Hook+Reference -return array ( - 0 => - array ( - 'name' => 'StripePaymentintent', - 'class' => 'CRM_Stripe_DAO_StripePaymentintent', - 'table' => 'civicrm_stripe_paymentintent', - ), -); diff --git a/xml/schema/CRM/Stripe/StripePaymentintent.xml b/xml/schema/CRM/Stripe/StripePaymentintent.xml deleted file mode 100644 index e1ca5e6c5ab497057c19d24644ac77aa2df9c65f..0000000000000000000000000000000000000000 --- a/xml/schema/CRM/Stripe/StripePaymentintent.xml +++ /dev/null @@ -1,129 +0,0 @@ -<?xml version="1.0" encoding="iso-8859-1" ?> - -<table> - <base>CRM/Stripe</base> - <class>StripePaymentintent</class> - <name>civicrm_stripe_paymentintent</name> - <comment>Stripe PaymentIntents</comment> - <log>true</log> - - <field> - <name>id</name> - <type>int unsigned</type> - <required>true</required> - <comment>Unique ID</comment> - </field> - <primaryKey> - <name>id</name> - <autoincrement>true</autoincrement> - </primaryKey> - - <field> - <name>stripe_intent_id</name> - <title>Stripe Intent ID</title> - <type>varchar</type> - <length>255</length> - <comment>The Stripe PaymentIntent/SetupIntent/PaymentMethod ID</comment> - </field> - <index> - <name>UI_stripe_intent_id</name> - <fieldName>stripe_intent_id</fieldName> - <unique>true</unique> - </index> - - <field> - <name>contribution_id</name> - <title>Contribution ID</title> - <type>int unsigned</type> - <comment>FK ID from civicrm_contribution</comment> - </field> - - <field> - <name>payment_processor_id</name> - <title>Payment Processor</title> - <type>int unsigned</type> - <comment>Foreign key to civicrm_payment_processor.id</comment> - <pseudoconstant> - <table>civicrm_payment_processor</table> - <keyColumn>id</keyColumn> - <labelColumn>name</labelColumn> - </pseudoconstant> - </field> - <foreignKey> - <name>payment_processor_id</name> - <table>civicrm_payment_processor</table> - <key>id</key> - <onDelete>SET NULL</onDelete> - </foreignKey> - - <field> - <name>description</name> - <title>Description</title> - <type>varchar</type> - <required>false</required> - <length>255</length> - <comment>Description of this paymentIntent</comment> - </field> - - <field> - <name>status</name> - <type>varchar</type> - <length>25</length> - <required>false</required> - <comment>The status of the paymentIntent</comment> - </field> - - <field> - <name>identifier</name> - <type>varchar</type> - <length>255</length> - <required>false</required> - <comment>An identifier that we can use in CiviCRM to find the paymentIntent if we do not have the ID (eg. session key)</comment> - </field> - - <field> - <name>contact_id</name> - <type>int unsigned</type> - <comment>FK to Contact</comment> - </field> - <foreignKey> - <name>contact_id</name> - <table>civicrm_contact</table> - <key>id</key> - <onDelete>CASCADE</onDelete> - </foreignKey> - - <field> - <name>created_date</name> - <title>Created Date</title> - <type>timestamp</type> - <default>CURRENT_TIMESTAMP</default> - <comment>When was paymentIntent created</comment> - </field> - - <field> - <name>flags</name> - <type>varchar</type> - <length>100</length> - <required>false</required> - <comment>Flags associated with this PaymentIntent (NC=no contributionID when doPayment called)</comment> - </field> - - <field> - <name>referrer</name> - <title>Referrer</title> - <type>varchar</type> - <required>false</required> - <length>255</length> - <comment>HTTP referrer of this paymentIntent</comment> - </field> - - <field> - <name>extra_data</name> - <title>Extra Data</title> - <type>varchar</type> - <required>false</required> - <length>255</length> - <comment>Extra data collected to help with diagnostics (such as email, name)</comment> - </field> -</table>