-
Notifications
You must be signed in to change notification settings - Fork 1
Implement Woo Payment Gateway #116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
xecdev
wants to merge
17
commits into
master
Choose a base branch
from
feat/implement-woo-payment-gateway
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
1082131
Need refactoring for WC
c31505c
Initial Woo + PayButton integration with blocks support
f82853e
Add 'Payment Confirmed' message
591403e
Add HPOS Compatibilty for WC
6a19c4c
Render PayButton metadata in WooCommerce Order Edit screen and misc r…
0916767
Improve Payment Sucess CSS
b940d62
Improve styling and PayButton size
0066e45
Add Wallet Address Validation to Woo Settings and change validation r…
8940a3d
Add the eCash logo to the PayButton Gateway in the checkout page
c2b2191
Added 'Enable/disable Sticky Header', seprate the verification overla…
a289db4
Fixed the PluginCheck errors
7c24eec
Responding to CodeRabbit's feedback
425d5d0
Responding to the bots feedback
3ad7ebe
Enable the WooCommerce Payments button
6959652
Fix the wallet address validation bug
1b4dd53
Fix typo
a4ef747
Check if Woo is installed
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 hidden or 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,76 @@ | ||
| /** | ||
| * WooCommerce PayButton Blocks Integration JS | ||
| */ | ||
| (function( wc, wp ) { | ||
| const { registerPaymentMethod } = wc.wcBlocksRegistry; | ||
| const { getSetting } = wc.wcSettings; | ||
| const { decodeEntities } = wp.htmlEntities; | ||
| const { createElement } = wp.element; | ||
|
|
||
| const settings = getSetting( 'paybutton_data', {} ); | ||
|
|
||
| const labelText = decodeEntities( settings.title || 'PayButton' ); | ||
|
|
||
| // Create a Custom Label Component (Dual Icons) | ||
| const LabelIconOnly = () => { | ||
| return createElement( | ||
| 'span', | ||
| { | ||
| style: { | ||
| display: 'flex', | ||
| alignItems: 'center', | ||
| width: '100%', | ||
| } | ||
| }, | ||
| // 1. The PayButton Image | ||
| settings.icon ? createElement( 'img', { | ||
| src: settings.icon, | ||
| alt: labelText, | ||
| style: { | ||
| maxHeight: '30px', | ||
| objectFit: 'contain' | ||
| } | ||
| } ) : null, | ||
|
|
||
| // 2. The Pipeline Separator (Only shows if BOTH icons exist) | ||
| (settings.icon && settings.icon2) ? createElement( 'span', { | ||
| style: { | ||
| margin: '0 10px', // Spacing around the pipe | ||
| color: '#ccc', // Light gray color | ||
| fontSize: '24px', // Size of the pipe | ||
| lineHeight: '1', | ||
| fontWeight: '300' | ||
| } | ||
| }, '|' ) : null, | ||
|
|
||
| // 3. The eCash Image | ||
| settings.icon2 ? createElement( 'img', { | ||
| src: settings.icon2, | ||
| alt: 'eCash', | ||
| style: { | ||
| maxHeight: '24px', | ||
| objectFit: 'contain' | ||
| } | ||
| } ) : null, | ||
|
|
||
| // 4. Fallback: If no icons are found, show text | ||
| (!settings.icon && !settings.icon2) ? createElement( 'span', null, labelText ) : null | ||
| ); | ||
| }; | ||
|
|
||
| const Content = () => { | ||
| return createElement( 'div', null, decodeEntities( settings.description || '' ) ); | ||
| }; | ||
|
|
||
| registerPaymentMethod( { | ||
| name: 'paybutton', | ||
| label: createElement( LabelIconOnly ), | ||
| content: createElement( Content ), | ||
| edit: createElement( Content ), | ||
| canMakePayment: () => true, | ||
| ariaLabel: labelText, | ||
| supports: { | ||
| features: settings.supports, | ||
| }, | ||
| } ); | ||
| })( window.wc, window.wp ); |
This file contains hidden or 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 hidden or 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,57 @@ | ||
| /** | ||
| * WooCommerce PayButton Integration JS | ||
| */ | ||
| jQuery(document).ready(function($) { | ||
| $('.paybutton-woo-container').each(function() { | ||
| var $container = $(this); | ||
| var configData = $container.data('config'); | ||
|
|
||
| if (typeof configData === 'string') { | ||
| try { configData = JSON.parse(configData); } | ||
| catch (e) { return; } | ||
| } | ||
|
|
||
| let paymentInitiated = false; | ||
|
|
||
| function showOverlay(msg) { | ||
| const el = document.getElementById('paybutton_overlay'); | ||
| if (el) { | ||
| document.getElementById('paybutton_overlay_text').innerText = msg; | ||
| el.style.display = 'block'; | ||
| } | ||
| } | ||
|
|
||
| function pollOrderStatus() { | ||
| setInterval(function() { | ||
| $.ajax({ | ||
| url: PaywallAjax.ajaxUrl, | ||
| method: 'POST', | ||
| data: { | ||
| action: 'paybutton_check_order_status', | ||
| security: PaywallAjax.nonce, | ||
| order_id: configData.opReturn | ||
| }, | ||
| success: function(response) { | ||
| if (response.success) { | ||
| // Success! Reload to hide button and show receipt | ||
| location.reload(); | ||
| } | ||
| } | ||
| }); | ||
| }, 3000); | ||
| } | ||
|
|
||
| PayButton.render($container[0], { | ||
| ...configData, | ||
| onSuccess: function(tx) { | ||
| paymentInitiated = true; | ||
| pollOrderStatus(); | ||
| }, | ||
| onClose: function() { | ||
| if (paymentInitiated) { | ||
| showOverlay("Verifying Payment..."); | ||
| } | ||
| } | ||
| }); | ||
| }); | ||
| }); | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.