Skip to content
This repository has been archived by the owner on Feb 10, 2023. It is now read-only.

Commit

Permalink
Updated to be compatible with new API URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
jmauzyk committed Feb 12, 2020
1 parent abf6fba commit 3472944
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 24 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Release Notes for CardConnect for Craft Commerce

## 1.1.0 - 2020-02-12
* Updated to be compatible with [new API URLs](https://developer.cardconnect.com/changelog/cardpointe-gateway-api#date-updated-9-16-2019)

## 1.0.1 - 2019-10-30
* Updated Omnipay: CardConnect to 1.0.1
* Fixed missing address
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "jmauzyk/commerce-cardconnect",
"description": "CardConnect integration for Craft Commerce 2",
"type": "craft-plugin",
"version": "1.0.1",
"version": "1.1.0",
"keywords": [
"craft",
"cms",
Expand All @@ -28,7 +28,7 @@
"craftcms/cms": "^3.1.0",
"craftcms/commerce": "^2.0.0",
"craftcms/commerce-omnipay": "^2.0.0",
"jmauzyk/omnipay-cardconnect": "^1.0.1"
"jmauzyk/omnipay-cardconnect": "^1.1.0"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Plugin extends \craft\base\Plugin
/**
* @var string
*/
public $schemaVersion = '1.0.0';
public $schemaVersion = '1.1.0';

// Public Methods
// =========================================================================
Expand Down
6 changes: 0 additions & 6 deletions src/gateways/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ class Gateway extends CreditCardGateway
*/
public $apiHost;

/**
* @var string
*/
public $apiPort;

/**
* @var string
*/
Expand Down Expand Up @@ -88,7 +83,6 @@ protected function createGateway(): AbstractGateway

$gateway->setMerchantId($this->merchantId);
$gateway->setApiHost($this->apiHost);
$gateway->setApiPort($this->apiPort);
$gateway->setApiUsername($this->apiUsername);
$gateway->setApiPassword($this->apiPassword);
$gateway->setTestMode($this->testMode);
Expand Down
53 changes: 53 additions & 0 deletions src/migrations/m200211_195001_remove_api_port.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

namespace jmauzyk\commerce\cardconnect\migrations;

use Craft;
use craft\db\Migration;
use craft\db\Query;
use craft\commerce\Plugin;
use craft\commerce\records\Gateway;

/**
* m200211_195001_remove_api_port migration.
*/
class m200211_195001_remove_api_port extends Migration
{
/**
* @inheritdoc
*/
public function safeUp()
{
$schemaVersion = Craft::$app->projectConfig->get(
'plugins.commerce-cardconnect.schemaVersion',
true
);

if (version_compare($schemaVersion, '1.1', '<')) {
$rows = (new Query())
->from('{{%commerce_gateways}}')
->where(['type' => 'jmauzyk\commerce\cardconnect\gateways\Gateway'])
->all();

$service = Plugin::getInstance()->getGateways();
foreach ($rows as $row) {
$settings = json_decode($row['settings']);
if (isset($settings->apiPort)) {
unset($settings->apiPort);
$this->update('{{%commerce_gateways}}', ['settings' => json_encode($settings)], ['id' => $row['id']]);
$gateway = $service->getGatewayById($row['id']);
$service->saveGateway($gateway);
}
}
}
}

/**
* @inheritdoc
*/
public function safeDown()
{
echo "m200211_195001_remove_api_port cannot be reverted.\n";
return false;
}
}
23 changes: 8 additions & 15 deletions src/templates/gatewaySettings.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% from "_includes/forms" import textField, lightswitchField %}
{% from '_includes/forms' import textField, lightswitchField %}

{{ textField({
label: "Merchant ID"|t('commerce'),
label: 'Merchant ID'|t('commerce'),
id: 'merchantId',
class: 'ltr',
name: 'merchantId',
Expand All @@ -10,25 +10,18 @@
}) }}

{{ textField({
label: "API Host"|t('commerce'),
label: 'API Host'|t('commerce'),
instructions: 'Enter your API host without protocol.',
id: 'apiHost',
class: 'ltr',
name: 'apiHost',
placeholder: '<site>.cardconnect.com',
value: gateway.apiHost,
errors: gateway.getErrors('apiHost')
}) }}

{{ textField({
label: "API Port"|t('commerce'),
id: 'apiPort',
class: 'ltr',
name: 'apiPort',
value: gateway.apiPort,
errors: gateway.getErrors('apiPort')
}) }}

{{ textField({
label: "API Username"|t('commerce'),
label: 'API Username'|t('commerce'),
id: 'apiUsername',
class: 'ltr',
name: 'apiUsername',
Expand All @@ -37,7 +30,7 @@
}) }}

{{ textField({
label: "API Password"|t('commerce'),
label: 'API Password'|t('commerce'),
id: 'apiPassword',
class: 'ltr',
name: 'apiPassword',
Expand All @@ -46,7 +39,7 @@
}) }}

{{ lightswitchField({
label: "Test Mode"|t('commerce'),
label: 'Test Mode'|t('commerce'),
name: 'testMode',
on: gateway.testMode,
errors: gateway.getErrors('testMode'),
Expand Down

0 comments on commit 3472944

Please sign in to comment.