Skip to content
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

feat(iframe): add frame messaging for paysg #7979

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

KenLSM
Copy link
Contributor

@KenLSM KenLSM commented Dec 6, 2024

Problem

PaySG aims to integrate FormSG within an IFrame to facilitate payment creation. There's a need for real-time communication from FormSG to PaySG regarding form state changes, such as:

  • When a user is in the process of submitting a form
  • When a form has been successfully submitted

See #7978 for original PR

Solution

Implement window.parent.postMessage(message, origin) to enable communication from FormSG (child frame) to PaySG (parent window).

To maintain security:

  • Implement a whitelist of authorized domains (PaySG domains for different environments)
  • Only post messages to whitelisted domains

Implementation Details

  1. Create a whitelist of authorized PaySG domains
  2. Implement message posting for Storage Forms when form state changes during submission and error
  3. Ensure messages are only sent to whitelisted domains

Testing needed to ensure that the message is posted. This is a regression to ensure that Iframe message posting is not removed accidentally.

Breaking Changes

  • No - this PR is backwards compatible

Tests

Regression

Payment form can be submitted

  • Create a payment form
  • As a respondent fill up the payment section
  • Ensure that payment form can be successfully submitted

@KenLSM KenLSM changed the title External/zeke/iframe feat(iframe): add frame messaging for paysg Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants