Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Payment Notification to use greeting, remove text to 'Please print this confirmation for your records. #13655

Merged
merged 1 commit into from
Feb 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CRM/Contribute/Form/AdditionalPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,11 @@ public function submit($submittedValues) {
$this->_params['contact_id'] = $this->_contactId;
$this->_params['contribution_id'] = $this->_contributionId;

// These 2 rows are temporarily added for sequencing of adding commits. They won't be needed when we
// switch to Payment.send_confirmation api
$contact = civicrm_api3('Contact', 'getsingle', ['id' => $this->_contactId, 'return' => 'email_greeting']);
$this->assign('emailGreeting', $contact['email_greeting_display']);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as below!!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these 2 lines will go next pr


$sendReceipt = $this->emailReceipt($this->_params);
if ($sendReceipt) {
$statusMsg .= ' ' . ts('A receipt has been emailed to the contributor.');
Expand Down
4 changes: 4 additions & 0 deletions CRM/Financial/BAO/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ protected static function loadRelatedEntities($id) {
$contactID = self::getPaymentContactID($contributionID);
list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID);
$entities['contact'] = ['id' => $contactID, 'display_name' => $displayName, 'email' => $email];
$contact = civicrm_api3('Contact', 'getsingle', ['id' => $contactID, 'return' => 'email_greeting']);
$entities['contact']['email_greeting'] = $contact['email_greeting_display'];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems $contact is not used anywhere below so can we change it to:

$entities['contact']['email_greeting'] = civicrm_api3('Contact', 'getvalue', ['id' => $contactID, 'return' => 'email_greeting_display']);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@monishdeb nope we can't - if it's empty getvalue will throw an error


$participantRecords = civicrm_api3('ParticipantPayment', 'get', [
'contribution_id' => $contributionID,
Expand Down Expand Up @@ -214,6 +216,7 @@ public static function getPaymentContactID($contributionID) {
public static function getConfirmationTemplateParameters($entities) {
$templateVariables = [
'contactDisplayName' => $entities['contact']['display_name'],
'emailGreeting' => $entities['contact']['email_greeting'],
'totalAmount' => $entities['payment']['total'],
'amountOwed' => $entities['payment']['balance'],
'totalPaid' => $entities['payment']['paid'],
Expand Down Expand Up @@ -263,6 +266,7 @@ public static function filterUntestedTemplateVariables($params) {
'refundAmount',
'totalPaid',
'paymentsComplete',
'emailGreeting'
];
// These are assigned by the payment form - they still 'get through' from the
// form for now without being in here but we should ideally load
Expand Down
11 changes: 10 additions & 1 deletion CRM/Upgrade/Incremental/MessageTemplates.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,16 @@ protected function getTemplateUpdates() {
['name' => 'membership_online_receipt', 'type' => 'text'],
['name' => 'membership_online_receipt', 'type' => 'html'],
]
]
],
[
'version' => '5.12.alpha1',
'upgrade_descriptor' => ts('Update payment notification to remove print text, use email greeting'),
'label' => ts('Payment notification'),
'templates' => [
['name' => 'payment_or_refund_notification', 'type' => 'text'],
['name' => 'payment_or_refund_notification', 'type' => 'html'],
]
],
];
}

Expand Down
7 changes: 6 additions & 1 deletion tests/phpunit/CRM/Contribute/Form/AdditionalPaymentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,16 @@ public function testAddPaymentUsingCreditCardForPartialyPaidContribution() {
$this->checkResults(array(30, 70), 2);
$mut->assertSubjects(['Payment Receipt -']);
$mut->checkMailLog([
'Dear Anthony Anderson',
'Dear Anthony,',
'Payment Details',
'Total Fees: $ 100.00',
'This Payment Amount: $ 70.00',
'Balance Owed: $ 0.00 ',
'Billing Name and Address',
'Vancouver, AE 1321312',
'Visa',
'***********1111',
'Expires: May 2025',
]);

$mut->stop();
Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/api/v3/PaymentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function testPaymentEmailReceipt() {
$this->callAPISuccess('Payment', 'sendconfirmation', ['id' => $payment['id']]);
$mut->assertSubjects(['Payment Receipt - Annual CiviCRM meet']);
$mut->checkMailLog(array(
'Dear Mr. Anthony Anderson II',
'Dear Anthony,',
'Total Fees: $ 300.00',
'This Payment Amount: $ 50.00',
'Balance Owed: $ 100.00', //150 was paid in the 1st payment.
Expand Down Expand Up @@ -163,7 +163,7 @@ public function testPaymentEmailReceiptFullyPaid() {
$this->callAPISuccess('Payment', 'sendconfirmation', ['id' => $payment['id']]);
$mut->assertSubjects(['Payment Receipt - Annual CiviCRM meet']);
$mut->checkMailLog(array(
'Dear Mr. Anthony Anderson II',
'Dear Anthony,',
'A payment has been received.',
'Total Fees: $ 300.00',
'This Payment Amount: $ 150.00',
Expand Down Expand Up @@ -212,7 +212,7 @@ public function testRefundEmailReceipt($thousandSeparator) {
$this->callAPISuccess('Payment', 'sendconfirmation', ['id' => $payment['id']]);
$mut->assertSubjects(['Refund Notification - Annual CiviCRM meet']);
$mut->checkMailLog(array(
'Dear Mr. Anthony Anderson II',
'Dear Anthony,',
'A refund has been issued based on changes in your registration selections.',
'Total Fees: $ 300' . $decimalSeparator . '00',
'Refund Amount: $ -30' . $decimalSeparator . '00',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
{capture assign=emptyBlockStyle }style="padding: 10px; border-bottom: 1px solid #999;background-color: #f7f7f7;"{/capture}
{capture assign=emptyBlockValueStyle }style="padding: 10px; border-bottom: 1px solid #999;"{/capture}

<p>Dear {$contactDisplayName}</p>
{if $emailGreeting}<p>{$emailGreeting},</p>{/if}

<center>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree

<table width="620" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">

Expand All @@ -29,7 +30,6 @@
{else}
<p>{ts}A payment has been received.{/ts}</p>
{/if}
<p>{ts}Please print this confirmation for your records.{/ts}</p>
</td>
</tr>
<tr>
Expand Down Expand Up @@ -147,7 +147,7 @@
<tr>
<td>
<table style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse; width:100%;">
{if $contributeMode eq 'direct' and !$isAmountzero}
{if $billingName || $address}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are assigned in the processCreditCard code. I would have liked to load them for the db but we don't retain an address per payment - only per contribution - probably we should

<tr>
<th {$headerStyle}>
{ts}Billing Name and Address{/ts}
Expand All @@ -160,7 +160,7 @@
</td>
</tr>
{/if}
{if $contributeMode eq'direct' and !$isAmountzero}
{if $credit_card_number}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we would never have a card number here if it's not been used for a payment so we don't need contributeMode or to check the amount

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree

<tr>
<th {$headerStyle}>
{ts}Credit Card Information{/ts}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
Dear {$contactDisplayName}
{if $isRefund}
{if $emailGreeting}{$emailGreeting},
{/if}{if $isRefund}
{ts}A refund has been issued based on changes in your registration selections.{/ts}
{else}
{ts}A payment has been received.{/ts}
{/if}

{ts}Please print this confirmation for your records.{/ts}

{if $isRefund}
===============================================================================

Expand Down Expand Up @@ -46,7 +44,7 @@ Dear {$contactDisplayName}
{if $checkNumber}
{ts}Check Number{/ts}: {$checkNumber}
{/if}
{if $contributeMode eq 'direct' and !$isAmountzero}
{if $billingName || $address}

===============================================================================

Expand All @@ -58,7 +56,7 @@ Dear {$contactDisplayName}
{$address}
{/if}

{if $contributeMode eq 'direct' and !$isAmountzero}
{if $credit_card_number}
===========================================================
{ts}Credit Card Information{/ts}

Expand Down