Skip to content

Commit

Permalink
Add lang parameter (#26)
Browse files Browse the repository at this point in the history
Co-authored-by: Adam Wysocki <[email protected]>
  • Loading branch information
s4ddly and Adam Wysocki authored Oct 14, 2024
1 parent 7b01d6c commit cc6eff3
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 8 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.7.4]

### Fixed

- Read more button for payment method
- Excessive records in wp_options table

### Added

- API lang parameter handling

## [1.7.3]

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Contributors: tpay.com \
Tags: tpay, tpay.com, payment, payment gateway, woocommerce \
Tested up to: 6.2.2 \
Stable tag: 1.4 \
Stable tag: 1.7.4 \
Requires PHP: 7.1 or higher \
License: GPLv3 \
Tpay is payment gateway for WooCommerce.
Expand Down
12 changes: 12 additions & 0 deletions _dev/js/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@ import {JSEncrypt} from "jsencrypt";
import $ from "jquery";
import { getCreditCardNameByNumber, isSecurityCodeValid, isExpirationDateValid, isValid as isCardNumberValid } from 'creditcard.js'

$(document).on('click', '.agreement_text_scroller', function (event) {
event.preventDefault();
var fullText = $(this).closest('div').find('p:nth-of-type(2)');

if (fullText.is(":visible")) {
$(this).text($(this).attr('data-more'));
fullText.hide();
} else {
$(this).text($(this).attr('data-less'));
fullText.show();
}
});

$(document).ready(function () {
var $form = $('form.checkout');
Expand Down
1 change: 1 addition & 0 deletions includes/Tpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ public function set_payment_data($order, $channelId)
'hiddenDescription' => $this->crc,
'amount' => $order->get_total(),
'payer' => $payer_data,
'lang' => tpay_lang(),
'callbacks' => [
'payerUrls' => [
'success' => $this->get_return_url($order),
Expand Down
2 changes: 1 addition & 1 deletion includes/TpayGateways.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ public function set_payment_data($order, $channelId)
'method' => 'pay_by_link',
],
'payer' => $payer_data,
'lang' => tpay_lang(),
'callbacks' => [
'payerUrls' => [
'success' => $this->get_return_url($order),
Expand Down Expand Up @@ -476,7 +477,6 @@ public function process_refund($order_id, $amount = null, $reason = ''): bool
public function gateway_ipn()
{
$body = $_POST;
update_option('tpay_IPN'.time(), print_r($body, true));
Ipn\IpnContext::chooseStrategy($body);
wp_die();
}
Expand Down
1 change: 1 addition & 0 deletions includes/TpayGeneric.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public function set_payment_data($order, $channelId)
'hiddenDescription' => $this->crc,
'amount' => $order->get_total(),
'payer' => $payer_data,
'lang' => tpay_lang(),
'callbacks' => [
'payerUrls' => [
'success' => $this->get_return_url($order),
Expand Down
17 changes: 15 additions & 2 deletions tpay-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,13 @@ function buildInfo(): string

function enqueue_tpay_gateway_assets()
{
$asset = require plugin_dir_path(__FILE__) . 'views/assets/installments-blocks.min.asset.php';

wp_register_script(
'tpay_gateway_js',
plugin_dir_url(__FILE__) . 'views/assets/main.min.js',
[],
time(),
$asset['dependencies'],
$asset['version'],
true
);
wp_localize_script('tpay_gateway_js', 'tpay', [
Expand Down Expand Up @@ -231,3 +233,14 @@ function tpay_blik0_transaction_status()

wp_send_json($result);
}

function tpay_lang(): string
{
$locale = explode('_', get_locale());

if (false === in_array($locale[0], ['pl', 'en', 'uk'])) {
return 'en';
}

return $locale[0];
}
4 changes: 2 additions & 2 deletions tpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Tpay Payment Gateway
* Plugin URI: https://tpay.com
* Description: Tpay payment gateway for WooCommerce
* Version: 1.7.3
* Version: 1.7.4
* Author: Krajowy Integrator Płatności S.A.
* Author URI: http://www.tpay.com
* License: LGPL 3.0
Expand Down Expand Up @@ -42,7 +42,7 @@

require_once 'tpay-functions.php';

define('TPAY_PLUGIN_VERSION', '1.7.3');
define('TPAY_PLUGIN_VERSION', '1.7.4');
define('TPAY_PLUGIN_DIR', dirname(plugin_basename(__FILE__)));
add_action('plugins_loaded', 'init_gateway_tpay');
register_activation_hook(__FILE__, 'tpay_on_activate');
Expand Down
2 changes: 1 addition & 1 deletion views/assets/main.min.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('jquery'), 'version' => '224a87c1d74803009269');
<?php return array('dependencies' => array('jquery'), 'version' => '9d0396b0ee6863572de1');
2 changes: 1 addition & 1 deletion views/assets/main.min.js

Large diffs are not rendered by default.

0 comments on commit cc6eff3

Please sign in to comment.