Skip to content

Commit

Permalink
Merge pull request #1 from ionutcalara/master
Browse files Browse the repository at this point in the history
Renamed main plugin, added default order statuses
  • Loading branch information
ionutcalara authored Nov 27, 2019
2 parents 75fdd91 + 385c1aa commit 8cc7271
Show file tree
Hide file tree
Showing 21 changed files with 262 additions and 240 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Released under the GPL V3 license: https://opensource.org/licenses/GPL-3.0

* The plugin has been tested with most versions of CS-Cart at every iteration. We recommend using the latest version of CS-Cart, but if that is not possible for some reason, test the plugin with your CS-Cart version and it would probably function properly.
* CS-Cart
version last tested on: *4.10.4*
version last tested on: *4.11.1*

## Installation

Expand All @@ -18,7 +18,7 @@ Released under the GPL V3 license: https://opensource.org/licenses/GPL-3.0

1. Create a live account
1. Create an app key for your CS-Cart website
1. Upload the plugin zip (`sl_paylike.zip`) trough the Add-ons panel and activate it
1. Upload the plugin zip (`kp_paylike.zip`) trough the Add-ons panel and activate it
1. Under Administration -> payment methods create a new payment method and select Paylike as the processor.
1. On the configure tab, insert the app key and your public key in the settings for the Paylike payment gateway you just created

Expand Down
Binary file added kp_paylike.zip
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @copyright 2019 Paylike.com.
* @author Panos <[email protected]>
* @copyright 2019 Paylike.io.
* @author Panos <[email protected]>
* Date: 17/9/2019
* Time: 11:28 πμ
*/
Expand Down Expand Up @@ -34,15 +34,14 @@ public function capture(&$order_info, $txnId) {
$pp_response['reason_text'] = $message;
$update = true;
} elseif ( ! empty( $capture['transaction'] ) ) {
$message = __('sl_paylike.trx_id').':' . $txnId .
__('sl_paylike.authorized_amount').':' . ( $capture['transaction']['amount'] / $currency_multiplier ) .
__('sl_paylike.captured_amount').':'. ( $capture['transaction']['capturedAmount'] / $currency_multiplier ) .
__('sl_paylike.order_time').':'. $capture['transaction']['created'] .
__('sl_paylike.currency_code').':'. $capture['transaction']['currency'];
$pp_response['reason_text'] = $message;
$pp_response['reason_text'] = __("captured");
$pp_response['transaction_id'] = $txnId;
$pp_response['captured'] = 'Y';
$pp_response['kp_paylike.order_time'] = kp_paylike_datetime_to_human($capture['transaction']['created']);
$pp_response['kp_paylike.currency_code'] = $capture['transaction']['currency'];
$pp_response['kp_paylike.authorized_amount'] = ( $capture['transaction']['amount'] / $currency_multiplier );
$pp_response['amount_capt'] = $capture['transaction']['capturedAmount'] / $currency_multiplier ;
$pp_response['captured'] = 'Y';
array_filter($pp_response);
$update = true;
}
if($update) {
Expand Down Expand Up @@ -70,17 +69,16 @@ public function refund(&$order_info, $txnId, $amount) {
$pp_response['reason_text'] = $message;
$update = true;
} elseif ( ! empty( $capture['transaction'] ) ) {
$message = __('sl_paylike.trx_id').':' . $txnId .
__('sl_paylike.authorized_amount').':' . ( $capture['transaction']['amount'] / $currency_multiplier ) .
__('sl_paylike.captured_amount').':'. ( $capture['transaction']['capturedAmount'] / $currency_multiplier ) .
__('sl_paylike.refunded_amount').':'. ( $capture['transaction']['refundedAmount'] / $currency_multiplier ) .
__('sl_paylike.order_time').':'. $capture['transaction']['created'] .
__('sl_paylike.currency_code').':'. $capture['transaction']['currency'];
$pp_response['reason_text'] = $message;
$pp_response['reason_text'] = __("refunded");
$pp_response['transaction_id'] = $txnId;
$pp_response['captured'] = 'Y';
$pp_response['kp_paylike.order_time'] = kp_paylike_datetime_to_human($capture['transaction']['created']);
$pp_response['kp_paylike.currency_code'] = $capture['transaction']['currency'];
$pp_response['kp_paylike.authorized_amount'] = ( $capture['transaction']['amount'] / $currency_multiplier );
$pp_response['amount_capt'] = $capture['transaction']['capturedAmount'] / $currency_multiplier ;
$pp_response['amount_refu'] = $capture['transaction']['refundedAmount'] / $currency_multiplier ;
$pp_response['captured'] = 'Y';
$pp_response['refunded'] = 'Y';
array_filter($pp_response);
$update = true;
}
if($update) {
Expand Down Expand Up @@ -109,16 +107,14 @@ public function void(&$order_info, $txnId) {
$pp_response['reason_text'] = $message;
$update = true;
} elseif ( ! empty( $capture['transaction'] ) ) {
$message = __('sl_paylike.trx_id').':' . $txnId .
__('sl_paylike.captured_amount').':'. ( $capture['transaction']['capturedAmount'] / $currency_multiplier ) .
' Void Amount: ' . ( $capture['transaction']['voidedAmount'] / $currency_multiplier ) .
__('sl_paylike.order_time').':'. $capture['transaction']['created'] .
__('sl_paylike.currency_code').':'. $capture['transaction']['currency'];
$pp_response['reason_text'] = $message;
$pp_response['reason_text'] = __("voided");
$pp_response['transaction_id'] = $txnId;
$pp_response['captured'] = 'N';
$pp_response['kp_paylike.order_time'] = kp_paylike_datetime_to_human($capture['transaction']['created']);
$pp_response['kp_paylike.currency_code'] = $capture['transaction']['currency'];
$pp_response['voided_amount'] = $capture['transaction']['voidedAmount'] / $currency_multiplier ;
$pp_response['captured'] = 'N';
$pp_response['voided'] = 'Y';
array_filter($pp_response);
$update = true;
}
if($update) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @copyright 2019 Paylike.com.
* @author Panos <[email protected]>
* @copyright 2019 Paylike.io.
* @author Panos <[email protected]>
* Date: 17/9/2019
* Time: 10:17 πμ
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?xml version="1.0"?>
<addon scheme="3.0">
<id>sl_paylike</id>
<id>kp_paylike</id>
<name>Paylike.io payment gateway</name>
<version>1.0</version>
<version>1.1</version>
<priority>5200</priority>
<position>0</position>
<default_language>en</default_language>
<auto_install>MULTIVENDOR</auto_install>
<status>active</status>
<supplier>paylike.io</supplier>
<supplier_link>https://paylike.io</supplier_link>
<supplier>Paylike.io</supplier>
<supplier_link>http://Paylike.io</supplier_link>
<author>
<name>CS-Cart.in</name>
<url>http://cs-cart.in</url>
<name>Paylike.io</name>
<url>http://Paylike.io</url>
<email>[email protected]</email>
</author>
<queries>
Expand All @@ -21,6 +21,6 @@
</item>
</queries>
<functions>
<item for="uninstall">sl_paylike_delete_payment_processors</item>
<item for="uninstall">kp_paylike_delete_payment_processors</item>
</functions>
</addon>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @copyright 2019 Paylike.com.
* @author Panos <[email protected]>
* @copyright 2019 Paylike.io.
* @author Panos <[email protected]>
* Date: 17/9/2019
* Time: 12:26 μμ
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<?php
/**
* @copyright 2019 Paylike.io.
* @author Panos <[email protected]>
* @author Panos <[email protected]>
* Date: 16/9/2019
* Time: 10:10 πμ
*/
use Tygh\Registry;

function sl_paylike_currencies() {
function kp_paylike_currencies() {
return \Paylike\Currency::getCurrenciesList();
}

function sl_paylike_get_order_statuses_list() {
function kp_paylike_get_order_statuses_list() {
$statuses = fn_get_statuses();
$data = array();
foreach ($statuses as $k => $status) {
Expand All @@ -19,7 +20,7 @@ function sl_paylike_get_order_statuses_list() {
return $data;
}

function fn_sl_paylike_change_order_status($status_to, $status_from, &$order_info, $force_notification, $order_statuses, $place_order) {
function fn_kp_paylike_change_order_status($status_to, $status_from, &$order_info, $force_notification, $order_statuses, $place_order) {
$doCapture = false;
$doVoid = false;
$txnId = false;
Expand Down Expand Up @@ -51,7 +52,7 @@ function fn_sl_paylike_change_order_status($status_to, $status_from, &$order_inf
}
}

function sl_paylike_can_refund_order($order_info) {
function kp_paylike_can_refund_order($order_info) {
$out = false;
if($order_info['payment_method']['processor']=='Paylike') {
$captured = !empty($order_info['payment_info']['captured']) ? $order_info['payment_info']['captured'] : 'Y';
Expand All @@ -66,8 +67,17 @@ function sl_paylike_can_refund_order($order_info) {
return $out;
}

function sl_paylike_delete_payment_processors()
function kp_paylike_delete_payment_processors()
{
db_query("UPDATE ?:payments SET processor_id = 0, processor_params='', status='D' WHERE processor_id IN (SELECT processor_id FROM ?:payment_processors WHERE processor_script IN ('paylike.php'))");
db_query("DELETE FROM ?:payment_processors WHERE processor_script IN ('paylike.php')");
db_query("UPDATE ?:payments SET processor_id = 0, processor_params='', status='D' WHERE processor_id IN (SELECT processor_id FROM ?:payment_processors WHERE processor_script IN ('paylike.php'))");
db_query("DELETE FROM ?:payment_processors WHERE processor_script IN ('paylike.php')");
}

function kp_paylike_datetime_to_human($dt) {
$t = strtotime($dt);
$out = sprintf("%s %s",
fn_date_format($t,Registry::get('settings.Appearance.date_format')),
fn_date_format($t,Registry::get('settings.Appearance.time_format'))
);
return $out;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @copyright 2019 Paylike.com.
* @author Panos <[email protected]>
* @copyright 2019 Paylike.io.
* @author Panos <[email protected]>
* Date: 17/9/2019
* Time: 11:17 πμ
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @copyright 2019 Paylike.com.
* @author Panos <[email protected]>
* @copyright 2019 Paylike.io.
* @author Panos <[email protected]>
* Date: 16/9/2019
* Time: 9:48 πμ
*/
Expand Down Expand Up @@ -46,19 +46,16 @@
elseif ( is_array( $fetch ) && $fetch['transaction']['custom']['order_id']==$order_id) {
$total = $fetch['transaction']['amount'] / $currency_multiplier;
$amount = $fetch['transaction']['amount'];

$message = __('sl_paylike.trx_id').': ' . $txnId .
' '.__('sl_paylike.authorized_amount').': ' . ( $fetch['transaction']['amount'] / $currency_multiplier ) .
' '.__('sl_paylike.captured_amount').': ' . ( $fetch['transaction']['capturedAmount'] / $currency_multiplier ) .
' '.__('sl_paylike.order_time').': ' . $fetch['transaction']['created'] .
' '.__('sl_paylike.currency_code').': ' . $fetch['transaction']['currency'];
$pp_response['order_status'] = $processor_data['processor_params']['delayed_status'];
$pp_response['amount_auth'] = $fetch['transaction']['amount'] / $currency_multiplier ;
$pp_response['amount_capt'] = $fetch['transaction']['capturedAmount'] / $currency_multiplier ;
$pp_response['amount_refu'] = 0;
$pp_response['reason_text'] = $message;

$pp_response['reason_text'] = __("delayed");
$pp_response['transaction_id'] = $txnId;
$pp_response['kp_paylike.order_time'] = kp_paylike_datetime_to_human($fetch['transaction']['created']);
$pp_response['kp_paylike.currency_code'] = $fetch['transaction']['currency'];
$pp_response['amount_auth'] = $fetch['transaction']['amount'] / $currency_multiplier ;
//$pp_response['amount_capt'] = $fetch['transaction']['capturedAmount'] / $currency_multiplier ;
$pp_response['captured'] = 'N';
array_filter($pp_response);
}
} else {

Expand All @@ -73,19 +70,15 @@
$pp_response['order_status'] = 'F';
$pp_response['reason_text'] = $message;
} elseif ( ! empty( $capture['transaction'] ) ) {

$message = __('sl_paylike.trx_id'). ': ' . $txnId .
' '.__('sl_paylike.authorized_amount').': ' . ( $capture['transaction']['amount'] / $currency_multiplier ) .
' '.__('sl_paylike.captured_amount').': ' . ( $capture['transaction']['capturedAmount'] / $currency_multiplier ) .
' '.__('sl_paylike.order_time').': ' . $capture['transaction']['created'] .
' '.__('sl_paylike.currency_code').': ' . $capture['transaction']['currency'];
$pp_response['order_status'] = 'P';
$pp_response['reason_text'] = __("captured");
$pp_response['transaction_id'] = $txnId;
$pp_response['kp_paylike.order_time'] = kp_paylike_datetime_to_human($capture['transaction']['created']);
$pp_response['kp_paylike.currency_code'] = $capture['transaction']['currency'];
$pp_response['amount_auth'] = $capture['transaction']['amount'] / $currency_multiplier ;
$pp_response['amount_capt'] = $capture['transaction']['capturedAmount'] / $currency_multiplier ;
$pp_response['amount_refu'] = 0;
$pp_response['reason_text'] = $message;
$pp_response['transaction_id'] = $txnId;
$pp_response['captured'] = 'Y';
array_filter($pp_response);
} else {
$transaction_failed = true;
}
Expand Down Expand Up @@ -125,12 +118,12 @@
];
$view->assign('customer', $customer);
$platform = [
'name' => PRODUCT_NAME,
'name' => 'CS-CART ' . PRODUCT_NAME,
'version' => PRODUCT_VERSION,
'addon_name' => 'Paylike addon',
'addon_version' => fn_get_addon_version('sl_paylike'),
'addon_name' => 'Paylike.io CS-Cart Kit',
'addon_version' => fn_get_addon_version('kp_paylike'),
];
$view->assign('platform', $platform);
$view->display('addons/sl_paylike/components/payment_page.tpl');
$view->display('addons/kp_paylike/components/payment_page.tpl');
die(1);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{if sl_paylike_can_refund_order($order_info)}
{if kp_paylike_can_refund_order($order_info)}

<a class="btn cm-dialog-opener cm-ajax"
href="{"paylike.refund?order_id=`$order_info.order_id`"|fn_url}"
data-ca-dialog-title="Refund"
>{__("sl_paylike.refund")}</a>
>{__("kp_paylike.refund")}</a>
{/if}
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

<fieldset >
<div class="control-group">
<label class="control-label cm-required" for="elm_amount">{__("sl_paylike.amount")}</label>
<label class="control-label cm-required" for="elm_amount">{__("kp_paylike.amount")}</label>
<div class="controls">
<input type="number" name="amount" id="elm_amount" step="0.01" min="1" max="{$amount}" value="{$amount}" />
</div>
</div>
</fieldset>
<div class="buttons-container">
<input type="submit" class="btn btn-primary" name="dispatch[paylike.refund]" value="{__("sl_paylike.refund")}" />
{include file="addons/sl_paylike/components/close_popup.tpl"}
<input type="submit" class="btn btn-primary" name="dispatch[paylike.refund]" value="{__("kp_paylike.refund")}" />
{include file="addons/kp_paylike/components/close_popup.tpl"}
</div>

</form>
Expand Down
Loading

0 comments on commit 8cc7271

Please sign in to comment.