Enroll an autopay

For your customer to enroll an autopay, your server requests a token from PAR with the service and customer data, and then their browser presents that token to PAR to start the session.

Request the token

POST {BASE_URL}/restpatpass/v1/services/patInscription

The request is authenticated with the Authorization and Commercecode headers, as explained in Authentication.

Required fields

  • Name
    commerceCode
    Type
    string
    is Required
    REQUIRED
    Description

    Your site's commerce code. It must be identical to the one you send in the Commercecode header.

  • Name
    url
    Type
    string
    is Required
    REQUIRED
    Description

    Return URL. PAR sends the cardholder to this address when the enrollment finishes. It must be a public URL.

  • Name
    finalUrl
    Type
    string
    is Required
    REQUIRED
    Description

    Final URL. PAR sends the cardholder to this address when they leave the autopay voucher. It must be a public URL.

  • Name
    correoPersona
    Type
    string
    is Required
    REQUIRED
    Description

    The cardholder's email. If they already have a PAR account with that email, the session opens with their account.

  • Name
    serviceId
    Type
    string
    is Required
    REQUIRED
    Description

    Identifier of the service to be charged, for example the contract or customer number. Up to 32 characters. The person cannot have another active autopay with the same identifier on your site.

Optional fields

These fields prefill the enrollment form, so the cardholder does not have to type them.

  • Name
    rut
    Type
    string
    is optional
    Description

    The cardholder's identity document. Up to 10 characters.

  • Name
    nombre
    Type
    string
    is optional
    Description

    The cardholder's first name. Up to 60 characters.

  • Name
    pApellido
    Type
    string
    is optional
    Description

    The cardholder's first surname. Up to 60 characters.

  • Name
    sApellido
    Type
    string
    is optional
    Description

    The cardholder's second surname. Up to 60 characters.

  • Name
    montoMaximo
    Type
    number
    is optional
    Description

    Maximum amount the autopay can charge. It must be greater than or equal to zero.

  • Name
    telefonoCelular
    Type
    string
    is optional
    Description

    The cardholder's mobile phone. Up to 50 characters. If it is not a valid phone number, PAR ignores it.

  • Name
    telefonoFijo
    Type
    string
    is optional
    Description

    The cardholder's landline phone. Up to 50 characters. If it is not a valid phone number, PAR ignores it.

  • Name
    nombrePatPass
    Type
    string
    is optional
    Description

    Name the cardholder will recognize the autopay by. Up to 100 characters.

  • Name
    correoComercio
    Type
    string
    is optional
    Description

    The merchant's contact email. Up to 100 characters.

  • Name
    direccion
    Type
    string
    is optional
    Description

    Address associated with the enrollment. Up to 100 characters.

  • Name
    ciudad
    Type
    string
    is optional
    Description

    City associated with the enrollment. Up to 100 characters.

Example

Request

POST
/restpatpass/v1/services/patInscription
curl --request POST \
  --url '{BASE_URL}/restpatpass/v1/services/patInscription' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: {YOUR_SECRET_KEY}' \
  --header 'Commercecode: 1234567890' \
  --data '{
    "commerceCode": "1234567890",
    "url": "https://www.example.com/par/return",
    "finalUrl": "https://www.example.com/par/final",
    "correoPersona": "[email protected]",
    "serviceId": "CONTRACT-0001",
    "rut": "11111111-1",
    "nombre": "John",
    "pApellido": "Doe",
    "montoMaximo": 50000,
    "telefonoCelular": "+56912345678",
    "nombrePatPass": "Monthly plan"
  }'

Response

If the request is valid, PAR answers 200 with the token and the login URL:

Response

{
  "token": "{TOKEN}",
  "url": "{BASE_URL}/restpatpass/login"
}
  • Name
    token
    Type
    string
    is Required
    REQUIRED
    Description

    Single-use token the cardholder will start the session with. Keep it: you will need it for the status check and the voucher.

  • Name
    url
    Type
    string
    is Required
    REQUIRED
    Description

    Login URL where you must send the token from the cardholder's browser.

If any data is invalid, PAR answers with an error code that points to the field, as described in Errors. Each response reports a single field; fix it and request the token again.

Start the session

With the token, send the cardholder to the response url through a POST form from their browser, with the token in the tokenComercio field. You can do it in a full window or inside an iframe, if your site's origin is authorized for your merchant.

Form

<form method="post" action="{BASE_URL}/restpatpass/login">
  <input type="hidden" name="tokenComercio" value="{TOKEN}" />
  <button type="submit">Enroll autopay</button>
</form>

PAR consumes the token and takes the cardholder to enroll the autopay, with the data you sent already loaded. If the person already has a PAR account, they enroll the autopay from it; otherwise, they can enroll it without creating an account.

If the token is invalid, PAR answers 403. If the login fails for another reason, PAR shows the cardholder an error page.

Receive the return

When the cardholder finishes, PAR submits a POST form to your return url with the token in the j_token field:

POST https://www.example.com/par/return
Content-Type: application/x-www-form-urlencoded

j_token={TOKEN}

The return only means the cardholder came back to your site. To know whether the autopay was enrolled, check the status with that token from your server, as explained in Check the status.