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

Commit

Permalink
Merge pull request #127 from laravel/develop
Browse files Browse the repository at this point in the history
Release v1.9.0
  • Loading branch information
sandervanhooft authored Dec 11, 2019
2 parents 899d661 + c5acf42 commit 2e20ab3
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 13 deletions.
11 changes: 7 additions & 4 deletions src/Billable.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ public function subscription($subscription = 'default')
*
* @param string $subscription
* @param string $plan
* @param array $firstPaymentOptions
* @return \Laravel\Cashier\SubscriptionBuilder\Contracts\SubscriptionBuilder
* @throws \Laravel\Cashier\Exceptions\InvalidMandateException
* @throws \Laravel\Cashier\Exceptions\PlanNotFoundException
* @throws \Throwable
*/
public function newSubscription($subscription, $plan)
public function newSubscription($subscription, $plan, $firstPaymentOptions = [])
{
if(! empty($this->mollie_mandate_id)) {

Expand All @@ -83,7 +85,7 @@ public function newSubscription($subscription, $plan)
}
}

return $this->newSubscriptionViaMollieCheckout($subscription, $plan);
return $this->newSubscriptionViaMollieCheckout($subscription, $plan, $firstPaymentOptions);
}

/**
Expand All @@ -92,12 +94,13 @@ public function newSubscription($subscription, $plan)
*
* @param $subscription
* @param $plan
* @param array $firstPaymentOptions
* @return \Laravel\Cashier\SubscriptionBuilder\FirstPaymentSubscriptionBuilder
* @throws \Laravel\Cashier\Exceptions\PlanNotFoundException
*/
public function newSubscriptionViaMollieCheckout($subscription, $plan)
public function newSubscriptionViaMollieCheckout($subscription, $plan, $firstPaymentOptions = [])
{
return new FirstPaymentSubscriptionBuilder($this, $subscription, $plan);
return new FirstPaymentSubscriptionBuilder($this, $subscription, $plan, $firstPaymentOptions);
}

/**
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.8.0';
const PACKAGE_VERSION = '1.9.0';

/**
* Bootstrap the application services.
Expand Down
9 changes: 7 additions & 2 deletions src/Order/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,13 @@ public function invoice($id = null, $date = null)

if(method_exists($owner, 'getExtraBillingInformation')) {
$extra_information = $owner->getExtraBillingInformation();
if($extra_information) {
$invoice->setExtraInformation([$extra_information]);

if(! empty($extra_information)) {
$extra_information = explode("\n", $extra_information);

if(is_array($extra_information) && ! empty($extra_information)) {
$invoice->setExtraInformation($extra_information);
}
}
}

Expand Down
11 changes: 7 additions & 4 deletions src/SubscriptionBuilder/FirstPaymentSubscriptionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,17 @@ class FirstPaymentSubscriptionBuilder implements Contract
* @param mixed $owner
* @param string $name
* @param string $plan
* @param array $paymentOptions
* @throws \Laravel\Cashier\Exceptions\PlanNotFoundException
*/
public function __construct(Model $owner, string $name, string $plan)
public function __construct(Model $owner, string $name, string $plan, $paymentOptions = [])
{
$this->owner = $owner;
$this->name = $name;

$this->plan = app(PlanRepository::class)::findOrFail($plan);

$this->initializeFirstPaymentBuilder($owner);
$this->initializeFirstPaymentBuilder($owner, $paymentOptions);

$this->startSubscription = new StartSubscription($owner, $name, $plan);
}
Expand Down Expand Up @@ -225,11 +227,12 @@ protected function validateCoupon()

/**
* @param \Illuminate\Database\Eloquent\Model $owner
* @param array $paymentOptions
* @return \Laravel\Cashier\FirstPayment\FirstPaymentBuilder
*/
protected function initializeFirstPaymentBuilder(Model $owner)
protected function initializeFirstPaymentBuilder(Model $owner, $paymentOptions = [])
{
$this->firstPaymentBuilder = new FirstPaymentBuilder($owner);
$this->firstPaymentBuilder = new FirstPaymentBuilder($owner, $paymentOptions);
$this->firstPaymentBuilder->setFirstPaymentMethod($this->plan->firstPaymentMethod());
$this->firstPaymentBuilder->setRedirectUrl($this->plan->firstPaymentRedirectUrl());
$this->firstPaymentBuilder->setWebhookUrl($this->plan->firstPaymentWebhookUrl());
Expand Down
4 changes: 2 additions & 2 deletions tests/Order/OrderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public function handlesOwnerBalance()
/** @test */
public function canGetInvoice()
{
$user = factory(User::class)->create(['extra_billing_information' => 'Some dummy extra billing information']);
$user = factory(User::class)->create(['extra_billing_information' => "Some dummy\nextra billing information"]);
$items = factory(OrderItem::class, 2)->states(['unlinked', 'EUR'])->create([
'owner_id' => $user->id,
'owner_type' => User::class,
Expand All @@ -215,7 +215,7 @@ public function canGetInvoice()
$this->assertEquals('2017-0000-0001', $invoice->id());
$this->assertEquals($date, $invoice->date());
$this->assertCount(2, $invoice->items());
$this->assertEquals('Some dummy extra billing information', $invoice->extraInformation(''));
$this->assertEquals(collect(['Some dummy', 'extra billing information']), $invoice->extraInformation());

$this->assertMoneyEURCents(500, $invoice->rawStartingBalance());
$this->assertMoneyEURCents(500, $invoice->rawUsedBalance());
Expand Down

0 comments on commit 2e20ab3

Please sign in to comment.