Code Monkey home page Code Monkey logo

ot-react-payment's Introduction

WIP: @opentable/react-payment

DO NOT USE: incomplete

React abstraction for payment provider strategies

  • Meant to abstract provider implementation details away from OT react sites
  • Creates a Payment Provider hook and context for use in OT React sites
  • (TODO) Contains clients for OT payment providers

Rationale and history

When integrating Stripe, the code for interacting with that service was tightly coupled with one provider (Stripe) and scattered throughout a few codebases.

Most payment providers use a similar mechanism for handling credit card information. Usually sensitive Credit Card information is only entered into iframes to the Provider's domain, and an obfuscated token is sent back to us for use and storage.

Since this interaction is so similar with different providers, we can wrap it with our own component library and include that in multiple OT sites.

In this way we can abstract implementation of n payment providers away from OT react code.

Anticipated places for use:

  1. consumer-frontend
  2. restref-site
  3. gc-monorepo-admin (OT4R)

Usage

Architecture

sequenceDiagram
	Note left of Consumer: (CFE, R3, OT4R)
	box Purple OpenTable 
		participant Consumer
		participant @opentable/react-payment
	end
    participant Provider 
	Note right of Provider: (Spreedly, Stripe)
    Consumer->>@opentable/react-payment: form with placeholders
    loop iframe content
		@opentable/react-payment->>Provider: inject script, update placeholders with iframes
        Provider->>@opentable/react-payment: payment provider card token & metadata 
    end
    @opentable/react-payment-->>Consumer: <PaymentProviderContext/> w/token & metadata
    @opentable/react-payment-->>Consumer: usePayment hook

TODO: add usages and howto

  • Context
  • Hook
  • Selecting a provider
  • Provider events
  • Adding a provider
  • ?

Install

Artifactory:


Supported providers

Spreedly

So far we have spiked the form/iframe integration works in CFE network flow.

The Spreedly script is included, window.Spreedly exists, and it replaces empty DOM elements with spreedly domain iframe content.

Using a test form hacked into CFE returns a token.

Spike is successful, next steps will be to attempt to integrate this lib with CFE in the network flow.

TODO:

  • Complete transaction with token
  • Other payment flows in CFE
  • Use in other OT react sites

Documentation

Stripe

TODO

Documentation

TODO

ot-react-payment's People

Contributors

scottlepich avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.