diff --git a/app/Ninja/Mailers/ContactMailer.php b/app/Ninja/Mailers/ContactMailer.php index 4df49bb956..9dfff49f0e 100644 --- a/app/Ninja/Mailers/ContactMailer.php +++ b/app/Ninja/Mailers/ContactMailer.php @@ -2,6 +2,7 @@ use Utils; use Event; +use URL; use App\Models\Invoice; use App\Models\Payment; @@ -41,6 +42,18 @@ class ContactMailer extends Mailer '$amount' => $invoiceAmount ]; + // Add variables for available payment types + foreach([PAYMENT_TYPE_CREDIT_CARD, PAYMENT_TYPE_PAYPAL, PAYMENT_TYPE_BITCOIN] as $type) { + if ($invoice->account->getGatewayByType($type)) { + + // Changes "PAYMENT_TYPE_CREDIT_CARD" to "$credit_card_link" + $gateway_slug = '$'.strtolower(str_replace('PAYMENT_TYPE_', '', $type)).'_link'; + + $variables[$gateway_slug] = URL::to("/payment/{$invitation->invitation_key}/{$type}"); + + } + } + $data['body'] = str_replace(array_keys($variables), array_values($variables), $emailTemplate); $data['link'] = $invitation->getLink(); $data['entityType'] = $entityType; diff --git a/resources/views/accounts/email_templates.blade.php b/resources/views/accounts/email_templates.blade.php index a2d5876b4f..5b57c7d8dc 100644 --- a/resources/views/accounts/email_templates.blade.php +++ b/resources/views/accounts/email_templates.blade.php @@ -108,7 +108,23 @@ } keys = ['footer', 'account', 'client', 'amount', 'link', 'contact']; - vals = [{!! json_encode($emailFooter) !!}, '{!! Auth::user()->account->getDisplayName() !!}', 'Client Name', formatMoney(100), '{!! NINJA_WEB_URL !!}', 'Contact Name'] + vals = [{!! json_encode($emailFooter) !!}, '{!! Auth::user()->account->getDisplayName() !!}', 'Client Name', formatMoney(100), '{!! NINJA_WEB_URL !!}', 'Contact Name']; + + // Add any available payment method links + account->getGatewayByType($type)) { + + // Changes "PAYMENT_TYPE_CREDIT_CARD" to "credit_card" + $gateway_slug = strtolower(str_replace('PAYMENT_TYPE_', '', $type)).'_link'; + + echo "keys.push('$gateway_slug'); "; + echo "vals.push('".URL::to("/payment/xxxxxx/{$type}")."'); "; + echo "\n"; + + } + } + ?> for (var i=0; i