Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
engram-design committed Aug 26, 2018
0 parents commit 63ffac8
Show file tree
Hide file tree
Showing 11 changed files with 302 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/ISSUE_TEMPLATE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
### Description



### Steps to reproduce

1.
2.

### Additional info

- Plugin version:
- Craft version:
31 changes: 31 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# CRAFT ENVIRONMENT
.env.php
.env.sh
.env

# COMPOSER
/vendor

# BUILD FILES
/bower_components/*
/node_modules/*
/build/*
/yarn-error.log

# MISC FILES
.cache
.DS_Store
.idea
.project
.settings
.map
*.esproj
*.sublime-workspace
*.sublime-project
*.tmproj
*.tmproject
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Changelog
=========

### 1.0.0

- Initial release.
9 changes: 9 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The MIT License (MIT)

Copyright (c) 2018 Verbb

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
PayPal Payflow payment gateway plugin for Craft Commerce 2
=======================

This plugin provides [PayPal Payflow](https://developer.paypal.com/docs/classic/products/payflow-gateway/) integrations for [Craft Commerce](https://craftcommerce.com/).

It provides PayPal Payflow Pro gateway.

## Requirements

This plugin requires Craft Commerce 2.0.0-alpha.5 or later.

## Installation

To install the plugin, follow these instructions.

1. Open your terminal and go to your Craft project:

cd /path/to/project

2. Then tell Composer to load the plugin:

composer require verbb/commerce-payflow

3. In the Control Panel, go to Settings → Plugins and click the “Install” button for PayPal Payflow.

## Setup

To add the payment gateway, go to Commerce → Settings → Gateways, create a new gateway, and set the gateway type Payflow”.
49 changes: 49 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"name": "verbb/commerce-payflow",
"description": "PayPal Payflow payment gateway plugin for Craft Commerce 2",
"type": "craft-plugin",
"version": "1.0.0",
"keywords": [
"craft",
"cms",
"craftcms",
"craft-plugin",
"paypal",
"payflow",
"omnipay",
"commerce"
],
"support": {
"email": "[email protected]",
"issues": "https://github.com/verbb/commerce-payflow/issues?state=open",
"source": "https://github.com/verbb/commerce-payflow",
"docs": "https://github.com/verbb/commerce-payflow",
"rss": "https://github.com/verbb/commerce-payflow/commits/v2.atom"
},
"license": "MIT",
"authors": [
{
"name": "Verbb",
"homepage": "https://verbb.io"
}
],
"require": {
"craftcms/commerce": "^2.0.0-alpha.6",
"craftcms/commerce-omnipay": "^1.0.0",
"omnipay/payflow": "~2.0"
},
"autoload": {
"psr-4": {
"verbb\\payflow\\": "src/"
}
},
"extra": {
"name": "PayPal Payflow",
"handle": "commerce-payflow",
"schemaVersion": "1.0.0",
"hasCpSettings": true,
"hasCpSection": true,
"changelogUrl": "https://raw.githubusercontent.com/verbb/commerce-payflow/master/CHANGELOG.md",
"class": "verbb\\payflow\\Payflow"
}
}
27 changes: 27 additions & 0 deletions src/Payflow.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
namespace verbb\payflow;

use verbb\payflow\gateways\Payflow as PayflowGateway;

use Craft;
use craft\base\Plugin;
use craft\events\RegisterComponentTypesEvent;

use craft\commerce\services\Gateways;

use yii\base\Event;

class Payflow extends Plugin
{
// Public Methods
// =========================================================================

public function init()
{
parent::init();

Event::on(Gateways::class, Gateways::EVENT_REGISTER_GATEWAY_TYPES, function(RegisterComponentTypesEvent $event) {
$event->types[] = PayflowGateway::class;
});
}
}
57 changes: 57 additions & 0 deletions src/gateways/Payflow.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php
namespace verbb\payflow\gateways;

use Craft;
use craft\commerce\omnipay\base\CreditCardGateway;

use Omnipay\Common\AbstractGateway;
use Omnipay\Omnipay;
use Omnipay\PayFlow\ProGateway;

class Payflow extends CreditCardGateway
{
// Properties
// =========================================================================

public $username;
public $password;
public $partner;
public $vendor;
public $testMode;


// Public Methods
// =========================================================================

public static function displayName(): string
{
return Craft::t('commerce', 'PayPal Payflow');
}

public function getSettingsHtml()
{
return Craft::$app->getView()->renderTemplate('commerce-payflow/gatewaySettings', ['gateway' => $this]);
}


// Protected Methods
// =========================================================================

protected function createGateway(): AbstractGateway
{
$gateway = Omnipay::create('Payflow_Pro');

$gateway->setUsername($this->username);
$gateway->setPassword($this->password);
$gateway->setPartner($this->partner);
$gateway->setVendor($this->vendor);
$gateway->setTestMode($this->testMode);

return $gateway;
}

protected function getGatewayClassName()
{
return '\\' . ProGateway::class;
}
}
12 changes: 12 additions & 0 deletions src/icon-mask.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions src/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions src/templates/gatewaySettings.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{% from "_includes/forms" import textField, lightswitchField %}

{{ textField({
label: 'API Username' | t('commerce'),
instructions: "Your Payflow API username." | t('commerce'),
id: 'username',
class: 'ltr',
name: 'username',
value: gateway.username,
errors: gateway.getErrors('username')
}) }}

{{ textField({
label: "API Password" | t('commerce'),
instructions: "Your Payflow API password." | t('commerce'),
id: 'password',
class: 'ltr',
name: 'password',
value: gateway.password,
errors: gateway.getErrors('password')
}) }}

{{ textField({
label: "Partner" | t('commerce'),
instructions: "The Payflow partner. This may be PayPal, or if an account was provided by an authorized PayPal reseller, who registered a Payflow user, then the ID provided by the reseller is used." | t('commerce'),
id: 'partner',
class: 'ltr',
name: 'partner',
value: gateway.partner,
errors: gateway.getErrors('partner')
}) }}

{{ textField({
label: "Vendor" | t('commerce'),
instructions: "The ID that you specified when you got the Payflow account, the same as the username unless you have created additional users on the account. That is, the merchant login ID for the account." | t('commerce'),
id: 'vendor',
class: 'ltr',
name: 'vendor',
value: gateway.vendor,
errors: gateway.getErrors('vendor')
}) }}

{{ lightswitchField({
label: "Test mode?" | t('commerce'),
name: 'testMode',
on: gateway.testMode,
errors: gateway.getErrors('testMode'),
}) }}

0 comments on commit 63ffac8

Please sign in to comment.