0.0.7 • Published 5 years ago

payment-module v0.0.7

Weekly downloads
2
License
ISC
Repository
github
Last release
5 years ago

payment-integration base module

this can be used as a base package which provide abstract method for your payment system and different payment modules can be build on top of this.

Installation

# npm package manager
npm install payment-module --save
# yarn package manager
yarn add payment-module

Usuage

import Payment from 'payment-module'

const paymentData = {
	mode: 'stripe',
	paymentData: {
		token: 'stripe-dev-token123'
	},
}

class StripePayment extends Payment {
	constructor(paymentData) {
		super(paymentData)
	}

	authorize = () => {
		const { token } = this.getPaymentData().paymentData
		if (token) {
			return true
		}
		return false
	}

	create = () => {
		const paymentData = this.getPaymentData()
		const mockCallback = jest.fn((token: string) => {
			if (token) {
				return {
					paid: true,
					"transid": "12345"
				}
			}
			return {
				paid: false,
				"transid": null
			}
		})
		const token = paymentData.paymentData.token ? paymentData.paymentData.token : ''
		const data = mockCallback(token);
		if (data.paid) {
			return true;
		}
		return false
	}
}

// replace jest.fn mock with actual payment api module payment
const payment = new StripePayment(paymentData)
0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago

1.0.0

5 years ago

0.1.0

7 years ago