Skip to content
Snippets Groups Projects

Fix switching between payment processors for anonymous sessions

Closed capo requested to merge capo/stripe:fix_multiple_processors_switch into master
1 unresolved thread

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

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
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 I think this is nearly ok - I just made one comment above

  • capo added 1 commit

    added 1 commit

    • 19bc7ba2 - Use getPublicKey instead of reading user_name from the payment processor

    Compare with previous version

  • Author Contributor

    @mattwire How does it look now?

  • mattwire mentioned in merge request !102 (merged)

    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)?

  • closed

  • Please register or sign in to reply
    Loading