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

Allow descriptions for payment fields #12721

Merged
merged 1 commit into from
Sep 13, 2018

Conversation

mattwire
Copy link
Contributor

@mattwire mattwire commented Aug 23, 2018

Overview

Allow a description to be specified for payment form fields.

Before

It is not possible to add a description for any of the payment fields.

After

A description can be added for any field added by getPaymentFormFieldsMetadata()
payment_descriptions

Technical Details

This adds an array of descriptions that is assigned to the template and can be used to display descriptions for each form element. If the description is not specified there is no change.

Comments

Example usage in org.civicrm.smartdebit here: mattwire/org.civicrm.smartdebit@931fbaf

@civibot
Copy link

civibot bot commented Aug 23, 2018

(Standard links)

@davejenx
Copy link
Contributor

davejenx commented Aug 23, 2018

Applied as patch to 5.4.0, working well here with current org.civicrm.smartdebit master, thanks!

Edit: Have tested successfully both on contribution page & with Webform CiviCRM.

@mattwire
Copy link
Contributor Author

@KarinG Is this something that could be of interest to you at all? That you might have time to review :-) Works on webform as well.

@@ -41,7 +41,8 @@
</div>
<div class="content">
{$form.$paymentField.html}
{if $paymentField == 'cvv2'}{* @todo move to form assignment*}
{if $paymentFieldDescriptions.$name}<div class="description">{$paymentFieldDescriptions.$name}</div>
Copy link
Contributor

@pradpnayak pradpnayak Aug 24, 2018

Choose a reason for hiding this comment

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

@mattwire Can you move the div section next line for better styling?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pradpnayak Yes, I've changed it - is that ok?

@mattwire mattwire force-pushed the billingblock_descriptions branch from 8b27615 to f44a7b1 Compare August 24, 2018 15:50
'return' => ['title'],
];
}

// Get all custom (is_reserved=0) option groups
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this change required?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, extra commit sneaked in

Copy link
Contributor

Choose a reason for hiding this comment

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

I think they are back again ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gone again..

@@ -129,8 +129,10 @@ protected static function addCommonFields(&$form, $paymentFields) {
// This will cause the fields to be marked as required - but it is up to the payment processor to
// validate it.
$requiredPaymentFields[$field['name']] = $field['is_required'];
$paymentFieldDescriptions[$field['name']] = $field['description'];
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we change this to

if (!empty($field['description'])) {
  $paymentFieldDescriptions[$field['name']] = $field['description'];
}

I feel there will be notice error when description is not present in $field.

@mattwire mattwire force-pushed the billingblock_descriptions branch 2 times, most recently from 9274a54 to 23ee3db Compare August 25, 2018 14:05
@mattwire mattwire changed the base branch from master to 5.5 August 25, 2018 22:12
@mattwire mattwire changed the base branch from 5.5 to master August 25, 2018 22:13
@mattwire mattwire force-pushed the billingblock_descriptions branch from 23ee3db to 6f91492 Compare August 25, 2018 22:13
@eileenmcnaughton
Copy link
Contributor

@mattwire this makes sense but I think we should assign the paymentfield metadata array to the template rather than an array specific to descriptions. Otherwise next time we want some extra info we have to define a new assign

@pradpnayak
Copy link
Contributor

@mattwire would you like to update the code as per Eileen's comment?

@mattwire mattwire force-pushed the billingblock_descriptions branch from 6f91492 to 4533376 Compare September 3, 2018 21:24
@mattwire
Copy link
Contributor Author

mattwire commented Sep 3, 2018

@pradpnayak @eileenmcnaughton This is now updated per comments

@pradpnayak
Copy link
Contributor

retest this please

@pradpnayak
Copy link
Contributor

Hi Matt,

I tested on current state for SEPA payment processor and it worked. Description fields are shown below payment fields.

Before:
before

After:
after

Thank you so much for the improvement!

@eileenmcnaughton
Copy link
Contributor

Code looks good. Thanks @pradpnayak for testing. Merge on pass

@eileenmcnaughton
Copy link
Contributor

test this please

@eileenmcnaughton
Copy link
Contributor

test fails unrelated

@eileenmcnaughton eileenmcnaughton merged commit 53258b7 into civicrm:master Sep 13, 2018
@mattwire mattwire deleted the billingblock_descriptions branch September 25, 2018 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants