Skip to main content

JhumanJ/OpnForm

3042 stars
2 code files
View JhumanJ/OpnForm on GitHub

app/Mail/Forms/SubmissionConfirmationMail.php

Open in GitHub
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
 
class FailedPaymentNotification extends Notification implements ShouldQueue
{
use Queueable;
 
public function via($notifiable)
{
return ['mail'];
}
 
public function toMail($notifiable)
{
return (new MailMessage)
->subject('Your Payment Failed')
->greeting(__('We tried to charge your card for your OpenForm subscription but the payment but did not work.'))
->line(__('Please go to OpenForm, click on your name on the top right corner, and click on "Billing".
You will then be able to update your card details. To avoid any service disruption, you can reply to this email whenever
you updated your card details, and we\'ll manually attempt to charge your card.'))
->action(__('Go to OpenForm'), url('/'));
}
}

app/Http/Controllers/Webhook/StripeController.php

Open in GitHub
use App\Notifications\Subscription\FailedPaymentNotification;
use Laravel\Cashier\Http\Controllers\WebhookController;
 
class StripeController extends WebhookController
{
//
protected function handleChargeFailed(array $payload)
{
if ($user = $this->getUserByStripeId($payload['data']['object']['customer'])) {
$user->notify(new FailedPaymentNotification());
}
 
return $this->successMethod();
}
//
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.