Paypal express checkout integration with drupal 9

Created on 26 April 2023, over 1 year ago
Updated 16 June 2023, over 1 year ago

1.0 Problem/Motivation

Can't be used paypal express checkout with drupal and webform_civicrm.

2.0 Detailed steps to reproduce (embed screenshots)

- Create a payment express payment processor.
- Set the payment processor paypal express in webform_civicrm

Screenshots with config

3.0 Proposed resolution

Create a condition if the payment is incoming from paypal express and modify how is handeling the redirect url.

A example of the code:

diff --git a/src/WebformCivicrmConfirmForm.php b/src/WebformCivicrmConfirmForm.php
index b642072..b463628 100644
--- a/src/WebformCivicrmConfirmForm.php
+++ b/src/WebformCivicrmConfirmForm.php
@@ -48,6 +48,14 @@ class WebformCivicrmConfirmForm  implements WebformCivicrmConfirmFormInterface {
         $paymentProcessor->setCancelUrl($paramsDoPayment['cancelURL']);
       }
       try {
+        if ($processor_type["class_name"] == "Payment_PayPalImpl") {
+          $result = $paymentProcessor->doPreApproval($paramsDoPayment);
+          if ($result["pre_approval_parameters"]) {
+            $paramsDoPayment["token"] = $result["pre_approval_parameters"]["token"];
+            \CRM_Utils_System::redirect($result['redirect_url']); // Redirect to a new page with the summary of the payment.
+          }
+
+        }
         $paymentProcessor->doPayment($paramsDoPayment);
 
       }

Make a new page with summary to confirm the paypal checkout, like in civicrm workflow.

Screenshots Images - CiviCRM contribution page workflow

Ref:
- Drupal 7 issue https://www.drupal.org/project/webform_civicrm/issues/2938155
- Drupal 7 Pull https://github.com/colemanw/webform_civicrm/pull/104/commits/691bcdadb8a...

Feature request
Status

Active

Version

6.2

Component

CiviCRM Data Handling

Created by

🇪🇸Spain rubofvil

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024