Fix switching between payment processors for anonymous sessions
Hi @mattwire,
I've found that calling the PaymentProcessor
API from JavaScript was only working for opened sessions with enough credentials. So changing multiple processors was generating issues.
I've seen the issue today in a site updated to 6.3.2.
With this patch I try to remove the Ajax call by defining a new variable CRM.vars.stripe_keys
that contains ids of payment processors as keys and their corresponding public keys as values.
Can you take a look at it and let me know if you'd prefer a different approach?
Thanks!
Merge request reports
Activity
added 1 commit
- af48991c - Refactor and simplify by publishing all active Stripe public keys
mentioned in issue #172 (closed)
Thanks @capo I've seen this a couple of times and could not work out why! We should also restrict this by current domain so we work with multisite and do not expose public keys for other domains.
added 1 commit
- 8e716c23 - Limit CRM.vars.stripe_keys to payment processors of the domain
Thanks to you @mattwire. Let me know if it works with my last commit.
368 * 369 * @return array 370 */ 371 protected function getStripePublicKeys() { 372 $paymentProcessors = civicrm_api3('PaymentProcessor', 'get', [ 373 'payment_processor_type_id' => 'Stripe', 374 'is_active' => TRUE, 375 'domain_id' => CRM_Core_Config::domainID(), 376 ]); 377 378 if (!$paymentProcessors['count']) { return []; } 379 380 $publicKeys = []; 381 382 foreach ($paymentProcessors['values'] as $paymentProcessor) { 383 $publicKeys[$paymentProcessor['id']] = $paymentProcessor['user_name']; @capo Please can you use
CRM_Core_Payment_Stripe::getPublicKey($paymentProcessor)
herechanged this line in version 4 of the diff
@capo I think this is nearly ok - I just made one comment above
added 1 commit
- 19bc7ba2 - Use getPublicKey instead of reading user_name from the payment processor
@mattwire How does it look now?
mentioned in merge request !102 (merged)
@capo I did some testing and found that this did not completely fix the problem and exposed some (existing) bugs in the code - please can you test and review !102 (merged)?