Skip to content
Snippets Groups Projects
Commit 78fce9ab authored by Joshua Walker's avatar Joshua Walker Committed by GitHub
Browse files

Merge pull request #174 from h-c-c/4.7-dev-155again

possible fix for #155 - makes transactions
parents 5e0af5f3 fdaf7b7c
No related branches found
No related tags found
No related merge requests found
......@@ -231,8 +231,6 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
return $return;
}
/**
* Implementation of hook_civicrm_validateForm().
*
......@@ -244,26 +242,7 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
* @param $form - reference to the form object
* @param $errors - Reference to the errors array.
*
* @todo This won't run, and needs to be moved elsewhere.
*/
/*public function stripe_civicrm_validateForm($formName, &$fields, &$files, &$form, &$errors) {
if (empty($form->_paymentProcessor['payment_processor_type'])) {
return;
}
// If Stripe is active here.
if (isset($form->_elementIndex['stripe_token'])) {
if ($form->elementExists('credit_card_number')) {
$cc_field = $form->getElement('credit_card_number');
$form->removeElement('credit_card_number', true);
$form->addElement($cc_field);
}
if ($form->elementExists('cvv2')) {
$cvv2_field = $form->getElement('cvv2');
$form->removeElement('cvv2', true);
$form->addElement($cvv2_field);
}
}
}*/
/**
* Implementation of hook_civicrm_buildForm().
......@@ -271,7 +250,7 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
* @param $form - reference to the form object
*/
public function buildForm(&$form) {
$stripe_key = stripe_get_key($form);
$stripe_key = self::stripe_get_key($form);
// If this is not a form Stripe is involved in, do nothing.
if (empty($stripe_key)) {
return;
......@@ -288,7 +267,7 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
$form->setAttribute('class', $form->getAttribute('class') . ' stripe-payment-form');
$form->addElement('hidden', 'stripe_token', $stripe_token, array('id' => 'stripe-token'));
}
stripe_add_stripe_js($stripe_key, $form);
self::stripe_add_stripe_js($stripe_key, $form);
// Add email field as it would usually be found on donation forms.
if (!isset($form->_elementIndex['email']) && !empty($form->userEmail)) {
......@@ -329,7 +308,7 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
return $pp['password'];
}
// We have a match.
return stripe_get_key_for_name($pp['name'], $is_test);
return self::stripe_get_key_for_name($pp['name'], $is_test);
}
}
}
......@@ -362,6 +341,8 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
CRM_Core_Resources::singleton()->addScriptFile('com.drastikbydesign.stripe', 'js/civicrm_stripe.js', 0);
}
/**
* Submit a payment using Stripe's PHP API:
* https://stripe.com/docs/api?lang=php
......
......@@ -151,3 +151,35 @@ function stripe_civicrm_managed(&$entities) {
return _stripe_civix_civicrm_managed($entities);
}
/**
* Implementation of hook_civicrm_validateForm().
*
* Prevent server validation of cc fields
*
* @param $formName - the name of the form
* @param $fields - Array of name value pairs for all 'POST'ed form values
* @param $files - Array of file properties as sent by PHP POST protocol
* @param $form - reference to the form object
* @param $errors - Reference to the errors array.
*
*/
function stripe_civicrm_validateForm($formName, &$fields, &$files, &$form, &$errors) {
if (empty($form->_paymentProcessor['payment_processor_type'])) {
return;
}
// If Stripe is active here.
if (isset($form->_elementIndex['stripe_token'])) {
if ($form->elementExists('credit_card_number')) {
$cc_field = $form->getElement('credit_card_number');
$form->removeElement('credit_card_number', true);
$form->addElement($cc_field);
}
if ($form->elementExists('cvv2')) {
$cvv2_field = $form->getElement('cvv2');
$form->removeElement('cvv2', true);
$form->addElement($cvv2_field);
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment