Skip to content
This repository has been archived by the owner on Feb 2, 2022. It is now read-only.

Commit

Permalink
Release v1.6.0 (#111)
Browse files Browse the repository at this point in the history
* redeemCoupon docs

* Test Order.findByPaymentId

* Test Order.findByPaymentId null

* Order status check fix

* Order findByPaymentIdOrFail

* Simplify Order.findByPaimentId

* guardMollieMandate

* helper money_to_decimal

* guardMollieMandate

* restartCycle

* improved Mandate retrieval and validation

* Use temporary payment_id to fix race condition

* SubscriptionBuilders skipTrial

* Improved mandate retrieval - status 410

* Preparing release v1.5.0

* Prefix temporary uuid

* Actually test findByPaymentIdOrFail

* Handle removing inexistent scheduled items

* MandateClearedFromBillable fix #109

* Use SerializesModels trait

* Prepare release v1.6.0
  • Loading branch information
sandervanhooft authored Nov 25, 2019
1 parent ae3e296 commit 59f639d
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Billable.php
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ public function clearMollieMandate()
$this->fill(['mollie_mandate_id' => null]);
$this->save();

dispatch(new MandateClearedFromBillable($this, $previousId));
event(new MandateClearedFromBillable($this, $previousId));

return $this;
}
Expand Down
2 changes: 1 addition & 1 deletion src/CashierServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

class CashierServiceProvider extends ServiceProvider
{
const PACKAGE_VERSION = '1.5.0';
const PACKAGE_VERSION = '1.6.0';

/**
* Bootstrap the application services.
Expand Down
3 changes: 3 additions & 0 deletions src/Events/BalanceTurnedStale.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

namespace Laravel\Cashier\Events;

use Illuminate\Queue\SerializesModels;
use Laravel\Cashier\Credit\Credit;

class BalanceTurnedStale
{
use SerializesModels;

/**
* @var \Laravel\Cashier\Credit\Credit
*/
Expand Down
3 changes: 3 additions & 0 deletions src/Events/CouponApplied.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

namespace Laravel\Cashier\Events;

use Illuminate\Queue\SerializesModels;
use Laravel\Cashier\Coupon\AppliedCoupon;
use Laravel\Cashier\Coupon\RedeemedCoupon;

class CouponApplied
{
use SerializesModels;

/**
* @var \Laravel\Cashier\Coupon\RedeemedCoupon
*/
Expand Down
3 changes: 3 additions & 0 deletions src/Events/FirstPaymentFailed.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

namespace Laravel\Cashier\Events;

use Illuminate\Queue\SerializesModels;
use Mollie\Api\Resources\Payment;

class FirstPaymentFailed
{
use SerializesModels;

/**
* @var \Mollie\Api\Resources\Payment
*/
Expand Down
6 changes: 5 additions & 1 deletion src/Events/MandateClearedFromBillable.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

namespace Laravel\Cashier\Events;

use Illuminate\Queue\SerializesModels;

class MandateClearedFromBillable
{
use SerializesModels;

/**
* @var \Illuminate\Database\Eloquent\Model
*/
Expand All @@ -17,7 +21,7 @@ class MandateClearedFromBillable
/**
* ClearedMandate constructor.
*
* @param \Illuminate\Database\Eloquent\Model $owner
* @param mixed $owner
* @param string $oldMandateId
*/
public function __construct($owner, string $oldMandateId)
Expand Down
3 changes: 3 additions & 0 deletions src/Events/MandateUpdated.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
namespace Laravel\Cashier\Events;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Queue\SerializesModels;

class MandateUpdated
{
use SerializesModels;

/** @var \Illuminate\Database\Eloquent\Model */
public $owner;

Expand Down
3 changes: 3 additions & 0 deletions src/Events/SubscriptionPlanSwapped.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

namespace Laravel\Cashier\Events;

use Illuminate\Queue\SerializesModels;
use Laravel\Cashier\Subscription;

class SubscriptionPlanSwapped
{
use SerializesModels;

/**
* @var \Laravel\Cashier\Subscription
*/
Expand Down
3 changes: 3 additions & 0 deletions src/Events/SubscriptionQuantityUpdated.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

namespace Laravel\Cashier\Events;

use Illuminate\Queue\SerializesModels;
use Laravel\Cashier\Subscription;

class SubscriptionQuantityUpdated
{
use SerializesModels;

/**
* @var \Laravel\Cashier\Subscription
*/
Expand Down
3 changes: 3 additions & 0 deletions src/Events/SubscriptionStarted.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

namespace Laravel\Cashier\Events;

use Illuminate\Queue\SerializesModels;
use Laravel\Cashier\Subscription;

class SubscriptionStarted
{
use SerializesModels;

/**
* @var \Laravel\Cashier\Subscription
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ protected function removeScheduledOrderItem($save = false)
{
$item = $this->scheduledOrderItem;

if($item->isProcessed(false)) {
if($item && $item->isProcessed(false)) {
$item->delete();
}

Expand Down
5 changes: 5 additions & 0 deletions tests/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,11 @@ protected function getCustomerUser($persist = true, $overrides = [])
], $overrides));
}

/**
* @param bool $persist
* @param array $overrides
* @return User
*/
protected function getUser($persist = true, $overrides = [])
{
$user = factory(User::class)->make($overrides);
Expand Down
22 changes: 21 additions & 1 deletion tests/BillableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

namespace Laravel\Cashier\Tests;

use Illuminate\Support\Facades\Event;
use Laravel\Cashier\Coupon\RedeemedCoupon;
use Laravel\Cashier\Coupon\RedeemedCouponCollection;
use Laravel\Cashier\Subscription;
use Laravel\Cashier\Events\MandateClearedFromBillable;
use Laravel\Cashier\SubscriptionBuilder\FirstPaymentSubscriptionBuilder;
use Laravel\Cashier\SubscriptionBuilder\MandatedSubscriptionBuilder;
use Laravel\Cashier\Tests\Fixtures\User;
Expand Down Expand Up @@ -111,4 +112,23 @@ public function canRedeemCouponAndRevokeOtherCoupons()
$this->assertEquals(0, $subscription->appliedCoupons()->count());
}

/** @test */
public function clearMollieMandate()
{
Event::fake();
$this->withPackageMigrations();
$user = $this->getUser(true, ['mollie_mandate_id' => 'foo-bar']);
$this->assertEquals('foo-bar', $user->mollieMandateId());

$user->clearMollieMandate();

$this->assertNull($user->mollieMandateId());
Event::assertDispatched(MandateClearedFromBillable::class, function ($e) use ($user) {
$this->assertEquals('foo-bar', $e->oldMandateId);
$this->assertTrue($e->owner->is($user));

return true;
});
}

}

0 comments on commit 59f639d

Please sign in to comment.