Skip to content

Commit

Permalink
Merge pull request #298 from enupal/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
andrelopez authored Jun 26, 2022
2 parents e43349a + e380142 commit c77786c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Stripe Payments Changelog

## 5.0.4 - 2022.06.26
### Fixed
- Fixed issue on subscription when using stripe elements ([#295])
- Fixed issue when sync one-time and recurring orders ([#296])

[#295]: https://github.com/enupal/stripe/issues/295
[#296]: https://github.com/enupal/stripe/issues/296

## 5.0.3 - 2022.06.14
### Added
- Added support for [Affirm](https://stripe.com/en-gb/payments/affirm) payment method
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "enupal/stripe",
"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",
"type": "craft-plugin",
"version": "5.0.3",
"version": "5.0.4",
"keywords": [
"craft",
"cms",
Expand Down
2 changes: 1 addition & 1 deletion src/jobs/SyncOneTimePayments.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function execute($queue): void
$newOrder->quantity = 1;
$newOrder->isSubscription = false;
$newOrder->dateOrdered = DateTimeHelper::toDateTime($charge['created'])->format('Y-m-d H:i:s');
$newOrder->dateCreated = $newOrder->dateOrdered;
$newOrder->dateCreated = DateTimeHelper::toDateTime($charge['created']);
$newOrder->orderStatusId = $this->defaultStatusId;
$newOrder->stripeTransactionId = $charge['id'];
$newOrder->email = $email;
Expand Down
2 changes: 1 addition & 1 deletion src/jobs/SyncSubscriptionPayments.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function execute($queue): void
$newOrder->totalPrice = StripePlugin::$app->orders->convertFromCents($invoice['amount_paid'], $newOrder->currency);
$newOrder->quantity = $subscription['quantity'];
$newOrder->dateOrdered = DateTimeHelper::toDateTime($invoice['created'])->format('Y-m-d H:i:s');
$newOrder->dateCreated = $newOrder->dateOrdered;
$newOrder->dateCreated = DateTimeHelper::toDateTime($invoice['created']);
$newOrder->orderStatusId = $this->defaultStatusId;
$newOrder->stripeTransactionId = $subscriptionId;
$newOrder->email = $email;
Expand Down
12 changes: 7 additions & 5 deletions src/services/Orders.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use Stripe\InvoiceItem;
use Stripe\Refund;
use Stripe\Source;
use Stripe\Subscription;
use yii\base\Component;
use enupal\stripe\records\Order as OrderRecord;
use enupal\stripe\records\Customer as CustomerRecord;
Expand Down Expand Up @@ -1160,6 +1161,7 @@ private function addPlanToCustomer($customer, $planId, $data, $order)

// Add the plan to the customer
$subscriptionSettings = [
"customer" => $customer->id,
"plan" => $planId,
"trial_from_plan" => true,
'metadata' => $this->getStripeMetadata($data)
Expand All @@ -1183,8 +1185,7 @@ private function addPlanToCustomer($customer, $planId, $data, $order)
}

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

$subscription = $customer->subscriptions->create($subscriptionSettings);
$subscription = Subscription::create($subscriptionSettings);

return $subscription;
}
Expand Down Expand Up @@ -1243,6 +1244,7 @@ private function addRecurringPayment($customer, $data, $paymentForm, $order)

// Add the plan to the customer
$subscriptionSettings = [
"customer" => $customer->id,
"plan" => $plan['id']
];

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

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

$subscription = $customer->subscriptions->create($subscriptionSettings);
$subscription = Subscription::create($subscriptionSettings);

return $subscription;
}
Expand Down Expand Up @@ -1303,6 +1305,7 @@ private function addCustomPlan($customer, $data, $paymentForm)

// Add the plan to the customer
$subscriptionSettings = [
"customer" => $customer->id,
"plan" => $plan['id'],
"trial_from_plan" => true
];
Expand All @@ -1313,8 +1316,7 @@ private function addCustomPlan($customer, $data, $paymentForm)
}

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

$subscription = $customer->subscriptions->create($subscriptionSettings);
$subscription = Subscription::create($subscriptionSettings);

return $subscription;
}
Expand Down

0 comments on commit c77786c

Please sign in to comment.