mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-09 20:52:56 +01:00
Add payment link variables in invoice emails
This commit is contained in:
parent
9ffcf9f3ef
commit
bcc67d5b91
@ -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;
|
||||
|
@ -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
|
||||
<?php
|
||||
foreach([PAYMENT_TYPE_CREDIT_CARD, PAYMENT_TYPE_PAYPAL, PAYMENT_TYPE_BITCOIN] as $type) {
|
||||
if (Auth::user()->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<keys.length; i++) {
|
||||
var regExp = new RegExp('\\$'+keys[i], 'g');
|
||||
|
Loading…
Reference in New Issue
Block a user