0.11.7 • Published 3 years ago

plug-pag-service-pdv365 v0.11.7

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

plug-pag-service-pdv365

React Native Plug Pag Service PDV365

Esta biblioteca destina-se a integradores que utilizarão os terminais da linha Smart do PagSeguro como solução de pagamento integrada através do serviço PlugPagService.

"react-native": ">=0.63.4 <0.59.0"

Instalação

plug-pag-service-pdv365 requer Node.js ou Yarn.

Instale a dependências.

npm install plug-pag-service-pdv365 ou yarn add npm plug-pag-service-pdv365

Importação

import PlugPagService from 'plug-pag-service-pdv365';

Exemplos

Número de série:

function handleGetSerialNumber() {
	PlugPagService.getSerialNumber().then(
		(initResult) => {
			console.log('success', initResult);
		},
		(error) => {
			console.error('error', error.message);
		}
	);
}

Identificação de aplicativo:

function handleSetAppIdendification() {
	PlugPagService.setAppIdendification('RNPAGA', '1.0');
}

Evento Listener:

const eventPaymentsManagerEmitter = new NativeEventEmitter(PlugPagService);
const event = eventPaymentsManagerEmitter.addListener('eventPayments', (reminder) => console.log(reminder));

Inicializar e ativar o Pin pad:

function handleInitializeAndActivatePinpad() {
	handleSetAppIdendification();
	PlugPagService.initializeAndActivatePinpad('codigo_ativação').then(
		(initResult) => {
			if (initResult.retCode === PlugPagService.RET_OK) {
				// Define os dados do pagamento
				const paymentData = {
					amount: 19 * 100, //VALOR
					installmentType: 1, //A VISTA OU PARCELADO
					installments: 1, //PARCELAS
					type: 1, //TIPO DEBITO OU CREDITO OU VOUCHER
					userReference: 'PAGAMENTO', //REFERENCIA
					printReceipt: false, //IMPRIMIR RECIBO
				};
				PlugPagService.doPayment(JSON.stringify(paymentData)).then(
					(initResult) => {
						console.log('SUCESSO', initResult);
					},
					(error) => {
						console.error('ERRO', error);
					}
				);
			}
		},
		(error) => {
			console.error('ERROR', error);
		}
	);
}