Skip to content

Commit

Permalink
Merge pull request #9 from 202-ecommerce/develop
Browse files Browse the repository at this point in the history
1.2.1
  • Loading branch information
202-ecommerce authored Mar 27, 2020
2 parents 1622083 + cb2895c commit 97db8dd
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 18 deletions.
2 changes: 1 addition & 1 deletion 202/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<property name="src-dir" value="${basedir}" />
<property name="TARGETNAME" value="braintreeofficial" />
<property name="TARGETBRANCH" value="${env.GIT_BRANCH}" />
<property name="TARGETVERSION" value="1.2.0" />
<property name="TARGETVERSION" value="1.2.1" />
<property name="PHPVERSION" value="5.6" />
<property name="PSVERSION" value="1.7.5.x" />

Expand Down
97 changes: 96 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,97 @@
# braintree
# Braintree
Braintree official module

## About

Let customer pay on PrestaShop 1.7 with one of this payment methods :
- PayPal
- Braintree cards

#### Product page on PrestaShop Addons:

https://addons.prestashop.com/en/payments-gateways-prestashop-modules/46833-braintree-official.html

## Module version guide

| PrestaShop version | Module version | Repo | Doc | PHP Version |
|---------|------------|---------------------|---------------------|-------------|
| 1.7.x | 1.x | [master][paypal-4] | [module documentation][6]| 5.4 or greater |

## Requirements

1. PHP version (check Module version guide)
2. TLS 1.2 & cURL 1.0.1c

The Payment Card Industry (PCI) Council has mandated that early versions of
TLS be retired from service. All organizations that handle credit card information
are required to comply with this standard. As part of this obligation, PayPal has
upgraded its services to require TLS 1.2 for all HTTPS connections.
Connections to the sandbox environment use only TLS 1.2.

For more official, relevant information, see the 2017-2018 Merchant Security
Roadmap Microsite:
* [TLS 1.2 and HTTP/1.1 Upgrade Microsite][4]
* [SSL Certificate Upgrade Microsite][5]

Check the version of your URL’s underlying security library. If you use OpenSSL
libraries, please update them to at least version 1.0.1c.

## Installation

To install module on PrestaShop, download zip package form [product page on PrestaShop Addons][addons].

This module contain composer.json file. If you clone or download the module from github
repository, run the ```composer install``` from the root module folder.

See the [composer documentation][composer-doc] to learn more about the composer.json file.

## Compiling assets
**For development**

We use _Webpack_ to compile our javascript and scss files.
In order to compile those files, you must :
1. have _Node 10+_ installed locally
2. run `npm install` in the root folder to install dependencies
3. then run `npm run watch` to compile assets and watch for file changes

**For production**

Run `npm run build` to compile for production.
Files are minified, `console.log` and comments dropped.

## Contributing

PrestaShop modules are open-source extensions to the PrestaShop e-commerce solution. Everyone is welcome and even encouraged to contribute with their own improvements.

### Requirements

Contributors **must** follow the following rules:

* **Make your Pull Request on the "develop" branch**, NOT the "master" branch.
* Do not update the module's version number.
* Follow [the coding standards][1].

### Process in details

Contributors wishing to edit a module's files should follow the following process:

1. Create your GitHub account, if you do not have one already.
2. Fork the paypal project to your GitHub account.
3. Clone your fork to your local machine in the ```/modules``` directory of your PrestaShop installation.
4. Create a branch in your local clone of the module for your changes.
5. Change the files in your branch. Be sure to follow [the coding standards][1]!
6. Push your changed branch to your fork in your GitHub account.
7. Create a pull request for your changes **on the _'develop'_ branch** of the module's project. Be sure to follow [the commit message norm][2] in your pull request. If you need help to make a pull request, read the [Github help page about creating pull requests][3].
8. Wait for one of the core developers either to include your change in the codebase, or to comment on possible improvements you should make to your code.

That's it: you have contributed to this open-source project! Congratulations!

[1]: https://devdocs.prestashop.com/1.7/development/coding-standards/
[2]: http://doc.prestashop.com/display/PS16/How+to+write+a+commit+message
[3]: https://help.github.com/articles/using-pull-requests
[4]: https://www.paypal-notice.com/en/TLS-1.2-and-HTTP1.1-Upgrade/
[5]: https://www.paypal-notice.com/en/SSL-Certificate-Upgrade-Microsite/
[6]: https://help.202-ecommerce.com/wp-content/uploads/2019/12/User-guide-Braintree-PrestaShop-module.pdf
[paypal-4]: https://github.com/202-ecommerce/braintreeofficial/tree/master
[addons]: https://addons.prestashop.com/en/payments-gateways-prestashop-modules/46833-braintree-official.html
[composer-doc]: https://getcomposer.org/doc/04-schema.md
28 changes: 14 additions & 14 deletions braintreeofficial.php
Original file line number Diff line number Diff line change
Expand Up @@ -1023,17 +1023,17 @@ public function hookHeader()
}

$this->context->controller->addJqueryPlugin('fancybox');
$this->context->controller->registerJavascript($this->name . '-braintreegateway-client', 'https://js.braintreegateway.com/web/3.56.0/js/client.min.js', array('server' => 'remote'));
$this->context->controller->registerJavascript($this->name . '-braintreegateway-hosted', 'https://js.braintreegateway.com/web/3.56.0/js/hosted-fields.min.js', array('server' => 'remote'));
$this->context->controller->registerJavascript($this->name . '-braintreegateway-data', 'https://js.braintreegateway.com/web/3.24.0/js/data-collector.min.js', array('server' => 'remote'));
$this->context->controller->registerJavascript($this->name . '-braintreegateway-3ds', 'https://js.braintreegateway.com/web/3.56.0/js/three-d-secure.min.js', array('server' => 'remote'));
$this->context->controller->registerJavascript($this->name . '-braintreegateway-client', 'https://js.braintreegateway.com/web/3.57.0/js/client.min.js', array('server' => 'remote'));
$this->context->controller->registerJavascript($this->name . '-braintreegateway-hosted', 'https://js.braintreegateway.com/web/3.57.0/js/hosted-fields.min.js', array('server' => 'remote'));
$this->context->controller->registerJavascript($this->name . '-braintreegateway-data', 'https://js.braintreegateway.com/web/3.57.0/js/data-collector.min.js', array('server' => 'remote'));
$this->context->controller->registerJavascript($this->name . '-braintreegateway-3ds', 'https://js.braintreegateway.com/web/3.57.0/js/three-d-secure.min.js', array('server' => 'remote'));
$this->context->controller->registerStylesheet($this->name . '-braintreecss', 'modules/' . $this->name . '/views/css/braintree.css');
$this->addJsVarsLangBT();
$this->addJsVarsBT();
$this->context->controller->registerJavascript($this->name . '-braintreejs', 'modules/' . $this->name . '/views/js/payment_bt.js');

if (Configuration::get('BRAINTREEOFFICIAL_ACTIVATE_PAYPAL')) {
$this->context->controller->registerJavascript($this->name . '-pp-braintree-checkout-min', 'https://js.braintreegateway.com/web/3.56.0/js/paypal-checkout.min.js', array('server' => 'remote'));
$this->context->controller->registerJavascript($this->name . '-pp-braintree-checkout-min', 'https://js.braintreegateway.com/web/3.57.0/js/paypal-checkout.min.js', array('server' => 'remote'));
$this->context->controller->registerJavascript($this->name . '-pp-braintree-checkout', 'https://www.paypalobjects.com/api/checkout.js', array('server' => 'remote'));
Media::addJsDefL('empty_nonce', $this->l('Please click on the PayPal Pay button first'));
$this->addJsVarsPB();
Expand All @@ -1060,24 +1060,24 @@ public function hookHeader()
}

$resources = array(
'https://js.braintreegateway.com/web/3.56.0/js/client.min.js',
'https://js.braintreegateway.com/web/3.56.0/js/hosted-fields.min.js',
'https://js.braintreegateway.com/web/3.24.0/js/data-collector.min.js',
'https://js.braintreegateway.com/web/3.56.0/js/three-d-secure.min.js',
'https://js.braintreegateway.com/web/3.57.0/js/client.min.js',
'https://js.braintreegateway.com/web/3.57.0/js/hosted-fields.min.js',
'https://js.braintreegateway.com/web/3.57.0/js/data-collector.min.js',
'https://js.braintreegateway.com/web/3.57.0/js/three-d-secure.min.js',
);
$this->context->controller->registerStylesheet($this->name . '-braintreecss', 'modules/' . $this->name . '/views/css/braintree.css');

if (Configuration::get('BRAINTREEOFFICIAL_ACTIVATE_PAYPAL')) {
$resources_paypal = array(
'https://js.braintreegateway.com/web/3.56.0/js/paypal-checkout.min.js'
'https://js.braintreegateway.com/web/3.57.0/js/paypal-checkout.min.js'
);

if (Configuration::get('BRAINTREEOFFICIAL_EXPRESS_CHECKOUT_SHORTCUT_CART')) {
Media::addJsDef($this->methodBraintreeOfficial->getShortcutJsVars(BRAINTREE_CART_PAGE));
$this->context->controller->registerJavascript($this->name . '-braintreeShortcut', 'modules/' . $this->name . '/views/js/btShortcut.js');
$this->context->controller->registerJavascript($this->name . '-pp-braintree-checkout-min', 'https://js.braintreegateway.com/web/3.56.0/js/paypal-checkout.min.js', array('server' => 'remote'));
$this->context->controller->registerJavascript($this->name . '-pp-braintree-checkout-min', 'https://js.braintreegateway.com/web/3.57.0/js/paypal-checkout.min.js', array('server' => 'remote'));
$this->context->controller->registerJavascript($this->name . '-pp-braintree-checkout', 'https://www.paypalobjects.com/api/checkout.js', array('server' => 'remote'));
$this->context->controller->registerJavascript($this->name . '-pp-braintree-client', 'https://js.braintreegateway.com/web/3.56.0/js/client.min.js', array('server' => 'remote'));
$this->context->controller->registerJavascript($this->name . '-pp-braintree-client', 'https://js.braintreegateway.com/web/3.57.0/js/client.min.js', array('server' => 'remote'));
}

$resources = array_merge($resources, $resources_paypal);
Expand All @@ -1091,9 +1091,9 @@ public function hookHeader()
if (Configuration::get('BRAINTREEOFFICIAL_ACTIVATE_PAYPAL') && Configuration::get('BRAINTREEOFFICIAL_EXPRESS_CHECKOUT_SHORTCUT')) {
Media::addJsDef($this->methodBraintreeOfficial->getShortcutJsVars(BRAINTREE_PRODUCT_PAGE));
$this->context->controller->registerJavascript($this->name . '-braintreeShortcut', 'modules/' . $this->name . '/views/js/btShortcut.js');
$this->context->controller->registerJavascript($this->name . '-pp-braintree-checkout-min', 'https://js.braintreegateway.com/web/3.56.0/js/paypal-checkout.min.js', array('server' => 'remote'));
$this->context->controller->registerJavascript($this->name . '-pp-braintree-checkout-min', 'https://js.braintreegateway.com/web/3.57.0/js/paypal-checkout.min.js', array('server' => 'remote'));
$this->context->controller->registerJavascript($this->name . '-pp-braintree-checkout', 'https://www.paypalobjects.com/api/checkout.js', array('server' => 'remote'));
$this->context->controller->registerJavascript($this->name . '-pp-braintree-client', 'https://js.braintreegateway.com/web/3.56.0/js/client.min.js', array('server' => 'remote'));
$this->context->controller->registerJavascript($this->name . '-pp-braintree-client', 'https://js.braintreegateway.com/web/3.57.0/js/client.min.js', array('server' => 'remote'));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion controllers/front/validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function displayAjaxGetOrderInformation()
'amount' => $this->context->cart->getOrderTotal(true, Cart::BOTH),
'email' => $customer->email,
'billingAddress' => array(
'givenName' => $customer->firstname,
'givenName' => iconv("utf-8", "ascii//TRANSLIT", $customer->firstname),
'surneme' => $customer->lastname,
'phoneNumber' => $address->phone,
'streetAddress' => $address->address1,
Expand Down
2 changes: 1 addition & 1 deletion views/templates/front/payment_bt.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<div class="bt__mb-2">
<i class="material-icons mi-lock">lock</i>
<b>{l s='Pay securely using your credit card.' mod='braintreeofficial'}</b>
<img style="width: 120px" class="bt__ml-2" src="/modules/braintreeofficial/views/img/braintree-paypal.png">
<img style="width: 120px" class="bt__ml-2" src="{$baseDir|addslashes}modules/braintreeofficial/views/img/braintree-paypal.png">
</div>
<div class="payment_module braintree-card">
{if !isset($init_error)}
Expand Down

0 comments on commit 97db8dd

Please sign in to comment.