3. Planes

Los planes en nuestra API están pensados en darte la posibilidad de construir un sistema en el cual tu definas ya sea de forma estática o dinámica los costos que verán tus clientes disponibles a elegir en tus suscripciones.

256

Plan Variable

Crear Plan

Si se necesita hacer una plan variable es necesario hacer los siguientes pasos:

El atributo variableAmount debe ser igual a true con esto le indicamos al API que recibiremos montos variables, al activar este atributo por default no podremos hacer reintentos ni renovaciones automáticas dado a que los montos tendrán que ser confirmados por ustedes antes de realizarse y los atributos selfRetries y selfRenewal deberán ir en false

{
  "amount": 100,
  "currency": "MXN",
  "frecuency": 1,
  "interval": "MONTHLY",
  "name": "Colegiatura",
  "trialDays": 0,
  "expiryCount": 12,
  "variableAmount": true,
  "dayStartPayment": 1,
  "selfRetries": false,
  "selfRenewal": false,
  "terminalView":false,
  "identifier": "plan-id-alumno-3"
}

Crear Suscripcion
Al momento de crear una suscripción con un plan variable deberemos de utilizar el siguiente body para poderlo crear:

Body

{
	"client": {
		"id": "EJOn9mfqvHpd35aHgQyWYhfDH1e!WW",
		"paymentSource": {
			"source": "token_APkBgCDkVyChAFyCIhVGNRGAESTDjNYjqwOYvaUr"
		}
	},
    "redirect3dsUri": "https://netpay.mx"
}

Response
En este ejemplo el plan que creamos de un principio es del $100 lo cual dentro de la información de plan nos lo indica pero dentro de subscriptions veremos que "amount": 0.0 esto nos indica que los cobros de la suscripción aun no tienen asignado un valor después del primer cobro

{
    "id": "o!cOTso9TGDWe3SvsUnziQlm_2fZiN",
    "plan": {
        "id": "pTkhjeHrjsXTsWQ_XVSV9Y!iyaMfIe",
        "name": "Plan Fijo Adrian 2",
        "amount": 100.0,
        "currency": "MXN",
        "interval": "MONTHLY",
        "frecuency": 1,
        "trialDays": 0,
        "expiryCount": 0,
        "deprecated": 0,
        "active": 1,
        "variableAmount": 1,
        "dayStartPayment": 1,
        "identifier": "plan-id-alumno-3",
        "selfRenewal": 0,
        "selfRetries": 0,
        "terminalView": 0,
        "clientId": 18,
        "groupId": null,
        "createdAt": "2021-03-08T18:08:52.000+0000",
        "updatedAt": "2021-03-08T18:08:52.000+0000",
        "fixed": false,
        "planType": "Variable",
        "periodInDays": 365,
        "nextBillingStart": "2021-04-01T06:00:00.000+0000",
        "dayOfWeek": "MONDAY"
    },
    "client": {
        "id": "EJOn9mfqvHpd35aHgQyWYhfDH1e!WW",
        "name": "Felipe Castillo",
        "firstName": "Felipe",
        "lastName": "Castillo",
        "phone": "1234567890",
        "email": "[email protected]",
        "identifier": "client-id-32",
        "originationClientId": 18,
        "paymentSources": [
            {
                "paymentSource": "token_APkBgCDkVyChAFyCIhVGNRGAESTDjNYjqwOYvaUr",
                "sourceType": "card",
                "cardDefault": null,
                "createdAt": "2021-03-08T18:06:21.000+0000",
                "updatedAt": "2021-03-08T18:06:21.000+0000"
            }
        ],
        "subscriptions": [
            {
                "expiryCount": 0,
                "amount": 0.0,
                "plan": {
                    "id": "pTkhjeHrjsXTsWQ_XVSV9Y!iyaMfIe",
                    "name": "Plan Fijo Adrian 2",
                    "amount": 100.0,
                    "currency": "MXN",
                    "interval": "MONTHLY",
                    "frecuency": 1,
                    "trialDays": 0,
                    "expiryCount": 0,
                    "active": true,
                    "variableAmount": true,
                    "selfRetries": false,
                    "selfRenewal": false,
                    "terminalView": false,
                    "deprecated": false,
                    "dayStartPayment": 1,
                    "identifier": "plan-id-alumno-3",
                    "nextBillingStart": "2021-04-01T06:00:00.000+0000",
                    "createdAt": "2021-03-08T18:08:52.000+0000",
                    "subscriptions": [
                        {
                            "id": "EJOn9mfqvHpd35aHgQyWYhfDH1e!WW",
                            "name": "Felipe Castillo",
                            "phone": "1234567890",
                            "email": "[email protected]",
                            "firstName": "Felipe",
                            "lastName": "Castillo",
                            "createdAt": "2021-03-08T18:06:21.000+0000",
                            "paymentSource": null,
                            "paymentSources": null,
                            "identifier": "client-id-32",
                            "subscriptions": null
                        }
                    ]
                },
                "id": "o!cOTso9TGDWe3SvsUnziQlm_2fZiN"
            }
        ],
        "createdAt": "2021-03-08T18:06:21.000+0000",
        "updatedAt": "2021-03-08T18:06:21.000+0000"
    },
    "cardToken": {
        "token": "token_APkBgCDkVyChAFyCIhVGNRGAESTDjNYjqwOYvaUr",
        "expYear": "21",
        "expMonth": "08",
        "lastFourDigits": "0002",
        "cardHolderName": "John Doe",
        "brand": "visa",
        "deviceFingerPrint": "hdyAWr63jfvf0nnfvyen",
        "ipAddress": "254.254.254.1",
        "used": null,
        "vault": 0,
        "instegrationsdk": null,
        "integrationSdkVersion": null,
        "createdAt": "2021-03-08T18:04:19.000+0000",
        "updatedAt": "2021-03-08T18:04:19.000+0000",
        "vaultInformation": null,
        "simpleUse": false,
        "fromVault": false,
        "tokenWithOutPrefix": "APkBgCDkVyChAFyCIhVGNRGAESTDjNYjqwOYvaUr",
        "typeCard": "001",
        "cardBrand": "visa"
    },
    "status": "A",
    "billingStart": "2021-04-01",
    "billingEnd": null,
    "expiryCount": 0,
    "selfRenewal": 0,
    "selfRetries": 0,
    "amount": 0.0,
    "transactions": [],
    "subscriptionSchedulers": [],
    "createdAt": "2021-03-08T18:11:54.443+0000",
    "updatedAt": "2021-03-08T18:11:54.443+0000",
    "deviceFingerprintID": "0",
    "merchantReferenceCode": "0",
    "proxyIntentSubscriptionCount": null,
    "lastTransactionTokenId": null,
    "nextPaymentDate": null,
    "autocalculateBillingEnd": true,
    "redirect3dsUri": null,
    "finalAmount": 0.0
}

❗️

Imporante

Se debe de hacer un update a la suscripción antes de que llegue la fecha de pago de la suscripción por que esta esta en $0.0 que es el valor con el que nacen las suscripciones de monto variable con el monto variable para que al momento de llegar la fecha de cobro sea con este monto.

Update suscrption*

body

{
	"amount": 200
}

Response

{
    "id": "o!cOTso9TGDWe3SvsUnziQlm_2fZiN",
    "plan": {
        "id": "pTkhjeHrjsXTsWQ_XVSV9Y!iyaMfIe",
        "name": "Plan Fijo Adrian 2",
        "amount": 100.0,
        "currency": "MXN",
        "interval": "MONTHLY",
        "frecuency": 1,
        "trialDays": 0,
        "expiryCount": 0,
        "deprecated": 0,
        "active": 1,
        "variableAmount": 1,
        "dayStartPayment": 1,
        "identifier": "plan-id-alumno-3",
        "selfRenewal": 0,
        "selfRetries": 0,
        "terminalView": 0,
        "clientId": 18,
        "groupId": null,
        "createdAt": "2021-03-08T18:08:52.000+0000",
        "updatedAt": "2021-03-08T18:08:52.000+0000",
        "fixed": false,
        "planType": "Variable",
        "periodInDays": 365,
        "nextBillingStart": "2021-04-01T06:00:00.000+0000",
        "dayOfWeek": "MONDAY"
    },
    "client": {
        "id": "EJOn9mfqvHpd35aHgQyWYhfDH1e!WW",
        "name": "Felipe Castillo",
        "firstName": "Felipe",
        "lastName": "Castillo",
        "phone": "1234567890",
        "email": "[email protected]",
        "identifier": "client-id-32",
        "originationClientId": 18,
        "paymentSources": [
            {
                "paymentSource": "token_APkBgCDkVyChAFyCIhVGNRGAESTDjNYjqwOYvaUr",
                "sourceType": "card",
                "cardDefault": null,
                "createdAt": "2021-03-08T18:06:21.000+0000",
                "updatedAt": "2021-03-08T18:06:21.000+0000"
            }
        ],
        "subscriptions": [
            {
                "expiryCount": 0,
                "amount": 0.0,
                "plan": {
                    "id": "pTkhjeHrjsXTsWQ_XVSV9Y!iyaMfIe",
                    "name": "Plan Fijo Adrian 2",
                    "amount": 100.0,
                    "currency": "MXN",
                    "interval": "MONTHLY",
                    "frecuency": 1,
                    "trialDays": 0,
                    "expiryCount": 0,
                    "active": true,
                    "variableAmount": true,
                    "selfRetries": false,
                    "selfRenewal": false,
                    "terminalView": false,
                    "deprecated": false,
                    "dayStartPayment": 1,
                    "identifier": "plan-id-alumno-3",
                    "nextBillingStart": "2021-04-01T06:00:00.000+0000",
                    "createdAt": "2021-03-08T18:08:52.000+0000",
                    "subscriptions": [
                        {
                            "id": "EJOn9mfqvHpd35aHgQyWYhfDH1e!WW",
                            "name": "Felipe Castillo",
                            "phone": "1234567890",
                            "email": "[email protected]",
                            "firstName": "Felipe",
                            "lastName": "Castillo",
                            "createdAt": "2021-03-08T18:06:21.000+0000",
                            "paymentSource": null,
                            "paymentSources": null,
                            "identifier": "client-id-32",
                            "subscriptions": null
                        }
                    ]
                },
                "id": "o!cOTso9TGDWe3SvsUnziQlm_2fZiN"
            }
        ],
        "createdAt": "2021-03-08T18:06:21.000+0000",
        "updatedAt": "2021-03-08T18:06:21.000+0000"
    },
    "cardToken": {
        "token": "token_APkBgCDkVyChAFyCIhVGNRGAESTDjNYjqwOYvaUr",
        "expYear": "21",
        "expMonth": "08",
        "lastFourDigits": "0002",
        "cardHolderName": "John Doe",
        "brand": "visa",
        "deviceFingerPrint": "hdyAWr63jfvf0nnfvyen",
        "ipAddress": "254.254.254.1",
        "used": null,
        "vault": 0,
        "instegrationsdk": null,
        "integrationSdkVersion": null,
        "createdAt": "2021-03-08T18:04:19.000+0000",
        "updatedAt": "2021-03-08T18:04:19.000+0000",
        "vaultInformation": null,
        "simpleUse": false,
        "fromVault": false,
        "tokenWithOutPrefix": "APkBgCDkVyChAFyCIhVGNRGAESTDjNYjqwOYvaUr",
        "typeCard": "001",
        "cardBrand": "visa"
    },
    "status": "A",
    "billingStart": "2021-04-01",
    "billingEnd": null,
    "expiryCount": 0,
    "selfRenewal": 0,
    "selfRetries": 0,
    "amount": 200.0,
    "transactions": [],
    "subscriptionSchedulers": [
        {
            "subscription": null,
            "adqResponse": null,
            "status": "W",
            "paymentDate": "2021-04-01T06:00:00.000+0000",
            "createdAt": "2021-03-08T18:11:54.000+0000",
            "updatedAt": null,
            "transaction": null,
            "id": null
        }
    ],
    "createdAt": "2021-03-08T18:11:54.000+0000",
    "updatedAt": "2021-03-08T18:13:27.165+0000",
    "deviceFingerprintID": "0",
    "merchantReferenceCode": "0",
    "proxyIntentSubscriptionCount": null,
    "lastTransactionTokenId": null,
    "nextPaymentDate": null,
    "autocalculateBillingEnd": true,
    "redirect3dsUri": null,
    "finalAmount": 200.0
}

Donde encontraras la información de tu suscripción variable serán estos datos del JSON de respuesta.

"status": "A",
    "billingStart": "2021-04-01",
    "billingEnd": null,
    "expiryCount": 0,
    "selfRenewal": 0,
    "selfRetries": 0,
    "amount": 200.0,
    "transactions": []