-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
96 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
use Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType; | ||
|
||
final class WC_Razorpay_Blocks extends AbstractPaymentMethodType | ||
{ | ||
protected $name = 'razorpay'; | ||
|
||
public function initialize() | ||
{ | ||
$this->settings = get_option('woocommerce_razorpay_settings', []); | ||
} | ||
|
||
public function get_payment_method_script_handles() | ||
{ | ||
wp_register_script( | ||
'razorpay-blocks-integration', | ||
plugin_dir_url(__FILE__) . 'checkout_block.js', | ||
[ | ||
'wc-blocks-registry', | ||
'wc-settings', | ||
'wp-element', | ||
'wp-html-entities', | ||
'wp-i18n', | ||
], | ||
null, | ||
true | ||
); | ||
|
||
if (function_exists('wp_set_script_translations')) | ||
{ | ||
wp_set_script_translations('razorpay-blocks-integration'); | ||
} | ||
|
||
return ['razorpay-blocks-integration']; | ||
} | ||
|
||
public function get_payment_method_data() | ||
{ | ||
return [ | ||
'title' => 'Pay by Razorpay', | ||
'description' => $this->settings['description'], | ||
]; | ||
} | ||
} |
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,18 @@ | ||
const settings = window.wc.wcSettings.getSetting('razorpay_data', {}); | ||
const label = window.wp.htmlEntities.decodeEntities(settings.title) || window.wp.i18n.__('Razorpay for woocommerce', 'razorpay'); | ||
const Content = () => { | ||
return window.wp.htmlEntities.decodeEntities(settings.description || ''); | ||
}; | ||
const Block_Gateway = { | ||
name: 'razorpay', | ||
label: label, | ||
content: Object(window.wp.element.createElement)(Content, null ), | ||
edit: Object(window.wp.element.createElement)(Content, null ), | ||
canMakePayment: () => true, | ||
ariaLabel: label, | ||
supports: { | ||
features: settings.supports, | ||
}, | ||
}; | ||
window.wc.wcBlocksRegistry.registerPaymentMethod( Block_Gateway ); | ||
|
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