Skip to content

Commit c77786c

Browse files
authored
Merge pull request #298 from enupal/develop
Develop
2 parents e43349a + e380142 commit c77786c

File tree

5 files changed

+18
-8
lines changed

5 files changed

+18
-8
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Stripe Payments Changelog
22

3+
## 5.0.4 - 2022.06.26
4+
### Fixed
5+
- Fixed issue on subscription when using stripe elements ([#295])
6+
- Fixed issue when sync one-time and recurring orders ([#296])
7+
8+
[#295]: https://github.com/enupal/stripe/issues/295
9+
[#296]: https://github.com/enupal/stripe/issues/296
10+
311
## 5.0.3 - 2022.06.14
412
### Added
513
- Added support for [Affirm](https://stripe.com/en-gb/payments/affirm) payment method

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "enupal/stripe",
33
"description": "Allows customers sign up for recurring and one-time payments with Stripe, perfect for orders, donations, subscriptions, and events. Create simple payment forms in seconds easily without coding. For Craft CMS 3.x",
44
"type": "craft-plugin",
5-
"version": "5.0.3",
5+
"version": "5.0.4",
66
"keywords": [
77
"craft",
88
"cms",

src/jobs/SyncOneTimePayments.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public function execute($queue): void
125125
$newOrder->quantity = 1;
126126
$newOrder->isSubscription = false;
127127
$newOrder->dateOrdered = DateTimeHelper::toDateTime($charge['created'])->format('Y-m-d H:i:s');
128-
$newOrder->dateCreated = $newOrder->dateOrdered;
128+
$newOrder->dateCreated = DateTimeHelper::toDateTime($charge['created']);
129129
$newOrder->orderStatusId = $this->defaultStatusId;
130130
$newOrder->stripeTransactionId = $charge['id'];
131131
$newOrder->email = $email;

src/jobs/SyncSubscriptionPayments.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public function execute($queue): void
132132
$newOrder->totalPrice = StripePlugin::$app->orders->convertFromCents($invoice['amount_paid'], $newOrder->currency);
133133
$newOrder->quantity = $subscription['quantity'];
134134
$newOrder->dateOrdered = DateTimeHelper::toDateTime($invoice['created'])->format('Y-m-d H:i:s');
135-
$newOrder->dateCreated = $newOrder->dateOrdered;
135+
$newOrder->dateCreated = DateTimeHelper::toDateTime($invoice['created']);
136136
$newOrder->orderStatusId = $this->defaultStatusId;
137137
$newOrder->stripeTransactionId = $subscriptionId;
138138
$newOrder->email = $email;

src/services/Orders.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
use Stripe\InvoiceItem;
3434
use Stripe\Refund;
3535
use Stripe\Source;
36+
use Stripe\Subscription;
3637
use yii\base\Component;
3738
use enupal\stripe\records\Order as OrderRecord;
3839
use enupal\stripe\records\Customer as CustomerRecord;
@@ -1160,6 +1161,7 @@ private function addPlanToCustomer($customer, $planId, $data, $order)
11601161

11611162
// Add the plan to the customer
11621163
$subscriptionSettings = [
1164+
"customer" => $customer->id,
11631165
"plan" => $planId,
11641166
"trial_from_plan" => true,
11651167
'metadata' => $this->getStripeMetadata($data)
@@ -1183,8 +1185,7 @@ private function addPlanToCustomer($customer, $planId, $data, $order)
11831185
}
11841186

11851187
$subscriptionSettings['metadata'] = $this->getStripeMetadata($data);
1186-
1187-
$subscription = $customer->subscriptions->create($subscriptionSettings);
1188+
$subscription = Subscription::create($subscriptionSettings);
11881189

11891190
return $subscription;
11901191
}
@@ -1243,6 +1244,7 @@ private function addRecurringPayment($customer, $data, $paymentForm, $order)
12431244

12441245
// Add the plan to the customer
12451246
$subscriptionSettings = [
1247+
"customer" => $customer->id,
12461248
"plan" => $plan['id']
12471249
];
12481250

@@ -1258,7 +1260,7 @@ private function addRecurringPayment($customer, $data, $paymentForm, $order)
12581260

12591261
$subscriptionSettings['metadata'] = $this->getStripeMetadata($data);
12601262

1261-
$subscription = $customer->subscriptions->create($subscriptionSettings);
1263+
$subscription = Subscription::create($subscriptionSettings);
12621264

12631265
return $subscription;
12641266
}
@@ -1303,6 +1305,7 @@ private function addCustomPlan($customer, $data, $paymentForm)
13031305

13041306
// Add the plan to the customer
13051307
$subscriptionSettings = [
1308+
"customer" => $customer->id,
13061309
"plan" => $plan['id'],
13071310
"trial_from_plan" => true
13081311
];
@@ -1313,8 +1316,7 @@ private function addCustomPlan($customer, $data, $paymentForm)
13131316
}
13141317

13151318
$subscriptionSettings['metadata'] = $this->getStripeMetadata($data);
1316-
1317-
$subscription = $customer->subscriptions->create($subscriptionSettings);
1319+
$subscription = Subscription::create($subscriptionSettings);
13181320

13191321
return $subscription;
13201322
}

0 commit comments

Comments
 (0)