Skip to content

Commit

Permalink
Merge pull request #179 from wordpress-parsi/5.0.1
Browse files Browse the repository at this point in the history
Incompleted PR
  • Loading branch information
hamidrezayazdani authored Mar 12, 2024
2 parents 12085e6 + eda7766 commit 7ab7b9a
Show file tree
Hide file tree
Showing 16 changed files with 1,734 additions and 128 deletions.
19 changes: 19 additions & 0 deletions assets/js/wc-pg-blocks/wpp-wc-mellat-pg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const wppMellatPG_data = window.wc.wcSettings.getSetting( 'mellat_data', {} );
const wppMellatPG_label = window.wp.htmlEntities.decodeEntities( wppMellatPG_data.title )
|| window.wp.i18n.__( 'Mellat Bank', 'wp-parsidate' );
const wppMellatPG_content = ( wppMellatPG_data ) => {
return window.wp.htmlEntities.decodeEntities( wppMellatPG_data.description );
};
const wppMellatPG = {
name: 'mellat',
label: wppMellatPG_label,
content: Object( window.wp.element.createElement )( wppMellatPG_content, null ),
edit: Object( window.wp.element.createElement )( wppMellatPG_content, null ),
canMakePayment: () => true,
placeOrderButtonLabel: window.wp.i18n.__( 'Continue', 'wp-parsidate' ),
ariaLabel: wppMellatPG_label,
supports: {
features: wppMellatPG_data.supports,
},
};
window.wc.wcBlocksRegistry.registerPaymentMethod( wppMellatPG );
1 change: 1 addition & 0 deletions assets/js/wc-pg-blocks/wpp-wc-mellat-pg.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions assets/js/wc-pg-blocks/wpp-wc-parsian-pg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const wppParsianPG_data = window.wc.wcSettings.getSetting( 'parsian_data', {} );
const wppParsianPG_label = window.wp.htmlEntities.decodeEntities( wppParsianPG_data.title )
|| window.wp.i18n.__( 'Parsian Bank', 'wp-parsidate' );
const wppParsianPG_content = ( wppParsianPG_data ) => {
return window.wp.htmlEntities.decodeEntities( wppParsianPG_data.description );
};
const wppParsianPG = {
name: 'parsian',
label: wppParsianPG_label,
content: Object( window.wp.element.createElement )( wppParsianPG_content, null ),
edit: Object( window.wp.element.createElement )( wppParsianPG_content, null ),
canMakePayment: () => true,
placeOrderButtonLabel: window.wp.i18n.__( 'Continue', 'wp-parsidate' ),
ariaLabel: wppParsianPG_label,
supports: {
features: wppParsianPG_data.supports,
},
};
window.wc.wcBlocksRegistry.registerPaymentMethod( wppParsianPG );
1 change: 1 addition & 0 deletions assets/js/wc-pg-blocks/wpp-wc-parsian-pg.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions assets/js/wc-pg-blocks/wpp-wc-pasargad-pg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const wppPasargadPG_data = window.wc.wcSettings.getSetting( 'pasargad_data', {} );
const wppPasargadPG_label = window.wp.htmlEntities.decodeEntities( wppPasargadPG_data.title )
|| window.wp.i18n.__( 'Pasargad Bank', 'wp-parsidate' );
const wppPasargadPG_content = ( wppPasargadPG_data ) => {
return window.wp.htmlEntities.decodeEntities( wppPasargadPG_data.description );
};
const wppPasargadPG = {
name: 'pasargad',
label: wppPasargadPG_label,
content: Object( window.wp.element.createElement )( wppPasargadPG_content, null ),
edit: Object( window.wp.element.createElement )( wppPasargadPG_content, null ),
canMakePayment: () => true,
placeOrderButtonLabel: window.wp.i18n.__( 'Continue', 'wp-parsidate' ),
ariaLabel: wppPasargadPG_label,
supports: {
features: wppPasargadPG_data.supports,
},
};
window.wc.wcBlocksRegistry.registerPaymentMethod( wppPasargadPG );
1 change: 1 addition & 0 deletions assets/js/wc-pg-blocks/wpp-wc-pasargad-pg.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

81 changes: 81 additions & 0 deletions includes/plugins/wc-gateways/blocks/wpp-mellat-pg-block.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php

defined( 'ABSPATH' ) or exit( 'No direct script access allowed' );

use Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType;

if ( ! class_exists( 'WPP_WC_Mellat_Gateway_Blocks' ) ) {
final class WPP_WC_Mellat_Gateway_Blocks extends AbstractPaymentMethodType {

private $gateway;

/**
* Payment method name/id/slug.
*
* @var string
*/
protected $name = 'mellat';


/**
* Initializes the payment method type.
*/
public function initialize() {
$class_name = get_class( $this );
$this->settings = get_option( "woocommerce_{$this->name}_settings", [] );
$this->gateway = new $class_name;
}

/**
* Returns if this payment method should be active. If false, the scripts will not be enqueued.
*
* @return boolean
*/
public function is_active() {
return filter_var( $this->get_setting( 'enabled', true ), FILTER_VALIDATE_BOOLEAN );
}

/**
* Returns an array of scripts/handles to be registered for this payment method.
*
* @return array
*/
public function get_payment_method_script_handles() {
$script_id = "wpp-wc-$this->name-blocks-integration";
$script_name = "wpp-wc-$this->name-pg.js";

wp_register_script(
$script_id,
WP_PARSI_URL . "assets/js/wc-pg-blocks/$script_name",
array(
'wc-blocks-registry',
'wc-settings',
'wp-element',
'wp-html-entities',
'wp-i18n',
),
false,
true
);

if ( function_exists( 'wp_set_script_translations' ) ) {
wp_set_script_translations( $script_id, 'wp-parsidate', WP_PARSI_DIR . 'languages/' );
}

return array( $script_id );
}

/**
* Returns an array of key=>value pairs of data made available to the payment methods script.
*
* @return array
*/
public function get_payment_method_data() {
return array(
'title' => $this->get_setting( 'title' ),
'description' => $this->get_setting( 'description' ),
'supports' => $this->get_supported_features(),
);
}
}
}
83 changes: 83 additions & 0 deletions includes/plugins/wc-gateways/blocks/wpp-parsian-pg-block.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php

defined( 'ABSPATH' ) or exit( 'No direct script access allowed' );

use Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType;

if ( ! class_exists( 'WPP_WC_Parsian_Gateway_Blocks' ) ) {
final class WPP_WC_Parsian_Gateway_Blocks extends AbstractPaymentMethodType {

private $gateway;

/**
* Payment method name/id/slug.
*
* @var string
*/
protected $name = 'parsian';


/**
* Initializes the payment method type.
*/
public function initialize() {
$class_name = get_class( $this );
$this->settings = get_option( "woocommerce_{$this->name}_settings", [] );
$this->gateway = new $class_name;
}

/**
* Returns if this payment method should be active. If false, the scripts will not be enqueued.
*
* @return boolean
*/
public function is_active() {
return filter_var( $this->get_setting( 'enabled', true ), FILTER_VALIDATE_BOOLEAN );
}

/**
* Returns an array of scripts/handles to be registered for this payment method.
*
* @return array
*/
public function get_payment_method_script_handles() {
$script_id = "wpp-wc-$this->name-blocks-integration";
$script_name = "wpp-wc-$this->name-pg";
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG || wpp_is_active( 'dev_mode' ) ? '' : '.min';


wp_register_script(
$script_id,
WP_PARSI_URL . "assets/js/wc-pg-blocks/$script_name$suffix.js",
array(
'wc-blocks-registry',
'wc-settings',
'wp-element',
'wp-html-entities',
'wp-i18n',
),
false,
true
);

if ( function_exists( 'wp_set_script_translations' ) ) {
wp_set_script_translations( $script_id, 'wp-parsidate', WP_PARSI_DIR . 'languages/' );
}

return array( $script_id );
}

/**
* Returns an array of key=>value pairs of data made available to the payment methods script.
*
* @return array
*/
public function get_payment_method_data() {
return array(
'title' => $this->get_setting( 'title' ),
'description' => $this->get_setting( 'description' ),
'supports' => $this->get_supported_features(),
);
}
}
}
81 changes: 81 additions & 0 deletions includes/plugins/wc-gateways/blocks/wpp-pasargad-pg-block.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php

defined( 'ABSPATH' ) or exit( 'No direct script access allowed' );

use Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType;

if ( ! class_exists( 'WPP_WC_Pasargad_Gateway_Blocks' ) ) {
final class WPP_WC_Pasargad_Gateway_Blocks extends AbstractPaymentMethodType {

private $gateway;

/**
* Payment method name/id/slug.
*
* @var string
*/
protected $name = 'pasargad';


/**
* Initializes the payment method type.
*/
public function initialize() {
$class_name = get_class( $this );
$this->settings = get_option( "woocommerce_{$this->name}_settings", [] );
$this->gateway = new $class_name;
}

/**
* Returns if this payment method should be active. If false, the scripts will not be enqueued.
*
* @return boolean
*/
public function is_active() {
return filter_var( $this->get_setting( 'enabled', true ), FILTER_VALIDATE_BOOLEAN );
}

/**
* Returns an array of scripts/handles to be registered for this payment method.
*
* @return array
*/
public function get_payment_method_script_handles() {
$script_id = "wpp-wc-$this->name-blocks-integration";
$script_name = "wpp-wc-$this->name-pg.js";

wp_register_script(
$script_id,
WP_PARSI_URL . "assets/js/wc-pg-blocks/$script_name",
array(
'wc-blocks-registry',
'wc-settings',
'wp-element',
'wp-html-entities',
'wp-i18n',
),
false,
true
);

if ( function_exists( 'wp_set_script_translations' ) ) {
wp_set_script_translations( $script_id, 'wp-parsidate', WP_PARSI_DIR . 'languages/' );
}

return array( $script_id );
}

/**
* Returns an array of key=>value pairs of data made available to the payment methods script.
*
* @return array
*/
public function get_payment_method_data() {
return array(
'title' => $this->get_setting( 'title' ),
'description' => $this->get_setting( 'description' ),
'supports' => $this->get_supported_features(),
);
}
}
}
3 changes: 3 additions & 0 deletions includes/plugins/wc-gateways/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

// Silence is golden
Loading

0 comments on commit 7ab7b9a

Please sign in to comment.