An open API service indexing awesome lists of open source software.

https://github.com/webdna/commerce-opayo

Opayo payment gateway for Craft Commerce
https://github.com/webdna/commerce-opayo

Last synced: 4 months ago
JSON representation

Opayo payment gateway for Craft Commerce

Awesome Lists containing this project

README

          

Opayo for Craft Commerce icon

Opayo for Craft Commerce

This plugin provides a [Opyao](https://www.opayo.co.uk/) integration for [Craft Commerce](https://craftcms.com/commerce).

## Requirements

This plugin requires Craft 3.6 and Craft Commerce 3.3 or later.

## Installation

You can install this plugin from the Plugin Store or with Composer.

#### From the Plugin Store

Go to the Plugin Store in your project’s Control Panel and search for Opayo for Craft Commerce”. Then click on the “Install” button in its modal window.

#### With Composer

Open your terminal and run the following commands:

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

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

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

## Setup

To add an Opayo payment gateway, go to Commerce → Settings → Gateways, create a new gateway.

> **Tip:** The Vendor, Integration Key and Integration Password gateway settings can be set to environment variables. See [Environmental Configuration](https://docs.craftcms.com/v3/config/environments.html) in the Craft docs to learn more about that.

### Using the legacy basket format

Example implementation

```twig

{{ csrfInput() }}
{% set gateway = craft.commerce.gateways.getGatewayByHandle('opayo') %}









Submit

```

```js
function paymentFormSubmit(e) {
e.preventDefault();
// disable submit button
e.target.querySelector('button[type="submit"]').disabled = true;

sagepayOwnForm({
merchantSessionKey: e.target.querySelector('input[name="sessionKey"]').value
}).tokeniseCardDetails({
cardDetails: {
cardholderName: e.target.querySelector('[id="name"]').value,
cardNumber: e.target.querySelector('[id="cardnumber"]').value,
expiryDate: e.target.querySelector('[id="expiry"]').value,
securityCode: e.target.querySelector('[id="cvv"]').value,
},
onTokenised: function(result) {
if (result.success) {
e.target.querySelector('[name="nonce"]').value = result.cardIdentifier;
e.target.removeEventListener('submit', paymentFormSubmit);
e.target.submit();
} else {
alert(result.errors.join(', '));
}
}
});
}
document.getElementById('opayo-form').addEventListener('submit', paymentFormSubmit);
```