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

Commit

Permalink
Finish 1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jmauzyk committed Oct 21, 2020
1 parent d16a546 commit 246b61c
Show file tree
Hide file tree
Showing 21 changed files with 1,611 additions and 72 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Release Notes for CardConnect for Craft Commerce

## 1.4.0 - 2020-10-21
> {tip} It's now possible to tokenize using the CardSecure API via javascript. Tokenization method is selected in the gateway settings. For information on customizing form appearance and custom payment forms, see [the documentation](https://github.com/jmauzyk/commerce-cardconnect/blob/master/README.md).
* Added support for saving payment sources
* Added ability to tokenize using CardSecure API via javascript
* Updated Omnipay: CardConnect to 1.3.0
* Added `jmauzyk\commerce\cardconnect\gateways\Gateway::getIframeNumberInput()`
* Deprecated `jmauzyk\commerce\cardconnect\gateways\Gateway::getTokenizedNumberInput()`

## 1.3.1 - 2020-08-20
* Updated tokenized number input to make UI in Craft CP
* Fixed order ID not displaying in CardPointe
Expand Down
48 changes: 43 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ The basic Commerce payment form can be output using the following line of code.
{{ cart.gateway.getPaymentFormHtml({})|raw }}
```

As of v1.3.0, payment forms generated using `getPaymentFormHtml()` will use tokenized card numbers by default via CardConnect's [Hosted iFrame Tokenizer](https://developer.cardconnect.com/hosted-iframe-tokenizer). To revert to using clear text card numbers, add `useTokens: false` to the params array passed to `getPaymentFormHtml()`. However, per CardConnect's documentation it is __strongly recommended__ that you tokenize the clear text card data before passing it into an authorization
request.
As of v1.3.0, payment forms generated using `getPaymentFormHtml()` will use tokenized card numbers by default via CardConnect's [Hosted iFrame Tokenizer](https://developer.cardconnect.com/hosted-iframe-tokenizer). To change the tokenization method or revert to using clear text card numbers, select the appropriate _Tokenization_ configuration under the gateway's settings. Per CardConnect's documentation it is __strongly recommended__ that you tokenize the clear text card data before passing it into a request.
### Custom Payment Form
Expand All @@ -71,10 +70,49 @@ If additional customization is needed, custom payment forms can be used so long
* Combined `expiry` (MM/YYYY)
* `cvv`
To use tokenized card numbers with custom payment forms, use the following line of code to output the hosted iframe tokenizer with an accompanying hidden `number` input. Be sure to include your own JS event handler like the _Primary Payment Page Event Listener_ shown in the [Hosted iFrame Tokenizer documentation](https://developer.cardconnect.com/hosted-iframe-tokenizer#implementing-the-hosted-iFrame).
To use iframe tokenization with custom payment forms, use the following line of code to output the hosted iframe tokenizer with an accompanying hidden `number` input. Be sure to include your own JS event handler like the _Primary Payment Page Event Listener_ shown in the [Hosted iFrame Tokenizer documentation](https://developer.cardconnect.com/hosted-iframe-tokenizer#implementing-the-hosted-iFrame).
```Twig
{{ cart.gateway.getTokenizedNumberInput()|raw }}
{{ cart.gateway.getIframeNumberInput()|raw }}
```
To use CardSecure API tokenization with custom payment forms, use the code below as a basis. Element `id` and `name` attributes must be as shown in order to work with the tokenizer javascript.
```Twig
<!-- Card Number -->
<input type="tel" id="cc-cardNumber" name="cardNumber" value="">
<input type="hidden" id="cc-number" name="number" value="">
<!-- Expiry -->
<select id="cc-month" name="month">
<!-- options... -->
</select>
<select id="cc-year" name="year">
<!-- options... -->
</select>
<!-- OR -->
<input type="text" id="cc-expiry" name="expiry" value="">
<!-- CVV -->
<input type="tel" id="cc-cvv" name="cvv" value="">
<!-- Tokenizer JS -->
{% do view.registerAssetBundle("jmauzyk\\commerce\\cardconnect\\web\\assets\\cardsecurepaymentform\\CardSecurePaymentFormAsset") %}
{% js %}initTokenizer('{{ gateway.getApiSubdomain() }}');{% endjs %}
```
To speed up tokenization performance, it's recommended to use code similar to below to preconnect or dns-prefetch before the tokenization is called.
```Twig
{% set subdomain = gateway.getApiSubdomain() %}
{% set apiUrl = 'https://' ~ subdomain ~ '.cardconnect.com' %}
{% do view.registerLinkTag({rel: 'preconnect', href: apiUrl}) %}
{% do view.registerLinkTag({rel: 'dns-prefetch', href: apiUrl}) %}
```

### Hosted iFrame Tokenizer Customization
Expand Down Expand Up @@ -121,5 +159,5 @@ Below is an example of how you can customize the default payment form and tokeni
{{ cart.gateway.getPaymentFormHtml({srcParams: srcParams, options: options})|raw }}
{# To output tokenized number input with customization... #}
{{ gateway.getTokenizedNumberInput(srcParams, options)|raw }}
{{ gateway.getIframeNumberInput(srcParams, options)|raw }}
```
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "jmauzyk/commerce-cardconnect",
"description": "CardConnect integration for Craft Commerce 2",
"description": "CardConnect integration for Craft Commerce",
"type": "craft-plugin",
"version": "1.3.1",
"version": "1.4.0",
"keywords": [
"craft",
"cms",
Expand All @@ -28,7 +28,7 @@
"craftcms/cms": "^3.1",
"craftcms/commerce": "^2.0|^3.0",
"craftcms/commerce-omnipay": "^2.0",
"jmauzyk/omnipay-cardconnect": "^1.2"
"jmauzyk/omnipay-cardconnect": "^1.3"
},
"autoload": {
"psr-4": {
Expand Down
1 change: 1 addition & 0 deletions lib/jsencrypt/jsencrypt.min.js

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace jmauzyk\commerce\cardconnect;

use jmauzyk\commerce\cardconnect\gateways\Gateway;
use jmauzyk\commerce\cardconnect\plugin\Services;

use Craft;
use craft\events\RegisterComponentTypesEvent;
Expand Down Expand Up @@ -42,7 +43,12 @@ class Plugin extends \craft\base\Plugin
/**
* @var string
*/
public $schemaVersion = '1.1.0';
public $schemaVersion = '1.2.0';

// Traits
// =========================================================================

use Services;

// Public Methods
// =========================================================================
Expand All @@ -55,6 +61,8 @@ public function init()
parent::init();
self::$plugin = $this;

$this->_setPluginComponents();

Event::on(
Gateways::class,
Gateways::EVENT_REGISTER_GATEWAY_TYPES,
Expand Down
25 changes: 25 additions & 0 deletions src/errors/PaymentSourceException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
/**
* CardConnect for Craft Commerce plugin for Craft CMS 3.x
*
* CardConnect integration for Craft Commerce 2
*
* @link http://www.joel-king.com
* @copyright Copyright (c) 2019 jmauzyk
*/

namespace jmauzyk\commerce\cardconnect\errors;

use craft\commerce\errors\SubscriptionException;

/**
* Class PaymentSourceException
*
* @author jmauzyk
* @package CardConnect
* @since 1.4.0
*
*/
class PaymentSourceException extends SubscriptionException
{
}
25 changes: 25 additions & 0 deletions src/errors/ProfileException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
/**
* CardConnect for Craft Commerce plugin for Craft CMS 3.x
*
* CardConnect integration for Craft Commerce 2
*
* @link http://www.joel-king.com
* @copyright Copyright (c) 2019 jmauzyk
*/

namespace jmauzyk\commerce\cardconnect\errors;

use yii\base\Exception;

/**
* Class ProfileException
*
* @author jmauzyk
* @package CardConnect
* @since 1.4.0
*
*/
class ProfileException extends Exception
{
}
Loading

0 comments on commit 246b61c

Please sign in to comment.