Skip to content

Commit

Permalink
Merge pull request #5 from craftcms/bugfix/4-behaviour-and-db-compati…
Browse files Browse the repository at this point in the history
…bility

Bugfix/4 behaviour and db compatibility
  • Loading branch information
brandonkelly authored May 7, 2024
2 parents 50d6a94 + 58a704c commit 296f3b2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Release Notes for Stripe

## Unreleased
- Fixed an error that could occur on the My Account page, due to a plugin conflict. ([#4](https://github.com/craftcms/stripe/issues/4))
- Fixed a SQL error that could occur on MariaDB. ([#5](https://github.com/craftcms/stripe/pull/5))

## 1.0.0
- Initial release
4 changes: 3 additions & 1 deletion src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ public function init()
{
parent::init();

// we need to register the behavior as soon as possible
$this->registerBehaviors();

// Defer most setup tasks until Craft is fully initialized
Craft::$app->onInit(function() {
$request = Craft::$app->getRequest();
Expand All @@ -146,7 +149,6 @@ public function init()
$this->registerVariables();
$this->registerTwigExtension();
$this->registerResaveCommands();
$this->registerBehaviors();
$this->registerConditionRules();
$this->handleUserElementChanges();

Expand Down
6 changes: 3 additions & 3 deletions src/services/Invoices.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use Stripe\Invoice as StripeInvoice;
use yii\base\Component;
use yii\base\InvalidConfigException;
use yii\db\Expression;

/**
* Invoices service
Expand Down Expand Up @@ -161,9 +160,10 @@ public function getInvoiceById(?string $stripeId): Invoice|null
*/
public function getInvoicesByCustomerId(string $customerId): array
{
$qb = Craft::$app->getDb()->getQueryBuilder();
$invoices = $this->_createInvoiceQuery()
->addSelect(new Expression('ssid.data->"$.customer" AS customerId'))
->where(new Expression('ssid.data->"$.customer" = :customerId', ['customerId' => $customerId]))
->addSelect(['customerId' => $qb->jsonExtract('ssid.data', ['customer'])])
->where([$qb->jsonExtract('ssid.data', ['customer']) => $customerId])
->all();

if (!empty($invoices)) {
Expand Down
5 changes: 2 additions & 3 deletions src/services/PaymentMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use Stripe\PaymentMethod as StripePaymentMethod;
use yii\base\Component;
use yii\base\InvalidConfigException;
use yii\db\Expression;

/**
* Payment Methods service
Expand Down Expand Up @@ -162,8 +161,8 @@ public function getPaymentMethodById(?string $stripeId): PaymentMethod|null
public function getPaymentMethodsByCustomerId(string $customerId): array
{
$paymentMethods = $this->createPaymentMethodQuery()
->addSelect(new Expression('sspmd.data->"$.customer" AS customerId'))
->where(new Expression('sspmd.data->"$.customer" = :customerId', ['customerId' => $customerId]))
->addSelect('customerId')
->where(['customerId' => $customerId])
->all();

if (!empty($paymentMethods)) {
Expand Down

0 comments on commit 296f3b2

Please sign in to comment.