Skip to content

Redecard (former VisaNet) for Node.js. Redecard is 2nd largest Brazilian credit card processor. Work in progress.

Notifications You must be signed in to change notification settings

viktors/node-redecard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Redecard (former VisaNet) for Node.js

IMPORTANT: this is work in progress.

This module implements Redecard (former VisaNet) WebSevice Komerci for Node.js.

Redecard is 2nd largest Brazilian credit card processor.

Supported online payment options

  • MasterCard®, Diners and Visa® credit cards. Debit cards, such as Visa Electron, are not accepted.
  • Pre-authorization or full authorization
  • Splitting total amount into several installments
  • Additional installment fee applied to either merchant or the user
  • Support for Airline Companies, Hotels and Car Rental merchants (untested)

Key features

  • Parameter names and return values in English
  • Normal POST over HTTPS, no SOAP
  • Automatic retries
  • Configuration files for request/response field mapping, data type conversion and validation
  • Redecard test environment supported
  • Online tests
  • Evens out some inconsistencies in Redecard API
  • Clean and maintainable code

Usage

var redecard = require('redecard')
  , merchant = new redecard.Instance('test', 'john.doe', 'secret')
  , details = { amount: 0.01
                , type: redecard.TYPES.FULL_PAYMENT
                , installments: 0
                , supplierId: '36483184'
                , orderId: 'ORDER001'
                , cardNumber: '4111111111111111'
                , cardCode: '123'
                , cardExpMonth: 1
                , cardExpYear: 2016
                , cardFullName: 'JOHN DOE'
                }
merchant.getAuthorized(details, function(err, data) {
  if(err) throw(err)
  if(data.isApproved) {
    // transaction approved, confirm it
    
    var confirmationDetails = 
      { date: data.date
      , uniqSeq: data.uniqSeq
      , receiptId: data.receiptId
      , authorizationId: data.authorizationId
      , installments: details.installments
      , type: details.type
      , amount: details.amount
      , supplierId: details.supplierId
      , orderId: details.orderId
      }
    merchant.confirmTxn(
        confirmationDetails, function(err, data) {
          if(err) throw(err)
          // data.code should be one of:
          //    redecard.CONFIRMATION_CODES.OK
          //    redecard.CONFIRMATION_CODES.ALREADY_CONFIRMED
          //    redecard.CONFIRMATION_CODES.TRX_UNDONE
          //  TRX_UNDONE means that more than 2 minutes have passed 
          //  before confirmation was sent.
        }
    )
    
  } else {
    // transaction NOT approved
  }
}

API Documentation

GetAuthorized

Arguments

GetAuthorized takes two parameters: a hash of arguments and a callback.

FieldTypeRequired?Max. lengthOriginal Redecard FieldDescription
amountmoneyYes10TOTALSales total amount
typezpad2Yes2TRANSACAOTransaction type code
installmentszpad2Yes2PARCELASNumber of installments
supplierIdzpad9Yes9FILIACAOSupplying store membership number
orderIdstringYes16NUMPEDIDOOrder number generated by the merchant
cardNumberdigitsYes16NRCARTAOCard number
cardCodedigitsYes3CVC2Card CVC2
cardExpMonthmonthYes2MESCard expiration month
cardExpYearyearYes2ANOCard expiration year
cardFullNamestringYes50PORTADORCardholder name
iatastringYes9IATAAirline: IATA code
distributorIdstringYes9DISTRIBUIDORMembership number of distributing store / card issuer, when B2B
concentradorIdstringYes5CONCENTRADORN/A – Send parameter blank
boardingFeemoneyYes10TAXAEMBARQUEAirline: Boarding fee
checkinFeemoneyYes10ENTRADAAirline: Check-in fee
docNum1stringYes16NUMDOC1Airline: ticket number of the main passenger
docNum2stringYes16NUMDOC2Airline: ticket number of the second passenger
docNum3stringYes16NUMDOC3Airline: ticket number of the third passenger
docNum4stringYes16NUMDOC4Airline: ticket number of the fourth passenger
pax1stringYes26PAX1Airline: The name of the main passenger
pax2stringYes26PAX2Airline: The name of the second passenger
pax3stringYes26PAX3Airline: The name of the third passenger
pax4stringYes26PAX4Airline: The name of the fourth passenger
autoConfirmbooleanYes1CONFTXNAuto-confirm transaction?
addDataTststringYes0ADDDataOnly for Airline Companies, Hotels and Car Rental merchants
additionalDatastringYes0ADD_DataOnly for Airline Companies, Hotels and Car Rental merchants

Callback

Callback function receives ```err``` and a hash of return values.

FieldTypeOriginal Redecard FieldDescription
codeintegerCODRETReturn code
messageurlencodedMSGRETReturn code description
datedateDATATransaction date
orderIdstringNUMPEDIDOOrder number
authorizationIdstringNUMAUTORAuthorization number
receiptIdstringNUMCVSales receipt number
authenticationIdstringNUMAUTENTAuthentication number
uniqSeqstringNUMSQNUnique sequential number
countryCodestringORIGEM_BINCode of issuer country, 2-letter or 3-letter ISO country code
distributorIdstringDISTRIBUIDORMembership number of distributor / cardholder, when B2B
iatastringIATAIATA
autoConfirmCodeintegerCONFCODRETAutomatic confirmation return code
autoConfirmMessageurlencodedCONFMSGRETReturn code description
expiresdateDATA_EXPIPre-authorization expiration date
_xmlstring_xmlUnparsed XML response (for debugging)

ConfirmTxn

Arguments

ConfirmTxn takes two parameters: a hash of arguments and a callback.

FieldTypeRequired?Max. lengthOriginal Redecard FieldDescription
datedateYes8DATATransaction date
uniqSeqstringYes12NUMSQNUnique sequential number
receiptIdstringYes9NUMCVSales receipt number
authorizationIdstringYes6NUMAUTORAuthorization number
installmentszpad2Yes2PARCELASNumber of installments
typezpad2Yes2TRANSORIGTransaction type code
amountmoneyYes10TOTALSales total amount
supplierIdzpad9Yes9FILIACAOSupplying store membership number
distributorIdstringYes9DISTRIBUIDORMembership number of distributing store / card issuer, when B2B
orderIdstringYes16NUMPEDIDOOrder number generated by the merchant
docNum1stringYes16NUMDOC1Airline: ticket number of the main passenger
docNum2stringYes16NUMDOC2Airline: ticket number of the second passenger
docNum3stringYes16NUMDOC3Airline: ticket number of the third passenger
docNum4stringYes16NUMDOC4Airline: ticket number of the fourth passenger
pax1stringYes26PAX1Airline: The name of the main passenger
pax2stringYes26PAX2Airline: The name of the second passenger
pax3stringYes26PAX3Airline: The name of the third passenger
pax4stringYes26PAX4Airline: The name of the fourth passenger
additionalDatastringYes0AddDataOnly for Airline Companies, Hotels and Car Rental merchants

Callback

Callback function receives ```err``` and a hash of return values.

FieldTypeOriginal Redecard FieldDescription
codeintegerCODRETReturn code
messagestringMSGRETReturn message
orderIdstringNUMPEDIDOOrder number
_xmlstring_xmlUnparsed XML response (for debugging)

About

Redecard (former VisaNet) for Node.js. Redecard is 2nd largest Brazilian credit card processor. Work in progress.

Resources

Stars

Watchers

Forks

Packages

No packages published