NAV Navbar
shell javascript
  • Introducción
  • Response Codes
  • Authentication
  • Accounts
  • Charges
  • Plans
  • Subscriptions
  • Refunds
  • Testing Cards
  • Introducción

    ¡Bienvenido a 4Geeks Payments API! Ahora, puedes usar nuestros endpoints para acceder a nuestra API, en donde puedes empezar a registrar clientes, procesar pagos, subscribir clientes a planes anuales/mensuales/semanales, y crear cupones de descuentos o free trials.

    A la derecha puedes observar ejemplos de como consumir nuestro API y cual seria la respuesta obtienes al consumir nuestros endpoints. En el chat puedes conectar con otros desarrolladores.

    Descarga las librerías cliente y plugins que la comunidad ha creado para ti.

    Solicita tus llaves de acceso aquí.

    Response Codes

    El API devuelve mensajes de respuesta acompañados de códigos HTTP. Aquí describimos los código y una corta descripción.

    Error Code Meaning
    201 Created -- Recurso creado.
    204 No Content -- Recurso eliminado.
    400 Bad Request -- Enviaste algo mal.
    401 Unauthorized -- Tus llaves de acceso están mal.
    403 Forbidden -- Es solo para administradores.
    404 Not Found -- El recurso no se encuentra.
    405 Method Not Allowed -- El método no es permitido.
    429 Too Many Requests -- Estás solicitando muchas cosas al mismo tiempo!
    500 Internal Server Error --Tenemos un problema con nuestros servidores. Intente otra vez.
    503 Service Unavailable -- Estamos temporalmente fuera de servicio. Intente otra vez luego.

    Authentication

    Para autorizar y recibir el token de acceso:

    curl https://api.payments.4geeks.io/authentication/token/ \
      -X POST \
      -d '{
            "grant_type": "client_credentials",
            "client_id":"kGnxskOMNedrqj8IVma23Qk2DQGpjjpAUUPLr85W",
            "client_secret":"VbCaLax7xnhsBIfmkwic6ifSZ4FRiMRfwrrtdSKhw89f17LRdyeW7zYYKLwvj2VLRbQzH6q0F7mRejGJwBIckHa7W2PlJNN4QLqQcnCMYQkYj1DK4uUv0MVCbYhVeyTX"
          }'
    
    $ npm install gpayments
    
    const gpayments = require('gpayments')
    
    const gpApi = gpayments({
      clientId: '4geeks-payments-client-id',
      clientSecret: '4geeks-payments-client-secret'
    })
    
    > Retorna lo siguiente:
    
    {
        "access_token": "PdSKf04xi9LEcvcwIAdbWAXVg380Kz",
        "token_type": "Bearer",
        "expires_in": 36000,
        "scope": "read write groups"
    }
    

    4Geeks Payments utiliza oAuth2 por lo tanto asegurate de enviar grant_type=client_credentials. Ademas, debes enviar client_id=<4geeks-payments-client-id>, client_secret=<4geeks-payments-client-secret>.

    Esto te retornará un access_token, el cual necesitas enviar en cada solicitud de ahora en adelante.

    Recuerda nunca tener estas credenciales visibles para nadie, nunca subas esto a repositirios como GitHub ni mucho menos los compartas. Lo recomendable es utilizar dichas credenciales en variables de ambiente.

    Accounts

    Retreive My Information

    curl "https://api.payments.4geeks.io/v1/accounts/me/" \
      -X GET \
      -H "authorization: bearer PdSKf04xi9LEcvcwIAdbWAXVg380Kz"
    
    
    const account = await gpApi.me.fetch()
    console.log(account)
    

    Retorna:

    {
        "developer_key": "RF4wdFt2zgyzWpnhJz9vwrPkBfL3dVH1",
        "test": true,
        "page": "http://my_website.com",
        "bank_name": "your_bank_name",
        "bank_account_number": "your_bank_account_number",
        "bank_sinpe": "your_bank_sinpe"
    }
    
    {
        "developer_key": "RF4wdFt2zgyzWpnhJz9vwrPkBfL3dVH1",
        "test": true,
        "page": "http://my_website.com",
        "bank_name": "your_bank_name",
        "bank_account_number": "your_bank_account_number",
        "bank_sinpe": "your_bank_sinpe"
    }
    

    Este endpoint retorna mi información como developer de 4geeks Payments.

    HTTP Request

    GET https://api.payments.4geeks.io/v1/accounts/me/

    Update My Information

    curl "https://api.payments.4geeks.io/v1/accounts/me/" \
      -X PUT \
      -H "authorization: bearer PdSKf04xi9LEcvcwIAdbWAXVg380Kz" \
      -F 'bank_name=new_bank_name' \
    
    const account = await gpApi.me.update({ bank_name: 'Bac', test: false })
    
    console.log(account)
    

    Retorna:

    {
        "developer_key": "RF4wdFt2zgyzWpnhJz9vwrPkBfL3dVH1",
        "test": false,
        "page": "http://my_website.com",
        "bank_name": "new_bank_name",
        "bank_account_number": "your_bank_account_number",
        "bank_sinpe": "your_bank_sinpe"
    }
    
    {
        "developer_key": "RF4wdFt2zgyzWpnhJz9vwrPkBfL3dVH1",
        "test": true,
        "page": "http://my_website.com",
        "bank_name": "Bac",
        "bank_account_number": "your_bank_account_number",
        "bank_sinpe": "your_bank_sinpe"
    }
    

    Este endpoint actualiza mi información como developer de 4geeks Payments.

    HTTP Request

    PUT https://api.payments.4geeks.io/v1/accounts/me/

    PATCH https://api.payments.4geeks.io/v1/accounts/me/

    List My Customers

    curl https://api.payments.4geeks.io/v1/accounts/customers/ \
      -X GET \
      -H 'authorization: bearer PdSKf04xi9LEcvcwIAdbWAXVg380Kz'
    
    const customers = await gpApi.customers.fetch()
    
    console.log(customers)
    

    Retorna:

    [
        {
            "name": "Bruce Banner",
            "email": "brucebanner@hulk.com",
            "currency": "usd",
            "test": false,
            "key": "CiSsaomsMwlgc4gakq5nem426TXUGsN0",
            "card": {
                "last4": "4242",
                "exp_year": 2035,
                "exp_month": 12,
                "brand": "Visa",
                "cvc": "pass"
            }
        },
        {
            "name": "Bruce Wayne",
            "email": "bruce@4geeks.io",
            "currency": "usd",
            "test": false,
            "key": "gzvqFYXWvJhE4eCsZ3xFZckzDfMn",
            "card": {
                "last4": "4242",
                "exp_year": 2020,
                "exp_month": 11,
                "brand": "Visa",
                "cvc": "pass"
            }
        }
    ]
    
    [
        {
            "name": "Bruce Banner",
            "email": "brucebanner@hulk.com",
            "currency": "usd",
            "test": false,
            "key": "CiSsaomsMwlgc4gakq5nem426TXUGsN0",
            "card": {
                "last4": "4242",
                "exp_year": 2035,
                "exp_month": 12,
                "brand": "Visa",
                "cvc": "pass"
            }
        },
        {
            "name": "Bruce Wayne",
            "email": "bruce@4geeks.io",
            "currency": "usd",
            "test": false,
            "key": "gzvqFYXWvJhE4eCsZ3xFZckzDfMn",
            "card": {
                "last4": "4242",
                "exp_year": 2020,
                "exp_month": 11,
                "brand": "Visa",
                "cvc": "pass"
            }
        }
    ]
    

    Este endpoint retorna la informacion de todos los customers asociados a mi cuenta en 4Geeks Payments.

    HTTP Request

    GET https://api.payments.4geeks.io/v1/accounts/customers/

    Create a Customer

    curl 'https://api.payments.4geeks.io/v1/accounts/customers/' \
        -X POST \
        -H 'authorization: bearer PdSKf04xi9LEcvcwIAdbWAXVg380Kz' \
        -F 'name=Bruce Banner' \
        -F 'email=brucebanner@hulk.com' \
        -F 'currency=usd' \
        -F 'credit_card_number=4242424242424242' \
        -F 'credit_card_security_code_number=123' \
        -F 'exp_month=12' \
        -F 'exp_year=2035'
    
    const customer = await gpApi.customers.create({
      name: 'Bruce Banner',
      email: 'brucebanner@hulk.com',
      currency: 'usd',
      credit_card_number: 4242424242424242,
      credit_card_security_code_number: 123,
      exp_month: 12,
      exp_year: 2035
    })
    
    console.log(customer)
    

    Retorna:

    {
        "key": "kUlN9fjAC8jNQm8iqab3N9vHTeD758kK",
        "name": "Bruce Banner",
        "email": "brucebanner@hulk.com",
        "currency": "usd",
        "card": {
            "last4": "4242",
            "exp_year": 2035,
            "exp_month": 12,
            "brand": "Visa",
            "cvc": "pass"
        }
    }
    
    {
        "key": "kUlN9fjAC8jNQm8iqab3N9vHTeD758kK",
        "name": "Bruce Banner",
        "email": "brucebanner@hulk.com",
        "currency": "usd",
        "card": {
            "last4": "4242",
            "exp_year": 2035,
            "exp_month": 12,
            "brand": "Visa",
            "cvc": "pass"
        }
    }
    

    Este endpoint crea y asigna un customer a tu cuenta de 4Geeks payments.

    HTTP Request

    POST https://api.payments.4geeks.io/v1/accounts/customers/

    Fields

    Parameter Description Type Required
    name Nombre del customer string true
    email Email para contactar al customer string true
    currency Moneda en la cual vamos a cobrarle al customer string true
    credit_card_number Número de tarjeta. string true
    credit_card_security_code_number Código de seguridad de la tarjeta. string true
    exp_month Fecha del mes de expiración de la tarjeta. integer true
    exp_year Fecha del año de expiración de la tarjeta. integer true

    Retrieve a Customer

    curl https://api.payments.4geeks.io/v1/accounts/customer/GfGsOKTZVlTKyn7khcihXYuEUx0nBxb/ \
      -X GET \
      -H 'authorization: bearer PdSKf04xi9LEcvcwIAdbWAXVg380Kz' \
    
    const customer = await gpApi.customers.fetch('GfGsOKTZVlTKyn7khcihXYuEUx0nBxb')
    
    console.log(customer)
    

    Retorna:

    {
        "key": "GfGsOKTZVlTKyn7khcihXYuEUx0nBxbh",
        "name": "Bruce Banner",
        "email": "brucebanner@hulk.com",
        "currency": "usd",  
        "card": {
            "last4": "4242",
            "exp_year": 2035,
            "exp_month": 12,
            "brand": "Visa",
            "cvc": "pass"
        }
    }
    
    {
        "key": "GfGsOKTZVlTKyn7khcihXYuEUx0nBxbh",
        "name": "Bruce Banner",
        "email": "brucebanner@hulk.com",
        "currency": "usd",  
        "card": {
            "last4": "4242",
            "exp_year": 2035,
            "exp_month": 12,
            "brand": "Visa",
            "cvc": "pass"
        }
    }
    

    Este endpoint retorna un customer encontrado por el key identificador.

    HTTP Request

    GET https://api.payments.4geeks.io/v1/accounts/customer/<KEY>/

    URL Parameters

    Parameter Description
    KEY El KEY value del customer que se quiere retornar

    Update a Customer

    curl https://api.payments.4geeks.io/v1/accounts/customer/GfGsOKTZVlTKyn7khcihXYuEUx0nBxbh/ \
         -X PUT \
         -H 'authorization: bearer PdSKf04xi9LEcvcwIAdbWAXVg380Kz' \
         -F 'currency=usd' \
         -F 'email=brucebanner2@hulk.com'
    
    const data = { email: 'brucebanner2@hulk.com' }
    const customer = await gpApi.customers.update('GfGsOKTZVlTKyn7khcihXYuEUx0nBxb', data)
    
    console.log(customer)
    

    Retorna:

    {
        "key": "GfGsOKTZVlTKyn7khcihXYuEUx0nBxbh",
        "name": "Bruce Banner",
        "email": "brucebanner2@hulk.com",
        "currency": "usd",
        "card": {
            "last4": "4242",
            "exp_year": 2035,
            "exp_month": 12,
            "brand": "Visa",
            "cvc": "pass"
        }
    }
    
    {
        "key": "GfGsOKTZVlTKyn7khcihXYuEUx0nBxbh",
        "name": "Bruce Banner",
        "email": "brucebanner2@hulk.com",
        "currency": "usd",
        "card": {
            "last4": "4242",
            "exp_year": 2035,
            "exp_month": 12,
            "brand": "Visa",
            "cvc": "pass"
        }
    }
    

    Este endpoint edita un customer en especifico.

    HTTP Request

    PUT https://api.payments.4geeks.io/v1/accounts/customer/<KEY>/

    PATCH https://api.payments.4geeks.io/v1/accounts/customer/<KEY>/

    URL Parameters

    Parameter Description
    KEY El KEY del customer que se quiere retornar

    Delete a Customer

    curl https://api.payments.4geeks.io/v1/accounts/customer/GfGsOKTZVlTKyn7khcihXYuEUx0nBxbh/ \
         -X DELETE \
         -H 'authorization: bearer PdSKf04xi9LEcvcwIAdbWAXVg380Kz' \
    
    await gpApi.customers.remove('GfGsOKTZVlTKyn7khcihXYuEUx0nBxb')
    

    Retorna un status HTTP 204 No Content.

    Este endpoint elimina un customer en especifico.

    HTTP Request

    DELETE https://api.payments.4geeks.io/v1/accounts/customer/<KEY>/

    URL Parameters

    Parameter Description
    KEY El KEY del customer que se quiere eliminar

    Charges

    Create a Charge

    curl 'https://api.payments.4geeks.io/v1/charges/create/' \
        -X POST \
        -H 'authorization: bearer PdSKf04xi9LEcvcwIAdbWAXVg380Kz' \
        -F 'customer_key=56U9RMd7EKYLWtlNX112W5e3L73BYzuE' \
        -F 'amount=90.32' \
        -F 'description=some_description_here' \
        -F 'entity_description=some_text_here' \
        -F 'currency=usd'
    
    await gpApi.charges.create({
      amount: 90.32,
      customer_key: 'GfGsOKTZVlTKyn7khcihXYuEUx0nBxb',
      description: 'Plan 1 service charge',
      entity_description: 'Plan 1',
      currency: 'usd',
    })
    

    Retorna un status HTTP 201 Created

    Este endpoint crea un charge, en otras palabras, realiza un rebajo a la tarjeta del cliente, utilizando sus datos financieros.

    HTTP Request

    POST https://api.payments.4geeks.io/v1/charges/create/

    Fields

    Parameter Description Type Required
    customer_key Llave del cliente, esto para obtener la informacion de la tarjeta asociada al mismo. string true
    amount Cantidad de dinero a rebajar. float true
    description Descripcion con la cual podras buscar la transacción. string true
    entity_description Descripcion para el estado de cuenta de la tarjeta del cliete. Max 35 caracteres. string false
    currency Moneda por la cual se le hara el rebajo al cliente (crc, usd), por defecto se va a descontar en la moneda del customer string false

    Create a Simple Charge

    curl 'https://api.payments.4geeks.io/v1/charges/simple/create/' \
        -X POST \
        -H 'authorization: bearer PdSKf04xi9LEcvcwIAdbWAXVg380Kz' \
        -F 'amount=800.55' \
        -F 'description=Desc for Simple' \
        -F 'entity_description=Desc for Simple' \
        -F 'currency=usd' \
        -F 'credit_card_number=4242424242424242' \
        -F 'credit_card_security_code_number=123' \
        -F 'exp_month=11' \
        -F 'exp_year=2020'
    
    await gpApi.charges.create({
      amount: 90.32,
      description: 'Plan 1 service charge',
      entity_description: 'Plan 1',
      currency: 'usd',
      credit_card_number: 4242424242424242,
      credit_card_security_code_number: 123,
      exp_month: 11,
      exp_year: 2020
    })
    

    Retorna un status HTTP 201 Created

    Este endpoint crea un simple charge, en otras palabras, realiza un rebajo a la tarjeta que venga en el POST, no esta asignada a ningun customer.

    HTTP Request

    POST https://api.payments.4geeks.io/v1/charges/simple/create/

    Fields

    Parameter Description Type Required
    amount Cantidad de dinero a rebajar. float true
    description Descripcion que le enviaremos al cliente del rebajo. string true
    entity_description Descripcion para el estado de cuenta de la tarjeta del cliete. Max 35 caracteres. string false
    currency Moneda por la cual se le hara el rebajo al cliente (crc, usd) string true
    credit_card_number Numero de tarjeta. string true
    credit_card_security_code_number Codigo de seguridad de la tarjeta. string true
    exp_month Fecha del mes de expiracion de la tarjeta. integer true
    exp_year Fecha del año de expiracion de la tarjeta. integer true

    List all Charges Logs

    curl https://api.payments.4geeks.io/v1/charges/logs/ \
      -X GET \
      -H 'authorization: bearer PdSKf04xi9LEcvcwIAdbWAXVg380Kz' \
    
    const logs = await gpApi.charges.logs()
    
    console.log(logs)
    

    Retorna:

    [
        {
            "charge_id": "1BR0dbCqnAMAMqhvnVyvoh8E",
            "customer": null,
            "charge_by_customer": false,
            "charge_log": {
                "status": "succeeded",
                "description": "Entity Desc",
                "entity_description": "Test TEst",
                "currency": "usd",
                "amount": 50,
                "card": {
                    "last4": "4242",
                    "exp_year": 2035,
                    "exp_month": 12,
                    "brand": "Visa",
                    "cvc": "pass"
                }
            },
            "created_on": "2017-11-30T17:30:32Z",
            "created_on_pretty": "2017-11-30 17:30:32 UTC",
            "created_on_date": "2017-11-30"
        },
        {
            "charge_id": "1BR11aCqnAMAMqhvtER6z1NU",
            "customer": null,
            "charge_by_customer": false,
            "charge_log": {
                "status": "succeeded",
                "description": "Entity Desc",
                "entity_description": "Test TEst",
                "currency": "usd",
                "amount": 50,
                "card": {
                    "last4": "4242",
                    "exp_year": 2035,
                    "exp_month": 12,
                    "brand": "Visa",
                    "cvc": "pass"
                }
            },
            "created_on": "2017-11-30T17:30:32Z",
            "created_on_pretty": "2017-11-30 17:30:32 UTC",
            "created_on_date": "2017-11-30"
        },
        {
            "charge_id": "1BRiugCqnAMAMqhvADaYYcdb",
            "customer": {
                "name": "Bruce Banner",
                "email": "brucebanner@hulk.com",
                "currency": "usd",
                "test": false,
                "key": "CiSsaomsMwlgc4gakq5nem426TXUGsN0",
                "card": {
                    "last4": "4242",
                    "exp_year": 2035,
                    "exp_month": 12,
                    "brand": "Visa",
                    "cvc": "pass"
                }
            },
            "charge_by_customer": true,
            "charge_log": {
                "status": "succeeded",
                "description": "Test from my local computer Sergio",
                "entity_description": "Bank Description",
                "currency": "usd",
                "amount": 45,
                "card": {
                    "last4": "4242",
                    "exp_year": 2035,
                    "exp_month": 12,
                    "brand": "Visa",
                    "cvc": null
                }
            },
            "created_on": "2017-11-30T17:30:32Z",
            "created_on_pretty": "2017-11-30 17:30:32 UTC",
            "created_on_date": "2017-11-30"
        }
    ]
    
    [
        {
            "charge_id": "1BR0dbCqnAMAMqhvnVyvoh8E",
            "customer": null,
            "charge_by_customer": false,
            "charge_log": {
                "status": "succeeded",
                "description": "Entity Desc",
                "entity_description": "Test TEst",
                "currency": "usd",
                "amount": 50,
                "card": {
                    "last4": "4242",
                    "exp_year": 2035,
                    "exp_month": 12,
                    "brand": "Visa",
                    "cvc": "pass"
                }
            },
            "created_on": "2017-11-30T17:30:32Z",
            "created_on_pretty": "2017-11-30 17:30:32 UTC",
            "created_on_date": "2017-11-30"
        },
        {
            "charge_id": "1BR11aCqnAMAMqhvtER6z1NU",
            "customer": null,
            "charge_by_customer": false,
            "charge_log": {
                "status": "succeeded",
                "description": "Entity Desc",
                "entity_description": "Test TEst",
                "currency": "usd",
                "amount": 50,
                "card": {
                    "last4": "4242",
                    "exp_year": 2035,
                    "exp_month": 12,
                    "brand": "Visa",
                    "cvc": "pass"
                }
            },
            "created_on": "2017-11-30T17:30:32Z",
            "created_on_pretty": "2017-11-30 17:30:32 UTC",
            "created_on_date": "2017-11-30"
        },
        {
            "charge_id": "1BRiugCqnAMAMqhvADaYYcdb",
            "customer": {
                "name": "Bruce Banner",
                "email": "brucebanner@hulk.com",
                "currency": "usd",
                "test": false,
                "key": "CiSsaomsMwlgc4gakq5nem426TXUGsN0",
                "card": {
                    "last4": "4242",
                    "exp_year": 2035,
                    "exp_month": 12,
                    "brand": "Visa",
                    "cvc": "pass"
                }
            },
            "charge_by_customer": true,
            "charge_log": {
                "status": "succeeded",
                "description": "Test from my local computer Sergio",
                "entity_description": "Bank Description",
                "currency": "usd",
                "amount": 45,
                "card": {
                    "last4": "4242",
                    "exp_year": 2035,
                    "exp_month": 12,
                    "brand": "Visa",
                    "cvc": null
                }
            },
            "created_on": "2017-11-30T17:30:32Z",
            "created_on_pretty": "2017-11-30 17:30:32 UTC",
            "created_on_date": "2017-11-30"
        }
    ]
    

    Este endpoint retorna todos los logs de los cargos creados a mis clientes.

    HTTP Request

    GET https://api.payments.4geeks.io/v1/charges/logs/

    Fields

    Name Description Type
    customer Retorna toda la informacion de mi cliente. object
    charge_log Retorna la informacion de la transacción. object

    Retreive a Charge Log

    curl https://api.payments.4geeks.io/v1/charges/logs/<charge_id>/ \
      -X GET \
      -H 'authorization: bearer PdSKf04xi9LEcvcwIAdbWAXVg380Kz' \
    
    const log = await gpApi.charges.logs('1BTvroCqnAM123fqhvZw4dlkHk')
    
    console.log(log)
    

    Retorna:

      {
        "charge_id": "1BTvroCqnAM123fqhvZw4dlkHk",
        "customer": {
            "key": "vPAn1v4rJFQK2132dYBogBYVTFhaQN",
            "name": "Bruce Banner",
            "email": "brucebanner@4geeks.io",
            "currency": "usd",
            "card": {
                "last4": "4242",
                "exp_year": 2020,
                "exp_month": 12,
                "brand": "Visa",
                "cvc": "pass"
            }
        },
        "charge_by_customer": true,
        "charge_log": {
            "status": "succeeded",
            "description": "Description",
            "entity_description": "Entity Description",
            "currency": "usd",
            "amount": 12,
            "card": {
                "last4": "4242",
                "exp_year": 2020,
                "exp_month": 12,
                "brand": "Visa",
                "cvc": "pass"
            }
        },
        "created_on": "2017-11-30T17:30:32Z",
        "created_on_pretty": "2017-11-30 17:30:32 UTC",
        "created_on_date": "2017-11-30"
      }
    
      {
        "charge_id": "1BTvroCqnAM123fqhvZw4dlkHk",
        "customer": {
            "key": "vPAn1v4rJFQK2132dYBogBYVTFhaQN",
            "name": "Bruce Banner",
            "email": "brucebanner@4geeks.io",
            "currency": "usd",
            "card": {
                "last4": "4242",
                "exp_year": 2020,
                "exp_month": 12,
                "brand": "Visa",
                "cvc": "pass"
            }
        },
        "charge_by_customer": true,
        "charge_log": {
            "status": "succeeded",
            "description": "Description",
            "entity_description": "Entity Description",
            "currency": "usd",
            "amount": 12,
            "card": {
                "last4": "4242",
                "exp_year": 2020,
                "exp_month": 12,
                "brand": "Visa",
                "cvc": "pass"
            }
        },
        "created_on": "2017-11-30T17:30:32Z",
        "created_on_pretty": "2017-11-30 17:30:32 UTC",
        "created_on_date": "2017-11-30"
      }
    

    Este endpoint retorna el log específico del charge seleccionado.

    HTTP Request

    GET https://api.payments.4geeks.io/v1/charges/logs/<charge_id>/

    Fields

    URL Parameters

    Parameter Description
    charge_id Identificador del charge a desplegarse.

    Plans

    Create a Plan

    curl 'https://api.payments.4geeks.io/v1/plans/create/' \
         -X POST
         -H 'authorization: bearer 1qtm7wVG2eREf8vZhLRckAQWaxbaWY' \
         -F 'name=Mi Plan' \
         -F 'amount=300000' \
         -F 'currency=crc' \
         -F 'trial_period_days=0' \
         -F 'interval=month' \
         -F 'interval_count=1' \
         -F 'credit_card_description=Descripción'
    
    const plan = await gpApi.plans.create({
      id_name: 'plan-1',
      name: 'Test Plan',
      amount: 300000,
      currency: 'crc',
      trial_period_days: 0,
      interval: 'month',
      interval_count: 1,
      credit_card_description: 'Test Credit Card'
    })
    
    console.log(plan)
    

    Retorna un status HTTP 201 Created

    Este endpoint crea un plan de pago.

    HTTP Request

    POST https://api.payments.4geeks.io/v1/plans/create/

    Fields

    Parameter Description Type Required
    name Nombre del plan. string true
    currency Moneda en la cual se haran los rebajos. string true
    trial_period_days Numero de dias en las cuales se le brindara al usuario un trial. Default 0. integer false
    interval Frecuenca de rebajos (month, week, day, year). string true
    interval_count La cantidad de intervalos, por ejemplo interval=month, interval_count=6, eso significa que cada 6 meses se hara un rebajo. string true
    credit_card_description Descripcion para el estado de cuenta de la tarjeta del cliete. string false

    List all Plans

    curl https://api.payments.4geeks.io/v1/plans/mine \
      -X GET \
      -H 'authorization: bearer PdSKf04xi9LEcvcwIAdbWAXVg380Kz' \
    
    const plans = await gpApi.plans.fetch()
    
    console.log(plans)
    

    Retorna:

    [
        {
            "key": "ftmDCyPmun7QiKah5PrP2f",
            "information": {
                "currency": "crc",
                "amount": 6000,
                "name": "Test Plan",
                "created": '2017-11-30 17:52:23',
                "credit_card_description": "Charge Test",
                "trial_period_days": null,
                "interval": "month",
                "interval_count": 1
            }
        },
        {
            "key": "fD4rtgmun7QiKah5PrP2f",
            "information": {
                "currency": "crc",
                "amount": 300000,
                "name": "Mi Plan",
                "created": 1501184712,
                "credit_card_description": "Descripción",
                "trial_period_days": null,
                "interval": "month",
                "interval_count": 1
            }
        }
    ]
    
    [
        {
            "key": "ftmDCyPmun7QiKah5PrP2f",
            "information": {
                "currency": "crc",
                "amount": 6000,
                "name": "Test Plan",
                "created": '2017-11-30 17:52:23',
                "credit_card_description": "Charge Test",
                "trial_period_days": null,
                "interval": "month",
                "interval_count": 1
            }
        },
        {
            "key": "fD4rtgmun7QiKah5PrP2f",
            "information": {
                "currency": "crc",
                "amount": 300000,
                "name": "Mi Plan",
                "created": 1501184712,
                "credit_card_description": "Descripción",
                "trial_period_days": null,
                "interval": "month",
                "interval_count": 1
            }
        }
    ]
    

    Este endpoint retorna todos los planes que hayas creado.

    HTTP Request

    GET https://api.payments.4geeks.io/v1/plans/mine

    Retreive a Plan

    curl https://api.payments.4geeks.io/v1/plans/mine/<plan_key>/ \
      -X GET \
      -H 'authorization: bearer PdSKf04xi9LEcvcwIAdbWAXVg380Kz' \
    
    const plan = await gpApi.plans.fetch('ftmDCyPmun7QiKah5PrP2f')
    
    console.log(plan)
    

    Retorna:

      {
          "key": "ftmDCyPmun7QiKah5PrP2f",
          "information": {
              "currency": "crc",
              "amount": 6000,
              "name": "Test Plan",
              "created": '2017-11-30 17:52:23',
              "credit_card_description": "Charge Test",
              "trial_period_days": null,
              "interval": "month",
              "interval_count": 1
          }
      }
    
      {
          "key": "ftmDCyPmun7QiKah5PrP2f",
          "information": {
              "currency": "crc",
              "amount": 6000,
              "name": "Test Plan",
              "created": '2017-11-30 17:52:23',
              "credit_card_description": "Charge Test",
              "trial_period_days": null,
              "interval": "month",
              "interval_count": 1
          }
      }
    

    Este endpoint retorna un plan que el key indicado.

    HTTP Request

    GET https://api.payments.4geeks.io/v1/plans/mine/<plan_key>/

    URL Parameters

    Parameter Description
    plan_key Identificador del plan.

    Delete a Plan

    curl https://api.payments.4geeks.io/v1/plans/mine/<plan_key>/ \
      -X DELETE \
      -H 'authorization: bearer PdSKf04xi9LEcvcwIAdbWAXVg380Kz' \
    
    await gpApi.plans.remove('ftmDCyPmun7QiKah5PrP2f')
    

    Retorna un status HTTP 204 No Content

    Este endpoint elimina un plan que el key indicado.

    HTTP Request

    DELETE https://api.payments.4geeks.io/v1/plans/mine/<plan_key>/

    Subscriptions

    Create a Subscription

    curl 'https://api.payments.4geeks.io/v1/plans/subscribe/' \
         -X POST
         -H 'authorization: bearer 1qtm7wVG2eREf8vZhLRckAQWaxbaWY' \
         -F 'customer_key=customer-key' \
         -F 'plan_key=plan-key'
    
    await gpApi.subscriptions.subscribe({
      plan_id_name: 'plan-1',
      customer_key: 'GfGsOKTZVlTKyn7khcihXYuEUx0nBxb',
    })
    

    Retorna un status HTTP 201 Created

    Este endpoint crea un y asigna una subscripción a un cliente.

    HTTP Request

    POST https://api.payments.4geeks.io/v1/plans/subscribe/

    Fields

    Parameter Description Type Required
    customer_key Identificador del cliente. string true
    plan_key identificador del plan. string true

    List all Subscriptions

    curl https://api.payments.4geeks.io/v1/plans/subscriptions/ \
      -X GET \
      -H 'authorization: bearer PdSKf04xi9LEcvcwIAdbWAXVg380Kz' \
    
    const subscriptions = await gpApi.subscriptions.fetch()
    
    console.log(subscriptions)
    

    Retorna:

    [
        {
            "id": 1,
            "subscription_id": "B6Vje4CBVugWea",
            "developer": {
                "developer_key": "RF4wdFt2zgyzWpnhJz9vwrPkBfL3dVH1",
                "test": true,
                "page": "http://test.com",
                "bank_name": "BCR",
                "bank_aba_route": "123123",
                "bank_account_number": "123123123123",
                "bank_account_type": "DB",
                "bank_sinpe": "123123123123"
            },
            "customer": {
                "id": 16,
                "name": "Tony Stark",
                "email": "tony@4geeks.io",
                "currency": "crc",
                "credit_card_number": "*************4242",
                "credit_card_security_code_number": "***",
                "exp_month": 11,
                "exp_year": 2022,
                "test": true,
                "key": "56U9RMd7EKYLWtlNX112W5e3L73BYzuE"
            },
            "plan": {
                "key": "ftmDCyPmun7QiKah5PrP2f",
                "information": {
                    "currency": "usd",
                    "amount": 45,
                    "name": "Plan Test",
                    "key": "ftmDCyPmun7QiKah5PrP2f",
                    "created": "2017-12-05 19:14:22",
                    "credit_card_description": "Card Desc",
                    "trial_period_days": null,
                    "interval": "month",
                    "interval_count": 1
                }
            }
        }
    ]
    
    [
        {
            "id": 1,
            "subscription_id": "B6Vje4CBVugWea",
            "developer": {
                "developer_key": "RF4wdFt2zgyzWpnhJz9vwrPkBfL3dVH1",
                "test": true,
                "page": "http://test.com",
                "bank_name": "BCR",
                "bank_aba_route": "123123",
                "bank_account_number": "123123123123",
                "bank_account_type": "DB",
                "bank_sinpe": "123123123123"
            },
            "customer": {
                "id": 16,
                "name": "Tony Stark",
                "email": "tony@4geeks.io",
                "currency": "crc",
                "credit_card_number": "*************4242",
                "credit_card_security_code_number": "***",
                "exp_month": 11,
                "exp_year": 2022,
                "test": true,
                "key": "56U9RMd7EKYLWtlNX112W5e3L73BYzuE"
            },
            "plan": {
                "key": "ftmDCyPmun7QiKah5PrP2f",
                "information": {
                    "currency": "usd",
                    "amount": 45,
                    "name": "Plan Test",
                    "key": "ftmDCyPmun7QiKah5PrP2f",
                    "created": "2017-12-05 19:14:22",
                    "credit_card_description": "Card Desc",
                    "trial_period_days": null,
                    "interval": "month",
                    "interval_count": 1
                }
            }
        }
    ]
    

    Este endpoint retorna todos las subscripciones creadas.

    HTTP Request

    GET https://api.payments.4geeks.io/v1/plans/subscriptions/

    Retreive a Subscription

    curl https://api.payments.4geeks.io/v1/plans/subscription/B6Vje4CBVugWea \
         -X GET \
         -H 'authorization: bearer PdSKf04xi9LEcvcwIAdbWAXVg380Kz' \
    
    const subscription = await gpApi.subscriptions.fetch('BtZ3TxvsEvFh2x')
    
    console.log(subscription)
    

    Retorna:

    {
          "subscription_id": "BtZ3TxvsEvFh2x",
          "developer": {
              "developer_key": "DMThC06Dl2w5s3GLgg8joLE5GIsJJCs6",
              "test": false,
              "page": "http://www.mypage.com",
              "bank_name": null,
              "bank_account_number": null,
              "bank_sinpe": null
          },
          "customer": {
              "key": "vPAn1v4rJFQKam0gl37YBogBYVTFhaQN",
              "name": "Bruce Banner",
              "email": "brucebanner@gmail.com",
              "currency": "usd",
              "card": {
                  "last4": "4242",
                  "exp_year": 2020,
                  "exp_month": 12,
                  "brand": "Visa",
                  "cvc": "pass"
              }
          },
          "plan": {
              "key": "ftmDCyPmun7QiKah5PrP2f",
              "information": {
                  "currency": "usd",
                  "amount": 45,
                  "name": "Plan Test  ",
                  "key": "ftmDCyPmun7QiKah5PrP2f",
                  "created": "2017-12-05 19:14:22",
                  "credit_card_description": "Card Desc",
                  "trial_period_days": null,
                  "interval": "month",
                  "interval_count": 1
              }
          }
      }
    
    {
          "subscription_id": "BtZ3TxvsEvFh2x",
          "developer": {
              "developer_key": "DMThC06Dl2w5s3GLgg8joLE5GIsJJCs6",
              "test": false,
              "page": "http://www.mypage.com",
              "bank_name": null,
              "bank_account_number": null,
              "bank_sinpe": null
          },
          "customer": {
              "key": "vPAn1v4rJFQKam0gl37YBogBYVTFhaQN",
              "name": "Bruce Banner",
              "email": "brucebanner@gmail.com",
              "currency": "usd",
              "card": {
                  "last4": "4242",
                  "exp_year": 2020,
                  "exp_month": 12,
                  "brand": "Visa",
                  "cvc": "pass"
              }
          },
          "plan": {
              "key": "ftmDCyPmun7QiKah5PrP2f",
              "information": {
                  "currency": "usd",
                  "amount": 45,
                  "name": "Plan Test  ",
                  "key": "ftmDCyPmun7QiKah5PrP2f",
                  "created": "2017-12-05 19:14:22",
                  "credit_card_description": "Card Desc",
                  "trial_period_days": null,
                  "interval": "month",
                  "interval_count": 1
              }
          }
      }
    

    Este endpoint retorna un plan que el key indicado.

    HTTP Request

    GET https://api.payments.4geeks.io/v1/plans/subscription/<subscription_id>/

    URL Parameters

    Parameter Description
    subscription_id Identificador de la subscripcion.

    Delete a Subscription

    curl https://api.payments.4geeks.io/v1/plans/un-subscribe/B6Vje4CBVugWea \
         -X DELETE \
         -H 'authorization: bearer PdSKf04xi9LEcvcwIAdbWAXVg380Kz' \
    
    await gpApi.subscriptions.unsubscribe('sub_B6Vje4CBVugWea')
    

    Retorna un status HTTP 204 No Content

    Este endpoint elimina una subscripcion en especifico.

    HTTP Request

    DELETE https://api.payments.4geeks.io/v1/plans/un-subscribe/<subscription_id>/

    URL Parameters

    Parameter Description
    subscription_id Identificador de la subscripcion.

    Refunds

    Create a refund

    curl -X POST \
      https://api.payments.4geeks.io/v1/refunds/ \
      -H 'Authorization: bearer GZe5XDYlwPEk4OW1o5XCjqIOFnVABk' \
      -F 'amount=10' \
      -F 'charge_id=1BSt6hCqnAMAMqhvMGiBxOWe' \
      -F 'reason=duplicate'
    

    Retorna:

    {
        "refund_id": "1BiPhgCqnAMsdzqhvCTntF7aD",
        "charge_id": "1BSt6hCqnAMAasd3vMGiBxOWe",
        "amount": "10.00",
        "currency": "usd",
        "reason": "duplicate",
        "status": "succeeded",
        "test": true
    }
    

    Este endpoint crea un reembolso y lo asocia con una transacción.

    HTTP Request

    POST https://api.payments.4geeks.io/v1/refunds/

    Fields

    Parameter Description Type Required
    amount Monto del reembolso. string true
    charge_id identificador del Charge en cuestión. string true
    reason Motivo del reembolso. Puede ser duplicate, fraudulent o requested_by_customer string true

    List all my refunds

    curl https://api.payments.4geeks.io/v1/refunds/ \
      -X GET \
      -H 'authorization: bearer PdSKf04xi9LEcvcwIAdbWAXVg380Kz' \
    

    Retorna:

    [
        {
            "refund_id": "1BiOrQCqNertMqhvvUMhJajE",
            "charge_id": "1BSt5sCqnAMAMqhvd871C1Vl",
            "amount": "10.00",
            "currency": "usd",
            "reason": "duplicate",
            "status": "succeeded",
            "test": true
        },
        {
            "refund_id": "1BiPDoCqnNerAMqhvSzxyFXl2",
            "charge_id": "1BSt5sCqnAMAMqhvd871C1Vl",
            "amount": "40.00",
            "currency": "usd",
            "reason": "fraudulent",
            "status": "succeeded",
            "test": true
        },
        {
            "refund_id": "1BiPeNCqnANerMqhvc4QUDeeK",
            "charge_id": "1BSt6hCqnAMAMqhvMNerxOWe",
            "amount": "10.00",
            "currency": "usd",
            "reason": "requested_by_customer",
            "status": "succeeded",
            "test": true
        },
        {
            "refund_id": "1BiPhgNernAMAMqhvCTntF7aD",
            "charge_id": "1BSt6hCqnAMAMqhvMGiBNerWe",
            "amount": "10.00",
            "currency": "usd",
            "reason": "null",
            "status": "succeeded",
            "test": true
        }
    ]
    

    Este endpoint retorna todos los reembolsos activos.

    HTTP Request

    GET https://api.payments.4geeks.io/v1/refunds/

    Retreive a refund

    curl https://api.payments.4geeks.io/v1/refunds/1BiPhgCqnAMsdzqhvCTntF7aD \
         -X GET \
         -H 'authorization: bearer PdSKf04xi9LEcvcwIAdbWAXVg380Kz' \
    

    Retorna:

    {
        "refund_id": "1BiPhgCqnAMsdzqhvCTntF7aD",
        "charge_id": "1BSt6hCqnAMAasd3vMGiBxOWe",
        "amount": "10.00",
        "currency": "usd",
        "reason": "duplicate",
        "status": "succeeded",
        "test": true
    }
    

    Este endpoint retorna un reembolso.

    HTTP Request

    GET https://api.payments.4geeks.io/v1/refunds/<refund_id>/

    URL Parameters

    Parameter Description
    refund_id Identificador del reembolso.

    Testing Cards

    Test Card Numbers and Brand

    A continuación se enlistan números de tarjetas para afectos de testing, junto a su proveedor.

    Numero Marca
    4242424242424242 Visa.
    5555555555554444 MasterCard.
    378282246310005 AmericanExpress.

    Test Card Numbers and Errors

    A continuación se enlistan números de tarjetas para afectos de testing, junto a su proveedor.

    Numero Descripcion
    4000000000000127 CVC no es correcto.
    4000000000000002 Tarjeta Denegada.
    4000000000000069 Tarjeta expirada.

    Ademas puedes probar con numeros invalidos en mes, año y cvc, ya sea poniendo fechas pasadas o meses inválidos.