Integration between Click & Pledge's Payment System with Drupal Commerce
Download the Click & Pledge integration module from GitHub: https://github.com/ClickandPledge/commerce_cnp
Drupal Commerce is used to build eCommerce websites and applications of all sizes. Drupal Commerce is a fully open source: there is no "premium" version, meaning that you can take full advantage of the power of Drupal Commerce right now.
- Developers who like to handle Drupal installation from scratch or who want to extend an existing Drupal installation with Drupal Commerce features can download Drupal Commerce from its project page on drupal.org and install/configure the modules directly.
- Create product types with custom attributes
- Dynamic product displays
- Order management, line item
- Payment method API, allowing many different payment gateways
- Tax calculation / VAT support
- Discount pricing rules
- Deep integration with systems like D8's Fields, Views, Rules and Entity API.
Some Useful Links:
http://www.drupalcommerce.org/user-guide
http://www.drupalcommerce.org/user-guide/installing-scratch
Requirements
Drupal Commerce currently depends on Drupal 8 (>= 8.6.2) with the latest releases of a few modules: Ctools 1.2, Views 3.5, Entity API 1.0-rc3, Rules 2.2, and Address field 1.0-beta3.
Note: Here onwards we are assuming that you are running on Drupal 8(>= 8.6.2)
Installing Drupal Commerce
There are two ways to install Drupal Commerce.
- Install From Scratch: You can do it from scratch by installing Drupal 8 and then enabling the Commerce modules and their dependencies. This process requires additional configuration of products and product displays before you can start selling through your site.
- Your first step will be to perform a standard installation of Drupal 8. (For more details how to install Drupal please refer http://drupal.org/documentation/install
- Install Commerce modules:
- Address Field (http://drupal.org/project/addressfield)
- Chaos tool suite(http://drupal.org/project/ctools)
- Entity API (http://drupal.org/project/entity)
- Rules 2 (http://drupal.org/project/rules)
- Views 3 (http://drupal.org/project/views)
- You should download the latest version of Drupal Commerce (http://drupal.org/project/commerce)
- Commerce Addressbook (http://drupal.org/project/commerce_addressbook)
- Commerce add to cart confirmation (http://drupal.org/project/commerce_add_to_cart_confirmation)
- Shipping Modules:
- Commerce Shipping: http://drupal.org/project/commerce_shipping
- Flat rate Shipping - http://drupal.org/project/commerce_flat_rate
Admin Login:

Enter the correct Drupal Modules username and password to log in.
Once login, click Commerce to manage your C&P payments.

How to add Payment Processor
1. Download the ClickandPledge module from https://github.com/ClickandPledge/commerce_cnp2. Click on Modules Menu and then click on ‘Install new module’ link (Extend->List)
3. Install ‘ClickandPledge’ from the Drupal site by searching in modules or by uploading the module from your local computer.

4. Once installed, enter the email address associated to Click & Pledge and click ‘Verify’.

5. A verification code will be sent to your email address. Copy and paste the same and click ‘Log In’.


How to configure Click & Pledge Payment Processor
To configure Click & Pledge Payment Processor, go to Commerce and select ‘CnP Payment Settings’.

General Settings
Status: Enable the status to see the C&P payment gateway in the site.
Title & Description: Give the title for the Click & Pledge Payment Gateway and add
C&P Account ID: Based on the Account ID selected, the settings which are set in the Connect platform will
Connect Campaign URL Alias: Transactions will post to this selected Campaign. It can be added to the form so that the transacted amount will be added to the selected campaign. By entering the Connect Campaign URL Alias in the Form, the receipt assigned to the Connect Campaign will replace the generic receipt. The receipt which is assigned to this campaign will be sent to the recipient. For additional information on Receipts, click this link.
To know the Connect Campaign URL Alias, login to Connect platform (https://login.connect.clickandpledge.com) > Launcher > Fundraising > Campaigns > Select the desired campaign > Campaign Details > Campaign Settings > Basic Information > Campaign Alias.
Mode: Mode may be set either to Test or Production. Test mode is used to test the transactions. No amount will be deducted from the payment. Production mode is nothing but live payment form wherein the given amount will be deducted from the selected payment type.
Payment Methods: The Connect Payment settings will be replicated here. Due to limitations with the Drupal Commerce payment API, only credit card payment is currently supported.
Receipt Settings
Enable Send Receipt to Patron to send the receipt to the patron. Receipt Header and Terms & Conditions can be edited upon need.
Recurring Settings
Recurring Label: Enter the name of the recurring settings which will appear in the external page.
Payment Options Label: The name entered here will be displayed
NOTE: Recurring options will be available only when the check-box for recurring is enabled.
Default Payment Option: If both
Recurring Type Label: The name entered here will be displayed
Default Recurring type: Select the default recurring type. This option will be available only when both installments and subscription is enabled.
Periodicity Label: The name entered here will be displayed
Indefinite only: If this option is selected then 998 times for installments and 999 times for subscription, the recurring option will be continued.
Open Field only: If this option is selected, “Default number of payments” and “Maximum number of installments” can be given. The entries given here can be changed in the external page.
Indefinite + Open Field Only: If this option is selected, the default value will be 999 which can be changed accordingly in the external page.
Fixed Number – No Change allowed: If this option is selected, the number entered in this field remains constant.
After making all the changes click on the “Save Configuration” button.
How to Change User
We can change the user with Connect platform through OAuth Connection. To do so, you need to have Connect Account. Click on ‘Change User’.
Enter the email address associated with your Click & Pledge account and click on Verify.
Please check your email inbox for the email. Copy and Paste the code and click Log in.
Pre-Authorization
By default, Drupal Commerce allows zero payments (free orders) without asking for credit card information. If total payment is $0 then it will just ask billing information and confirms the order.
If we want to allow credit card information along with billing information, then we need to do the following code level changes in Drupal commerce module.
We need to work with the following two files with minimal code changes
File 1: PaymentProcess.php
Location: project-root-folder\modules\commerce\modules\payment\src\Plugin\Commerce\CheckoutPane\PaymentProcess.php
In this file, please find the function isVisible(). Replace isVisible() function with below modified function
File 2: PaymentInformation.php
Location: project-root-folder\modules\commerce\modules\payment\src\Plugin\Commerce\CheckoutPane\PaymentInformation.php
1. Please find the buildPaneForm() function. In this function, comment the below code shown:
/*if ($this->order->getTotalPrice()->isZero()) {
// Free orders don't need payment, collect just the billing information.
$pane_form['#title'] = $this->t('Billing information');
$pane_form = $this->buildBillingProfileForm($pane_form, $form_state);
return $pane_form;
}*/
2. Please find function validatePaneForm(). In this function, comment the below code shown:
/*if ($this->order->getTotalPrice()->isZero()) {
return;
}*/
3. Please find another function submitPaneForm(). In this function, comment the below code shown:
/*if ($this->order->getTotalPrice()->isZero()) {
$this->order->setBillingProfile($pane_form['billing_information']['#profile']);
return;
}*/
The above changes will allow you to accept $0 payments with credit card information also.