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

Cannot access protected property #247

Open
adevapp opened this issue Jan 28, 2018 · 7 comments
Open

Cannot access protected property #247

adevapp opened this issue Jan 28, 2018 · 7 comments

Comments

@adevapp
Copy link

adevapp commented Jan 28, 2018

( ! ) Fatal error: Uncaught Error: Cannot access protected property CRM_Contribute_Form_AdditionalPayment::$_paymentProcessors in ...../civicrm/ext/com.drastikbydesign.stripe/CRM/Core/Form/Stripe.php on line 13
( ! ) Error: Cannot access protected property CRM_Contribute_Form_AdditionalPayment::$_paymentProcessors in .....//civicrm/ext/com.drastikbydesign.stripe/CRM/Core/Form/Stripe.php on line 13

This occurs when attempting to record a CC payment against an existing offline contribution.

CiviCRM appear to have changed access to the variables used, so obtaining the variables from the class doesn't work.

Potential work around is using a function like:

function dashboard_civicrm_accessProtected($obj, $prop) {
$reflection = new ReflectionClass($obj);
$property = $reflection->getProperty($prop);
$property->setAccessible(true);
return $property->getValue($obj);
}

@chrisfromredfin
Copy link

Verified.

@h-c-c
Copy link
Collaborator

h-c-c commented Mar 11, 2018

Hey @adam-devapp, could you possibly walk me through how to trigger this error? Personally, I never used this workflow, so I just have no idea.

Thanks for the suggestion! I hope that works. If so, using the ReflectionClass could be a better bet in the long run for maintaining this code instead of extending a subclass every time this happens.

Apparently, to access this protected _paymentProcessors array, we'd have to extend CRM/Contribute/Form/AbstractEditPayment.php.

@chrisfromredfin
Copy link

The way that I was seeing it (and we are no longer using this workflow), was to go and create a new contribution for, say, $500 and mark it "Pending (from pay later)" by marking it as pending status with a pay by check method or something (in my case it was a custom payment method called "pledge to be paid").

Then go and try to, through the back end, record a credit card payment, and it whitescreens there.

@h-c-c
Copy link
Collaborator

h-c-c commented Mar 12, 2018

Thanks @chrisfromredfin, I see now this is a new feature in 4.7. Are you guys using any unmerged patches by chance? With a fresh 4.7.31 install I'm getting "Stripe.js token not passed".

@mattwire
Copy link
Contributor

@adam-devapp @chrisfromredfin @h-c-c You may wish to try my branch which completely does away with the CRM/Core/Form.php hack that this issue is caused by as well as resolving all known "Stripe.js token not passed" issues: https://github.com/mattwire/com.drastikbydesign.stripe/tree/4.7-mjwconsulting-dev-squashed

@h-c-c
Copy link
Collaborator

h-c-c commented Mar 20, 2018

Hey @mattwire. Thanks for pointing us at this. I had a chance to take a quick glance over it, and was wondering if you could talk about your approach. I saw that you're overriding all CC fields, but wasn't sure how that helps.

I guess the question I want to ask is this. Did you find something in common relating to all the known causes of "Stripe.js token not passed."?

@mattwire
Copy link
Contributor

@h-c-c Hey, as you've probably seen it's a fairly substantial rewrite of parts of the extension. The "Stripe.js token not passed" is caused by a whole range of different things (eg. failing to include stripe.js, failing to submit token values if payment form is loaded via ajax etc).
I followed the guidance from stripe and include the stripe js code a lot more liberally (even when it may not be required on the page). In addition, I switched to the newer "Civi way" of implementing payment processor fields as modern browsers (eg. chrome/firefox) don't always include fields added by js in a POST request, but they do when added in the original form.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants