maxipago-gateway-sdk
v2.1.1
Published
Javascript lib for MaxiPago Gateway
Downloads
196
Readme
MaxiPago - Gateway SDK
This JavaScript library interfaces with the MaxiPago API.
Key functionalities of this library include:
- Accepting API requests in JSON format.
- Converting those requests to XML and communicating with the MaxiPago API.
- Returning the API response, transformed back into JSON format.
npm
yarn
pnpm
Import
To get started, import the maxipago-gateway-sdk
into your project:
import maxipago from 'maxipago-gateway-sdk'
Build the gateway
Use this method to create a gateway that enables you to make requests to the MaxiPago API.
Method:
maxipago.Gateway()
Params:
| Name | Description | Required | | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | | merchantId | Your MaxiPago merchant ID | Yes | | merchantKey | Your MaxiPago merchant KEY | Yes | | maxiPagoEnv | MaxiPago enviorement. Use 'development' for testapi.maxipago.net or 'production' for api.maxipago.net | Yes |
Example:
const gateway = new maxipago(
'youmaxipagoid',
'youmaxipagostrongkey',
'development',
)
According to the MaxiPago API Docs, this library has the following mapped functionalities:
This method add your customer on MaxiPago API.
Method:
- .addCustomer(addCustomerJSON)
Params:
- addCustomerJSON = your customer data in JSON format.
Example:
const addCustomerJSON = { customerIdExt: 5358, firstName: 'Kylee Hilpert', lastName: 'Bauch', address1: '42837 Flatley Union', address2: '6749 Hudson Prairie', city: 'Arnostad', state: 'Arizona', zip: '658388059', country: 'PR', phone: '730.900.4976', email: '[email protected]', dob: '06/26/2018', sex: 'M', } const response = await gateway.addCustomer(addCustomerJSON)
This method update previously added customer on MaxiPago API.
Method:
- .updateCustomer(updateCustomerJSON)
Params:
- updateCustomerJSON = your updated customer data in JSON format.
Example:
const updateCustomerJSON = { customerIdExt: 5254, firstName: 'Tatum Goodwin updated', lastName: 'Corwin updated', customerId: '119679', } const response = await gateway.updateCustomer(updateCustomerJSON)
This method delete previously added customer on MaxiPago API.
Method:
- .deleteCustomer(deleteCustomerJSON)
Params:
- deleteCustomerJSON = your updated customer data in JSON format.
Example:
const deleteCustomerJSON = { customerId: '119679' } const response = await gateway.deleteCustomer(deleteCustomerJSON)
This method zero dollar for an card on MaxiPago API.
Method:
- .zeroDollar(zeroDollarJSON)
Params:
- zeroDollarJSON = your zero dollar data in JSON format.
Example:
const zeroDollarJSON = { processorID: '1', referenceNum: 'PONumber-000000', transactionDetail: { payType: { creditCard: { number: '4111111111111111', expMonth: '12', expYear: '2020', cvvNumber: '999', }, }, }, payment: { chargeTotal: '00.00', }, } const response = await gateway.zeroDollar(zeroDollarJSON)
This method add an card for previously added customer on MaxiPago API.
Method:
- .addCard(addCardJSON)
Params:
- addCardJSON = your card data in JSON format.
Example:
const addCardJSON = { customerId: '119720', creditCardNumber: '4111111111111111', expirationMonth: 12, expirationYear: 2020, billingName: 'Corwin', } const response = await gateway.addCard(addCardJSON)
This method delete an card previously added on MaxiPago API.
Method:
- .deleteCard(deleteCardJSON)
Params:
- deleteCardJSON = your card data in JSON format.
Example:
const deleteCardJSON = { customerId: '119722', token: '+adHuFvmSms=', } const response = await gateway.deleteCard(deleteCardJSON)
This method add an sale authorization for previously card added on MaxiPago API.
Method:
- .auth(authJSON)
Params:
- authJSON = your authorization data in JSON format.
Example:
const authJSON = { processorID: '1', referenceNum: 'PONumber-8959', billing: {}, transactionDetail: { payType: { creditCard: { number: '4111111111111111', expMonth: '12', expYear: '2020', cvvNumber: '', }, }, }, payment: { currencyCode: 'BRL', chargeTotal: '10.00', }, saveOnFile: { customerToken: '119766', }, } const response = await gateway.auth(authJSON)
You can also request an authorization using card token:
const authJSON = { processorID: '1', referenceNum: 'PONumber-2861', transactionDetail: { payType: { onFile: { customerId: '119790', token: 'XN7N7qSfZKc=', }, }, }, payment: { currencyCode: 'BRL', chargeTotal: '10.00', }, } const response = await gateway.auth(authJSON)
This method capture an sale authorization previously added on MaxiPago API.
Method:
- .capture(captureJSON)
Params:
- captureJSON = your capture data in JSON format.
Example:
const captureJSON = { orderID: '0A0104A3:01659FE61095:AE1B:34012394', referenceNum: 'PONumber-5918', payment: { chargeTotal: '10.00', }, } const response = await gateway.capture(captureJSON)
This method void an previously capture requested on MaxiPago API.
Method:
- .void(voidJSON)
Params:
- voidJSON = your void data in JSON format.
Example:
const voidJSON = { transactionID: '2203293' } const response = await gateway.void(voidJSON)
This method return an capture previously requested on MaxiPago API.
Method:
- .returnPayment(returnPaymentJSON)
Params:
- returnPaymentJSON = your return payment data in JSON format.
Example:
const returnPaymentJSON = { orderID: '0A0104A3:0165A0D725D2:51BC:3AA3973C', referenceNum: 'PONumber-5441', payment: { chargeTotal: '10.00', }, } const response = await gateway.returnPayment(returnPaymentJSON)
This method do an sale on MaxiPago API.
Method:
- .sale(saleJSON)
Params:
- saleJSON = your sale data in JSON format.
Example:
const saleJSON = { processorID: '1', referenceNum: 'PONumber-000000', transactionDetail: { payType: { creditCard: { number: '4111111111111111', expMonth: '12', expYear: '2020', cvvNumber: '', }, }, }, payment: { currencyCode: 'BRL', chargeTotal: '15.33', }, saveOnFile: { customerToken: 'G%WkQ0sJ%3O$gxo2yLGxz!!5#t&jD#P3bR', }, } const response = await gateway.sale(saleJSON)
This method query an transaction on MaxiPago API.
Method:
- .transactionQuery(transactionQueryJSON)
Params:
- transactionQueryJSON = your return payment data in JSON format.
Example:
const transactionQueryJSON = { filterOptions: { transactionId: 2997111, }, } const response = await gateway.transactionQuery(transactionQueryJSON)
This method add an recurring payment MaxiPago API.
Method:
- .recurringPayment(recurringPaymentJSON)
Params:
- recurringPaymentJSON = your recurring payment data in JSON format.
Example:
const recurringPaymentJSON = { processorID: '1', referenceNum: 'PONumber-6058', billing: { name: 'Bailey Hahn', address: '63849 Towne Plain', address2: '06249 Cummings Plains', city: 'Cummingsland', state: 'Kansas', postalcode: '458932184', country: 'UY', phone: '032.912.6510', email: '[email protected]', }, shipping: { name: 'Rosemary Barton DDS', address: '6695 Beahan View', address2: '9255 Brielle Harbors', city: 'West Willis', state: 'Massachusetts', postalcode: '142042357', country: 'US', phone: '245.009.3441', email: '[email protected]', }, transactionDetail: { payType: { creditCard: { number: '4111111111111111', expMonth: '12', expYear: '2020', cvvNumber: '', }, }, }, payment: { currencyCode: 'BRL', chargeTotal: '11.00', }, recurring: { action: 'new', startDate: '2018-09-04', frequency: '1', period: 'monthly', installments: '10', failureThreshold: '5', }, } const response = await gateway.recurringPayment(recurringPaymentJSON)
You can request an recurring payment using card token:
const recurringPaymentJSON = { processorID: '1', referenceNum: 'PONumber-5268', billing: { name: 'Lyla Schulist', address: '76180 Dicki Summit', address2: '4073 Sydni Union', city: 'Port Eleonoreside', state: 'Florida', postalcode: '771760064', country: 'TD', phone: '810.135.7471', email: '[email protected]', }, shipping: { name: 'Edna Wolf PhD', address: '327 Moore Rapids', address2: '7913 Bruen Junction', city: 'Lebsackburgh', state: 'Indiana', postalcode: '506219721', country: 'NZ', phone: '434.540.4613', email: '[email protected]', }, transactionDetail: { payType: { onFile: { customerId: '119903', token: 'lmHDTV334BQ=', }, }, }, payment: { currencyCode: 'BRL', chargeTotal: '11.00', }, recurring: { action: 'new', startDate: '2018-09-04', frequency: '1', period: 'monthly', installments: '10', failureThreshold: '5', }, } const response = await gateway.recurringPayment(recurringPaymentJSON)
This method update an recurring payment previously added MaxiPago API.
Method:
- .updateRecurringPayment(updateRecurringPaymentJSON)
Params:
- updateRecurringPaymentJSON = your recurring payment data in JSON format.
Example:
const updateRecurringPaymentJSON = { orderID: '0A0104A3:0165A003EA9E:CA3E:788D2E4F', paymentInfo: { cardInfo: { softDescriptor: 'RECSDNAME', }, }, recurring: { processorID: '1', action: 'disable', installments: '11', nextFireDate: '2018-09-04', fireDay: '20', period: 'quarterly', }, billingInfo: { name: 'Dr. Adonis Wiegand', address1: '77459 Ignacio Flat', address2: '873 Alexandrine Meadow', city: 'South Genestad', zip: '775927405', country: 'GL', email: '[email protected]', phone: '363.469.7941', }, shippingInfo: { name: 'Dayton Zboncak', address1: '61508 Rempel Glens', address2: '11020 Jaden Plains', city: 'Port Easter', zip: '127344175', country: 'BF', email: '[email protected]', phone: '801.057.6041', }, } const response = await gateway.void(updateRecurringPaymentJSON)
This method cancel an previously recurring payment added on MaxiPago API.
Method:
- .cancelRecurringPayment(cancelRecurringPaymentJSON)
Params:
- cancelRecurringPaymentJSON = your recurring payment data in JSON format.
Example:
const cancelRecurringPaymentJSON = { orderID: '0A0104A3:0165A0AC8533:9B78:5B51BACC', } const response = await gateway.cancelRecurringPayment( cancelRecurringPaymentJSON, )
- @faker-js/faker - To create fake data tests.
- axios - To make MaxiPago Requests.
- dotenv - To work with internal environment constiables.
- moment - To work correctly with dates and time zones.
- react-native-xml2js - To convert XML to JSON
- xml-js- To convert JSON to XMLrequests
- xml2js- To convert XML responses to JSON
We would love for you to contribute to the project and help make it even better than it is today!
Building
- Fork and clone the repository to your machine and install the project dependencies.
pnpm install
Testing
- Make a copy of
.env-example
file and rename it to.env
. - Fill in your test MaxiPago settings in
.env
file. - Run the tests with:
pnpm run test
Coverage
pnpm run test:cov
Found a Bug?
If you find a bug in the source code, you can help us by submitting an issue. Even better, you can submit a pull request with a fix.
Missing a Feature?
You can request a new feature by submitting an issue to our github repository.
If you would like to implement a new feature, please consider the size of the change in order to determine the right steps to proceed:
Small Features can be crafted and directly submitted as a pull request.
For a Major Feature, first open an issue and outline your proposal so that it can be discussed. This process allows us to better coordinate our efforts, prevent duplication of work, and help you to craft the change so that it is successfully accepted into the project.
Commit Guide
Commit Message Header
<type>: <short summary>
│ │
│ └─⫸ Summary in present tense. Not capitalized. No period at the end.
│
└─⫸ Commit Type: build|ci|docs|feat|fix|perf|refactor|test
The <type>
and <summary>
fields are mandatory.
Type
Must be one of the following:
- build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
- ci: Changes to our CI configuration files and scripts (example scopes: Circle, BrowserStack, SauceLabs)
- docs: Documentation only changes
- feat: A new feature
- fix: A bug fix
- perf: A code change that improves performance
- refactor: A code change that neither fixes a bug nor adds a feature
- test: Adding missing tests or correcting existing tests
Summary
Use the summary field to provide a succinct description of the change:
- use the imperative, present tense: "change" not "changed" nor "changes"
- don't capitalize the first constter
- no dot (.) at the end
MIT