Skip to content

Commit

Permalink
Initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
ppmadmin committed Oct 31, 2017
0 parents commit e789666
Show file tree
Hide file tree
Showing 57 changed files with 2,780 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
@@ -0,0 +1,4 @@
payabbhi.tar.gz
.DS_Store
dist/*

21 changes: 21 additions & 0 deletions LICENSE
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 Paypermint

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.
29 changes: 29 additions & 0 deletions Makefile
@@ -0,0 +1,29 @@
VERSION_FILE=VERSION
VER=`cat $(VERSION_FILE)`

release: init prepare archive cleanup

init:
mkdir dist

prepare:
cp VERSION payabbhi
markdown-pdf README.md
zip -r payabbhi.zip payabbhi


archive:
zip -r payabbhi-prestashop-$(VER).zip payabbhi.zip README.pdf
tar -cvzf payabbhi-prestashop-$(VER).tar.gz payabbhi.zip README.pdf


cleanup:
mv payabbhi-prestashop-$(VER).zip dist
mv payabbhi-prestashop-$(VER).tar.gz dist
rm payabbhi/VERSION
rm README.pdf
rm payabbhi.zip


clean:
rm -rf dist
40 changes: 40 additions & 0 deletions README.md
@@ -0,0 +1,40 @@
## Payabbhi Payments - Prestashop Integration

This extension is built on Payabbhi PHP Library to provide seamless integration of [Payabbhi Checkout ](https://payabbhi.com/docs/checkout) with PrestaShop 1.6


### Installation

Make sure you have signed up for your [Payabbhi Account](https://payabbhi.com/docs/account) and downloaded the [API keys](https://payabbhi.com/docs/account/#api-keys) from the [Portal](https://payabbhi.com/portal).

1. Unzip [payabbhi-prestashop-VERSION.zip](https://github.com/payabbhi/payabbhi-prestashop/releases).

2. Navigate to `PrestaShop Back Office` -> `Modules and Services` and click on `Add a new module`.

3. Browse for `payabbhi.zip` to add Payabbhi Payment Extension to PrestaShop.

4. On successful upload, `payabbhi` folder should get added to PrestaShop installation directory as follows:

```
PrestaShop/
modules/
payabbhi/
config.xml
controllers/
index.php
logo.png
payabbhi-php/
payabbhi.php
VERSION
views/
```

4. After successful upload, navigate to `Modules List` ->`Payments and Gateways` and install `Payabbhi Checkout` as per on-screen instructions. If you do not find Payabbhi on the list, please use the search option to find it.

5. Configure `Payabbhi` and Save the settings:
- [Access ID](https://payabbhi.com/docs/account/#api-keys)
- [Secret Key](https://payabbhi.com/docs/account/#api-keys)
- [payment_auto_capture](https://payabbhi.com/docs/api/#create-an-order)


[Payabbhi Checkout](https://payabbhi.com/docs/checkout) is now enabled in PrestaShop.
1 change: 1 addition & 0 deletions VERSION
@@ -0,0 +1 @@
1.0.0
13 changes: 13 additions & 0 deletions payabbhi/config.xml
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>payabbhi</name>
<displayName><![CDATA[Payabbhi]]></displayName>
<version><![CDATA[1.0.0]]></version>
<description><![CDATA[Accept payments for your products via Payabbhi.]]></description>
<author><![CDATA[Payabbhi Team]]></author>
<tab><![CDATA[payments_gateways]]></tab>
<confirmUninstall><![CDATA[Are you sure you want to uninstall?]]></confirmUninstall>
<is_configurable>1</is_configurable>
<need_instance>1</need_instance>
<limited_countries></limited_countries>
</module>
10 changes: 10 additions & 0 deletions payabbhi/controllers/front/index.php
@@ -0,0 +1,10 @@
<?php
header('Expires: Tue, 01 Apr 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');

header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');

header('Location: ../');
exit;
25 changes: 25 additions & 0 deletions payabbhi/controllers/front/payment.php
@@ -0,0 +1,25 @@
<?php
class PayabbhiPaymentModuleFrontController extends ModuleFrontController
{
public $ssl = true;
public $display_column_left = false;
public function initContent()
{
parent::initContent();

$cart = $this->context->cart;
$payabbhi = new payabbhi();
$payabbhi->execPayment($cart);

$this->context->smarty->assign(array(
'nbProducts' => $cart->nbProducts(),
'total' => $cart->getOrderTotal(true, Cart::BOTH),
'this_path' => $this->module->getPathUri(),
'this_path_bw' => $this->module->getPathUri(),
'this_path_ssl' => Tools::getShopDomainSsl(true, true).__PS_BASE_URI__.'modules/'.$this->module->name.'/'
)
);

$this->setTemplate('payment_execution.tpl');
}
}
70 changes: 70 additions & 0 deletions payabbhi/controllers/front/validation.php
@@ -0,0 +1,70 @@
<?php


class PayabbhiValidationModuleFrontController extends ModuleFrontController
{
public function postProcess()
{
global $cookie;

$payment_id = $_REQUEST['payment_id'];
$attributes = array(
'payment_id' => $payment_id,
'order_id' => $_REQUEST['order_id'],
'payment_signature' => $_REQUEST['payment_signature'],
);

$cart = $this->context->cart;
$cart_id = $cart->id;

$payabbhi = new Payabbhi();
$success = true;

$accessID = Configuration::get('PAYABBHI_ACCESS_ID'); //TODO fetch from $this if possible
$secretKey = Configuration::get('PAYABBHI_SECRET_KEY');
$client = new \Payabbhi\Client($accessID, $secretKey);

try {
$client->utility->verifyPaymentSignature($attributes);
$payment = $client->payment->retrieve($payment_id);
} catch (\Payabbhi\Error $e) {
$success = false;
$error = 'Prestashop Error: Payment failed because signature verification error';
}

if ($success == true)
{
$customer = new Customer($cart->id_customer);
$total = (float) $cart->getOrderTotal(true, Cart::BOTH);
$payabbhi->validateOrder($cart_id, _PS_OS_PAYMENT_, $total, $payabbhi->displayName . ' (' . $payment->method . ')', '', array(), NULL, false, $customer->secure_key);

Logger::addLog("Payment Successful for Order#" . $cart_id . ". Payabbhi payment ID: " . $payment_id . ". Payabbhi order ID: " . $_REQUEST['order_id'], 1);

$order = new Order((int)$payabbhi->currentOrder);
$payments = $order->getOrderPayments();

if (!empty($payments)) {
$payments[0]->transaction_id = $payment_id;
$payments[0]->update();
}

$query = http_build_query(array(
'controller' => 'order-confirmation',
'id_cart' => (int) $cart->id,
'id_module' => (int) $this->module->id,
'id_order' => $payabbhi->currentOrder
), '', '&');

$url = 'index.php?'. $query;
Tools::redirect($url);
}
else
{
Logger::addLog("Payment Failed for Order# ". $cart_id . "Error: ". $error, 4);
echo 'Error! Please contact the seller directly for assistance.</br>';
echo 'Order Id: '.$cart_id.'</br>';
echo 'Error: '.str_replace(' ', ' ', ucwords(str_replace('_', ' ', $response_code))).'</br>';
}

}
}
10 changes: 10 additions & 0 deletions payabbhi/index.php
@@ -0,0 +1,10 @@
<?php
header('Expires: Tue, 01 Apr 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');

header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');

header('Location: ../');
exit;
Binary file added payabbhi/logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions payabbhi/payabbhi-php/.gitignore
@@ -0,0 +1,14 @@
# Mac OS X dumps these all over the place.
.DS_Store

# Ignore the /vendor/ directory for people using composer
/vendor/

# If the vendor directory isn't being commited the composer.lock file should also be ignored
composer.lock

# Ignore PHPUnit coverage file
clover.xml

# Ignore tests
test.php
21 changes: 21 additions & 0 deletions payabbhi/payabbhi-php/LICENSE
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 Paypermint

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.

0 comments on commit e789666

Please sign in to comment.