API Reference

Auth Matic

Verify quickly and easily if your payment methods are valid.

Open Auth Function

The openAuth function allows you to verify your payment methods easily and quickly.

Parameters

The openAuth has two parameters:

First Parameter (required)

For the correct use of Auth Matic this first parameter is necessary, it receives an object with the following properties

PropertyDescriptionTypeDefault
merchant_idRequired
To obtain the Merchant ID, you need to create a new Merchant or use a Merchant that has been previously created.
String
create_third_party_tokenAllows to determine if the payment method being verified will create a token related to a gateway that is integrated to Matic, if the field is true, it will return the token created at the end of the transaction.BooleanFalse
gateway_idIndicates to which gateway the payment method will be related if create_third_party_token is true.String

Second Parameter (optional)

To provide a faster and easier way to the customer when filling out the form to add a credit/debit card, we choose to use the second parameter, is an object that has the properties customer_email and billing_address with which the inputs will be pre-filled with this information in the form.

PropertyDescriptionType
customer_emailEmail indicated by the customer.String
billing_addressThis object contains the following properties and types:

address1: String
address2: String
city: String
state: String (e.g. "AL", "AB") see reference
zip_code: String
country: String (e.g "US", "CA") see reference
Object

Example usage:

import MaticSDK from '@matic.co/sdk'

const Sdk = MaticSDK('your sdk key');
//you can find the sdk_key on the get companies endpoint using the consumer secret and consumer key with authBasic

const data = {
  merchant_id: 'your Merchant ID'
  
}

// optional data
const pre_fill = {
  customer_email: '[email protected]',
  billing_address: {
    address1: 'Lorem ipsum',
    address2: 'Lorem ipsum',
    city: 'Los Angeles',
    state: 'AL',
    zip_code: '90001',
    country: 'US',
  },
}

// open Auth Matic
Sdk.openAuth(data, pre_fill)
if (window.MaticSDK) {
  // Initilalize instance  
  const SDK = window.MaticSDK('your sdk key');

  const data = {
    merchant_id: 'your Merchant ID'
  }

  // open Auth Matic
  SDK.openAuth(data)
}

Once you call the method, the following will be displayed:

Auth Matic is called. In credit/debit card mode.

Auth Matic is called. In credit/debit card mode.

Auth Matic Events

Once you open the Auth Matic, you may want to know the status of transactions. To that end, you can use the MaticSDK events. You can listen to Matic events with the on function

Example

import MaticSDK from '@matic.co/sdk'

const onSuccess = (data) => {
	// Your custom code
}
const onError = (data) => {
	// Your custom code
}

MaticSDK.on('success', onSuccess)
MaticSDK.on('error', onError)
if (window.MaticSDK) {
  const onSuccess = (data) => {
    // Your custom code
  }
  const onError = (data) => {
    // Your custom code
  }

  window.MaticSDK.on('success', onSuccess)
  window.MaticSDK.on('error', onError)
}

Success Events

To receive information about successful transactions, you can listen to success events

Success event listeners will receive an object with the operation data

Example

{
    "status": "success",
    "data": {
        "payment_method": {
            "bank_name": "Unknown",
            "billing_address": {
                "address1": "test",
                "address2": "",
                "city": "Phoenix",
                "country": "US",
                "state": "AZ",
                "zip_code": "12345"
            },
            "card_brand": "visa",
            "card_type": "credit",
            "cardholder": "John Doe",
            "create_third_party_token": false,
            "customer_email": "[email protected]",
            "expiration_month": 6,
            "expiration_year": 2024,
            "fingerprint": "e3cef43464fc832f6e04f187df25af497994",
            "first_six_digits": "411111",
            "gateway_id": null,
            "id": "714d008a-a5dc-422e-b26e-b383e8a73336",
            "issuer_identification_number": "41111111",
            "last_four_digits": "1111",
            "number": "4111-11**-****-1111",
            "third_party_token": null,
            "token": "Q3JvQAE2dnTxZHadJcOouzMQtbu"
        },
        "payment_method_id": "714d008a-a5dc-422e-b26e-b383e8a73336",
        "tp_token": null
    }
}

Error Events

In case the authentication process fails, it will emit an error event

Error event listeners will receive an object with the error data

Example

{
    "status": "failed",
    "errors": [
        {
            "code": 1,
            "message": "The card data entered is not allowed in this environment."
        }
    ]
}