-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from iamsayan/develop
added v1.2.0
- Loading branch information
Showing
14 changed files
with
19,124 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,6 @@ package.json | |
package-lock.json | ||
phpcs.xml | ||
README.md | ||
todo | ||
todo | ||
index.js | ||
webpack.config.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.vscode | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-html-entities'), 'version' => 'cace7ebdfbbb3a43dc17'); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?php | ||
use Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType; | ||
|
||
/** | ||
* Razorpay Payment Links Blocks integration | ||
* | ||
* @since 1.2.0 | ||
*/ | ||
final class RZP_WC_Payment_Gateway_Blocks_Support extends AbstractPaymentMethodType { | ||
|
||
/** | ||
* Payment method name/id/slug. | ||
* | ||
* @var string | ||
*/ | ||
protected $name = 'wc-razorpay'; | ||
|
||
/** | ||
* Initializes the payment method type. | ||
*/ | ||
public function initialize() { | ||
$this->settings = get_option( "woocommerce_{$this->name}_settings", [] ); | ||
} | ||
|
||
/** | ||
* Returns if this payment method should be active. If false, the scripts will not be enqueued. | ||
* | ||
* @return boolean | ||
*/ | ||
public function is_active() { | ||
return ! empty( $this->settings['enabled'] ) && 'yes' === $this->settings['enabled']; | ||
} | ||
|
||
/** | ||
* Returns an array of scripts/handles to be registered for this payment method. | ||
* | ||
* @return array | ||
*/ | ||
public function get_payment_method_script_handles() { | ||
$script_path = 'includes/blocks/assets/blocks.js'; | ||
$script_asset_path = RZPWC_PATH . 'includes/blocks/assets/blocks.asset.php'; | ||
$script_asset = file_exists( $script_asset_path ) | ||
? require( $script_asset_path ) | ||
: array( | ||
'dependencies' => array(), | ||
'version' => RZPWC_VERSION | ||
); | ||
$script_url = RZPWC_URL . $script_path; | ||
|
||
wp_register_script( | ||
'rzpwc-payment-blocks', | ||
$script_url, | ||
$script_asset[ 'dependencies' ], | ||
$script_asset[ 'version' ], | ||
true | ||
); | ||
|
||
if ( function_exists( 'wp_set_script_translations' ) ) { | ||
wp_set_script_translations( 'rzpwc-payment-blocks', 'rzp-woocommerce', RZPWC_PATH . 'languages/' ); | ||
} | ||
|
||
return [ 'rzpwc-payment-blocks' ]; | ||
} | ||
|
||
/** | ||
* 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 [ | ||
'title' => $this->get_setting( 'title' ), | ||
'description' => $this->get_setting( 'description' ), | ||
'supports' => $this->get_supported_features(), | ||
'button_text' => apply_filters( 'upiwc_order_button_text', __( 'Proceed to Payment', 'rzp-woocommerce' ) ), | ||
]; | ||
} | ||
|
||
/** | ||
* Returns an array of supported features. | ||
* | ||
* @return string[] | ||
*/ | ||
public function get_supported_features() { | ||
$gateways = WC()->payment_gateways->get_available_payment_gateways(); | ||
|
||
if ( isset( $gateways[ $this->name ] ) ) { | ||
$gateway = $gateways[ $this->name ]; | ||
|
||
return array_filter( $gateway->supports, [ $gateway, 'supports' ] ); | ||
} | ||
|
||
return []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?php // Silence is golden |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { registerPaymentMethod } from '@woocommerce/blocks-registry'; | ||
import { decodeEntities } from '@wordpress/html-entities'; | ||
import { getSetting } from '@woocommerce/settings'; | ||
|
||
const settings = getSetting( 'wc-razorpay_data', {} ); | ||
const label = decodeEntities( settings.title ) || 'Razorpay Payment Gateway'; | ||
|
||
const Content = () => { | ||
return decodeEntities( settings.description || '' ); | ||
}; | ||
|
||
const Label = ( props ) => { | ||
const { PaymentMethodLabel } = props.components; | ||
return <PaymentMethodLabel text={ label } />; | ||
}; | ||
|
||
const razorpayPaymentLinks = { | ||
name: "wc-razorpay", | ||
label: <Label />, | ||
content: <Content />, | ||
edit: <Content />, | ||
placeOrderButtonLabel: settings?.button_text, | ||
canMakePayment: () => true, | ||
ariaLabel: label, | ||
supports: { | ||
features: settings.supports, | ||
}, | ||
}; | ||
|
||
registerPaymentMethod( razorpayPaymentLinks ); |
Oops, something went wrong.