Commit 19987f21 authored by mattwire's avatar mattwire

Resolve #26 - Make sure we clear processor specific metadata from payment form...

Resolve #26 - Make sure we clear processor specific metadata from payment form when changing processor
parent 963fbe9a
......@@ -296,6 +296,7 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
'title' => 'Stripe Token',
'attributes' => array(
'id' => 'stripe-token',
'class' => 'payproc-metadata',
),
'cc_field' => TRUE,
'is_required' => TRUE,
......@@ -306,6 +307,7 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
'title' => 'Stripe ID',
'attributes' => array(
'id' => 'stripe-id',
'class' => 'payproc-metadata',
),
'cc_field' => TRUE,
'is_required' => TRUE,
......@@ -316,6 +318,7 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
'title' => 'Stripe Public Key',
'attributes' => array(
'id' => 'stripe-pub-key',
'class' => 'payproc-metadata',
),
'cc_field' => TRUE,
'is_required' => TRUE,
......
......@@ -57,6 +57,16 @@ CRM.$(function($) {
// We will re-add it if the transaction goes through.
onclickAction = $submit.attr('onclick');
$submit.removeAttr('onclick');
// Quickform doesn't add hidden elements via standard method. On a form where payment processor may
// be loaded via initial form load AND ajax (eg. backend live contribution page with payproc dropdown)
// the processor metadata elements will appear twice (once on initial load, once via AJAX). The ones loaded
// via initial load will not be removed when AJAX loaded ones are added and the wrong stripe-pub-key etc will
// be submitted. This removes all elements with the class "payproc-metadata" from the form each time the
// dropdown is changed.
$('select#payment_processor_id').on('change', function() {
$('input.payproc-metadata').remove();
});
});
// Re-prep form when we've loaded a new payproc
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment