Skip to content

Commit

Permalink
Merge pull request #5 from dmyers/patch-2
Browse files Browse the repository at this point in the history
Added next payment attempt to stripe webhook controller.
  • Loading branch information
mmanos committed Jan 24, 2015
2 parents d7c38ce + 55ee823 commit 58bf08d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Mmanos/Billing/Gateways/Stripe/WebhookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Request;
use Symfony\Component\HttpFoundation\Response;
use Carbon\Carbon;

class WebhookController extends \Mmanos\Billing\Gateways\WebhookController
{
Expand Down Expand Up @@ -54,12 +55,17 @@ protected function handleInvoiceCreated(array $payload)
protected function handleInvoicePaymentFailed(array $payload)
{
if ($customer = $this->getCustomer($payload['data']['object']['customer'])) {
$next_payment_attempt = Arr::get($payload, 'data.object.next_payment_attempt');

$data = array(
'attempt_count' => Arr::get($payload, 'data.object.attempt_count'),
'next_payment_attempt' => Carbon::createFromTimeStamp($next_payment_attempt),
);

$customer->fireCustomerEvent(
'invoicePaymentFailed',
$customer->invoices()->find($payload['data']['object']['id']),
array(
'attempt_count' => Arr::get($payload, 'data.object.attempt_count'),
)
$data
);
}

Expand Down

0 comments on commit 58bf08d

Please sign in to comment.