Conversation
| <?php echo __( 'Scan the QR code to pay', 'omise' ); ?> | ||
| </p> | ||
| <div class="omise omise-promptpay-qrcode"> | ||
| <img src="<?php echo $qrcode; ?>" alt="Omise QR code ID: <?php echo $charge['source']['scannable_code']['image']['id']; ?>"> |
There was a problem hiding this comment.
Do we need to make accommodations for SVG QRs in, say, Gmail?
There was a problem hiding this comment.
@mayurkathale will work on a SVG->PNG converter. I'm not sure if the PHP library requirements (e.g. ImageMagick/GD) for WooCommerce are similar enough?
There was a problem hiding this comment.
I'm actually trying to go with file-attachment instead. (or in a worse case, just put a link there and let buyer click the link to open the QR code)
There was a problem hiding this comment.
Cool. Can you coordinate with @mayurkathale on the ideal approach?
3a0e5f9 to
dbabbb9
Compare
| <?php echo __( 'Scan the QR code to pay', 'omise' ); ?> | ||
| </p> | ||
| <div class="omise omise-promptpay-qrcode"> | ||
| <img src="<?php echo $qrcode; ?>" alt="Omise QR code ID: <?php echo $charge['source']['scannable_code']['image']['id']; ?>"> |
There was a problem hiding this comment.
@mayurkathale will work on a SVG->PNG converter. I'm not sure if the PHP library requirements (e.g. ImageMagick/GD) for WooCommerce are similar enough?
2d8c305 to
ecca2d1
Compare
| $qrcode = $charge['source']['scannable_code']['image']['download_uri']; | ||
|
|
||
| $expires_datetime = new WC_DateTime( $charge['expires_at'], new DateTimeZone( 'UTC' ) ); | ||
| $expires_datetime->set_utc_offset( wc_timezone_offset() ); |
There was a problem hiding this comment.
Note: there is a timezone-offset configuration in WordPress itself. This part is to make sure that the plugin will set the time according to the WordPress configuration instead of server time/timezone.
| <div id="omise-offline-additional-details" class="omise omise-additional-payment-details-box omise-promptpay-details" <?php echo 'email' === $context ? 'style="margin-bottom: 4em; text-align:center;"' : ''; ?>> | ||
| <p><?php echo __( 'Scan the QR code to pay', 'omise' ); ?></p> | ||
| <div class="omise omise-promptpay-qrcode"> | ||
| <img style="margin: 0 auto;" src="<?php echo $qrcode; ?>" alt="Omise QR code ID: <?php echo $charge['source']['scannable_code']['image']['id']; ?>"> |
There was a problem hiding this comment.
Note: Test-mode and Live-mode will give a different format of QR code picture (png and svg). However, there should be no problem to display in img element.
|
|
||
| <div id="omise-offline-payment-result" class="omise-additional-payment-details-box" style="display: none;"></div> | ||
|
|
||
| <script> |
There was a problem hiding this comment.
Note: this Javascript might need to be relocated to another file in the future once the same solution gets applied to PayNow payment method (or it may not possible, still testing the idea – however, it will be out of scope from PromptPay so I skip it)
| public function register_ajax_actions() { | ||
| add_action('wp_ajax_nopriv_fetch_order_status', 'Omise_Ajax_Actions::fetch_order_status' ); | ||
| add_action('wp_ajax_fetch_order_status', 'Omise_Ajax_Actions::fetch_order_status' ); | ||
| } |
There was a problem hiding this comment.
https://developer.wordpress.org/reference/hooks/wp_ajax_nopriv__requestaction/
According to WordPress documents, wp_ajax_nopriv_* is needed for those non-authenticated Ajax actions for logged-out users. We need to hook 2 actions here to be able to implement the Ajax polling to keep tracking order-status at the Thank-you page.
| <p><a href="<?php echo $qrcode; ?>"><?php echo __( 'Click this link to display the QR code', 'omise' ); ?></a></p> | ||
| <?php endif; | ||
| } | ||
| } |
There was a problem hiding this comment.
I'm not strong at Javascript. If there is any suggestion to improve or to make the code more effective, please feel free to let me know 🙇
dac1b67 to
a9aa879
Compare
| $expires_datetime = new WC_DateTime( $charge['expires_at'], new DateTimeZone( 'UTC' ) ); | ||
| $expires_datetime->set_utc_offset( wc_timezone_offset() ); | ||
|
|
||
| if ( 'view' === $context ) : ?> |
There was a problem hiding this comment.
All of the inline CSS in the If block can be moved to omise-css.css file.
There was a problem hiding this comment.
Can I move this one to another PR?
I have a plan to revise the CSS classes to make all the shared-styles to be more in generic name but it will require to touch multiple files that out of scope from PromptPay implementation (planning to group those styles that are currently using with Offline additional information).
| }); | ||
| })(jQuery); | ||
| </script> | ||
| <?php elseif ( 'email' === $context ) : ?> |
There was a problem hiding this comment.
This part should be excluded in "Order failed" emails which usually gets send after failed charge creation.
There was a problem hiding this comment.
This part of the code will be triggered only when the charge is successfully created and user redirects to the thank-you page (or did you get another different result?)
|
Thanks! @mayurkathale |

1. Objective
This pull request is introducing PromptPay payment method to Omise-WooCommerce plugin.
Related information:
Related issue(s): T22500 (internal ticket)
2. Description of change
Alongs with the QR code expiry date.
on-holdthen the plugin will stop Ajax-polling request to save the computer resource and display a 'refresh' button to allow buyer to fetch a payment status manually instead.order-confirmationemail.3. Quality assurance
🔧 Environments:
✏️ Details:
There are 2 aspects that we want to test for this pull request, "merchant's perspective" and "buyer's perspective".
All the tests in this section will be separated into 2 situations as mentioned.
Setting up:
Omise > Settings. You will see the PromptPay payment method is listed at the Available Payment Methods table. Click configEnable Omise PromptPay Paymentand click Save changesPlacing Order:
As a buyer:
Once the payment method has been set and enabled. Buyers will be able to placing order using PromptPay payment method at the checkout page.

After selecting PromptPay as a payment method, PromptPay QR code will be displayed at the WooCommerce Order-Confirmation page (thank-you page), along with the QR code expiry date.

As well, there will be an email sent to buyer's billing email.

At this point, user may scan the QR code to pay.
As a merchant:
Once buyers make placed an order using PromptPay payment method, a new order with
on-holdstatus will be created on WooCommerce.Complete the payment
As a buyer:
Once the buyer paid for the payment, if payment is successful, there will be a successful payment message appear on the screen.

Once the buyer paid for the payment, if payment is failed, there will be a failure payment message appear on the screen.

In case if buyer didn't complete the transaction within 10 minutes, there will be a button refresh status appeared on the screen (this means that the AJAX polling has been terminated. Buyer can click this button to reactivate the AJAX script).

As a merchant:
In case of payment successful, the order status will be updated to
processing.In case of payment successful, the order status will be updated to
failed.4. Impact of the change
None
5. Priority of change
Normal
6. Additional Notes
Nothing.