mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
Merge pull request #339 from bcole808/issue-321-payment-links
Add payment link variables in invoice emails
This commit is contained in:
commit
a2b4c25a56
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use Utils;
|
use Utils;
|
||||||
use Event;
|
use Event;
|
||||||
|
use URL;
|
||||||
|
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
@ -41,6 +42,18 @@ class ContactMailer extends Mailer
|
|||||||
'$amount' => $invoiceAmount
|
'$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['body'] = str_replace(array_keys($variables), array_values($variables), $emailTemplate);
|
||||||
$data['link'] = $invitation->getLink();
|
$data['link'] = $invitation->getLink();
|
||||||
$data['entityType'] = $entityType;
|
$data['entityType'] = $entityType;
|
||||||
|
@ -108,7 +108,23 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
keys = ['footer', 'account', 'client', 'amount', 'link', 'contact'];
|
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++) {
|
for (var i=0; i<keys.length; i++) {
|
||||||
var regExp = new RegExp('\\$'+keys[i], 'g');
|
var regExp = new RegExp('\\$'+keys[i], 'g');
|
||||||
|
Loading…
Reference in New Issue
Block a user