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

Callback to handle HPP response + HPP_VERSION 2 #5

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

simonflk
Copy link

@simonflk simonflk commented Aug 17, 2016

I have a need for a more bespoke solution for hosted payments than your SDK currently provides.

This PR adds the following features by adding an addition function, setup() (naming isn't one of my strengths 😄)

  • Accepts a callback
    • Allows custom submission of HPP response to merchant server (e.g. using XHR, setting headers, or combining it with other data)
    • Allows the JS code to know something of what happened (e.g. HPP response received, or user closed lightbox without paying) and act accordingly
  • Doesn't automatically add event listener
    • Offers more flexibility, and works better where the DOM is dynamic, or when using frameworks such as React
  • Adds cleanup function to remove message listener, so rxp-js can be used multiple times in an app lifecycle without leaking

In doing this, I've done some small refactoring, to allow me to reuse functions, and also added UMD, so it can be more easily used with build tools such as webpack & browserify.

I was going to add unit tests for rx-hpp.js, but I found this very difficult to test because of the tight-coupling with the DOM, and the fact that the RxpLightbox is private, and therefore impossible to mock.

* You can handle lightbox initiation yourself
* Handle hpp response manually via callback instead of fire & forget post to merchant url
* UMD-ify the modules, for use with webpack/browserify/etc
+ Strip `null` from hpp json
+ normalise whitespace
+ add index.js entry point for npm
At some display resolutions, changes in iframe contents (e.g. validation errors/scrollbars), can receive multiple resize messages getting taller & narrower, until it's 0px wide
@simonflk simonflk changed the title Add support for callback to handle HPP response Callback to handle HPP response + HPP_VERSION 2 Sep 15, 2017
@marcfielding1
Copy link

Shame this isn't merged I really wanna use this.

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