0.4.2 • Published 4 years ago

pagos24 v0.4.2

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

pagos24

pagos24 is the Javascript / Typescript library so you can make payments and use Pagos24 services. This library has all the necessary tools for your application to use our services.

Table of Contents

  1. Installation
  2. Usage
  3. Login User
  4. Connect User
  5. Payment
  6. QR Code
  7. Log Out
  8. Contributing

Installation

    npm install pagos24 --save

or

    yarn add pagos24

Usage

The library is initialized where the application is initialized

import { Auth, ELanguageType } from "pagos24";

Auth.init({
    token: "tokenExample",
    appId: "apiExample",
    email: "example@example.com",
    secretKey: "exampleKey",
    sandbox: true,
    projectUrl: "Project example",
    lang: ELanguageType.EnUs
})
.then((result) => ...)
.catch((err) => ...);
ParameterDescription
tokenToken generated in the account settings on the website
appIdSelf-generated on the website
emailEmail with which you login to the pagos24 application
secretKeySecret key generated by the user in the application or web page
projectUrlName of the project that will integrate the pagos24 module
sandboxSpecifies if the library is in test or production mode (Recommended to use true if the library is being tested)
langLanguage to be handled within the library

This function will return the currently logged user, as long as there is one, otherwise it will return undefined

Login User

To be able to use a user's data, you must first log in. This is possible with the following function:

import { Auth, ELanguageType } from "pagos24";

Auth.logIn(ELanguageType.EnUs, ELoginMode.Window)
.then((result) => ...)
.catch((err) => ...);
Parameterdescriptiontype
languageLanguage in which the window will be opened (required)ELanguageType.enUS (english) ELanguageType.esVE (spanish) ELanguageType.ptBR (portuguese)
modeLogin opening modeELoginMode.Window ELoginMode.Redirect
redirectUrlUrl to which the login will be directed after logging in a user (optional)string

If you are integrating the library with a framework like Ionic, the login is different, of course, the results will be the same, it would be done in the following way:

import { AuthIonic, ELanguageType } from "pagos24";

AuthIonic.logIn('com.example://', ELanguageType.EnUs)
.then((result) => ...)
.catch((err) => ...);
ParameterDescriptiontype
urlSchemeUrl schema of the application (usually the ID of the application)string
languageApp languageELanguageType.enUS (english) ELanguageType.esVE (spanish) ELanguageType.ptBR (portuguese)

The process is simple, when trying to log in, the library will search your device to see if the Pagos24 application is installed, if it is installed the application will open, otherwise it will give an error.

Like the normal login, if there is already a logged in user, it will not redirect to the other application but the data will be delivered directly.

If there is any doubt about the url scheme this link can help you to configure it Setting url schema

Connect User

To obtain the credit cards affiliated with a Pagos24 user, you must connect with him as follows:

import { Payment } from 'pagos24';

Payment.connectUser(user)
.then((resp) => ...)
.catch((err) => ...);

It is recommended to use this function just after logging in with a user

Parameterdescriptiontype
userUser from whom the data will be obtainedIUserConnect
interface IUserConnect {
  avatar: string;
  email: string;
  error: number;
  fullname: string;
  lang: ELanguageType;
  qr: string;
  user_id: string;
}

Payment

There are mainly three methods to make a payment through Pagos24: With a credit card (affiliated with Pagos24), by points and by Pagos24 balance. The way to use the payment function is as follows:

import { Payment, EpaymentType, ELanguageType } from "pagos24";

Payment.payment(EpaymentType.BinCash, {
    OTPago: '012345',
    amount: 100,
    language: ELanguageType.EnUs,
    payerEmail: "example@example.com",
})
.then(result => ...)
.catch(err  => ...);
ParameterDescriptiontype
paymentTypeThe type of payment that will be made through Pagos24 (required)EpaymentType.BinCash EpaymentType.CreditCard EpaymentType.Points
paymentParamsThe parameters required to make a payment (required)IPaymentParams
// Params interface
interface IPaymentParams {
  payerEmail: string;
  amount: number;
  OTPago: number;
  language: ELanguageType;
  creditCardNumber?: string;
}
ParameterDescriptiontype
payerEmailEmail of the user who is going to pay (required)string
amountAmount to be paid by the user (required)number
pinUser payment pin (required)number
languageUser language (required)ELanguageType.enUS ELanguageType.esVE ELanguageType.ptBR
creditCardNumberRequired to pay by credit card, data that comes when connecting with the user. Required when paying by credit card (opcional)string

QR Code

There is the possibility of paying through the Pagos24 mobile application by reading a QR code. With the library you can also show that code and give the possibility of paying more easily

Controller.ts:

import { Payment } from "pagos24";

Payment.generateQRCode(100)
.then((uriExample) => ...)
.catch((err) => ...);

Template.html:

<img src="uriExample" />
ParameterDescriptiontype
paymentAmountAmount to be paidnumber

The function will return a base64 uri with the QR code that must be placed in the img tag within the template.

Log Out

There is a function to log out the current user

import {Auth} from 'pagos24';

function logOut() {
  Auth.logOut();
}

This function will erase the current user data

Contributing

Extraction requests are welcome. For major changes, first open a problem to discuss what you would like to change

License

MIT

0.4.2

4 years ago

0.4.1

4 years ago

0.3.9

4 years ago

0.3.8

4 years ago

0.3.6

4 years ago

0.3.7

4 years ago

0.3.5

4 years ago

0.3.4

4 years ago

0.2.6

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.3.3

4 years ago

0.2.5

4 years ago

0.2.1

4 years ago

0.1.17

4 years ago

0.1.18

4 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.2.4

4 years ago

0.1.15

4 years ago

0.1.16

4 years ago

0.1.14

4 years ago

0.1.10

4 years ago

0.1.11

4 years ago

0.1.12

4 years ago

0.1.13

4 years ago

0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

1.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago