2017 © Pedro Peláez
 

craft-plugin commerce-sagepay

SagePay payment gateway plugin for Craft Commerce 2

image

craftcms/commerce-sagepay

SagePay payment gateway plugin for Craft Commerce 2

  • Tuesday, April 3, 2018
  • by brandonkelly
  • Repository
  • 3 Watchers
  • 0 Stars
  • 75 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 2 Versions
  • 436 % Grown

The README.md

Sage Pay for Craft Commerce icon, (*1)

Sage Pay for Craft Commerce

This plugin provides a Sage Pay integration for Craft Commerce., (*2)

Tip: This plugin uses protocol version 4.00 of the API for SagePay/Opayo., (*3)

Requirements

This plugin requires either:, (*4)

  • Craft 4.0 and Craft Commerce 4.0 or later
  • Craft 5.0 and Craft Commerce 5.0 or later

Installation

You can install this plugin from the Plugin Store or with Composer., (*5)

From the Plugin Store

Go to the Plugin Store in your project’s Control Panel and search for Sage Pay for Craft Commerce”. Then click on the “Install” button in its modal window., (*6)

With Composer

Open your terminal and run the following commands:, (*7)

# go to the project directory
cd /path/to/my-project.test

# tell Composer to load the plugin
composer require craftcms/commerce-sagepay

# tell Craft to install the plugin
./craft install/plugin commerce-sagepay

Setup

To add a Sage Pay payment gateway, go to Commerce → Settings → Gateways, create a new gateway, and set the gateway type to “Sage Pay Server”., (*8)

Tip: The gateway settings can be set to environment variables. See Environmental Configuration in the Craft docs to learn more about that., (*9)

Using the legacy basket format

Sage Pay has two formats for submit basket data — Basket and BasketXML. The Basket is a legacy format, but is the only way to integrate with Sage 50 Accounts., (*10)

To use the legacy format, simply turn on the appropriate setting in the gateway settings. To complete your integration with Sage 50 Accounts you can use the following event:, (*11)

use \craft\commerce\omnipay\base\Gateway as BaseGateway;

Event::on(BaseGateway::class, BaseGatewa::EVENT_AFTER_CREATE_ITEM_BAG, function(ItemBagEvent $itemBagEvent) {

    $orderLineItems = $itemBagEvent->order->getLineItems();

    /**
     * @var $item Item
    */
    foreach ($itemBagEvent->items as $key => $item) {

        if (!isset($orderLineItems[$key])) {
            return;
        }

        $orderLineItem  = $orderLineItems[$key];

        // Make sure that the description and price are the same as we are relying upon the order
        // of the Order Items and The OmniPay Item Bag to be the same
        if ($orderLineItem->getDescription() != $item->getDescription()) {
            return;
        }

        if ($orderLineItem->price != $item->getPrice()) {
            return;
        }

        $sku = $orderLineItem->getSku();

        // Place the SKU within [] as the Product Record for the Sage 50 Accounts Integration
        $description = '[' . $sku . ']' . $item->getDescription();
        $item->setDescription($description);
    }
});

The Versions

03/04 2018

dev-master

9999999-dev

SagePay payment gateway plugin for Craft Commerce 2

  Sources   Download

proprietary

The Requires

 

omnipay yii2 sagepay commerce craftcms

03/04 2018

1.0.0

1.0.0.0

SagePay payment gateway plugin for Craft Commerce 2

  Sources   Download

proprietary

The Requires

 

omnipay yii2 sagepay commerce craftcms