Prueba rápida

Esta página ofrece una descripción rápida de cómo crear una transacción de pago con nuestro Servicio Web Rest.

Prepare su entorno

Si usa PHP con nuestro SDK, le recomendamos que agrupe sus claves en un archivo de configuración.

Ejemplo con claves de prueba:

<?php
/**
 * Get the client
 */
require_once __DIR__ . '/vendor/autoload.php';

/**
 * Define configuration
 */

/* Username, password and endpoint used for server to server web-service calls */
Lyra\Client::setDefaultUsername("69876357");
Lyra\Client::setDefaultPassword("testpassword_DEMOPRIVATEKEY23G4475zXZQ2UA5x7M");
Lyra\Client::setDefaultEndpoint("https://api.payzen.eu");


Recuerde sustituirlas por sus claves personales.

Para más información, consulte Servidor de SDK y Requisitos previos.

Crear una transacción

Para crear una nueva transacción a partir de un nuevo medio de pago, es necesario utilizar el Web Service Charge/CreatePayment:

{
    "amount": 990,
    "currency": "COP",
    "paymentForms": [
        {
          "paymentMethodType": "CARD",
          "pan": "4970100000000055",
          "expiryMonth": "11",
          "expiryYear": "21",
          "securityCode": "123"
        }
      ]
    }
}
/**
 * I initialize the PHP SDK
 */
require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/keys.PCI.php';
require_once __DIR__ . '/helpers.php';

/** 
 * Initialize the SDK 
 * see keys.php
 */
$client = new Lyra\Client();

/**
 * Define the card to use
 */
$card = array(
  "paymentMethodType" => "CARD",
  "pan" => "4970100000000055",
  "expiryMonth" => "11",
  "expiryYear" => "21",
  "securityCode" => "123"
);

/**
 * starting to create a transaction
 */
$store = array(
  "amount" => 250, 
  "currency" => "EUR",
  "formAction" => "REGISTER_PAY",
  "paymentForms" => array($card),
  "customer" => array(
    "email" => "sample@example.com",
    "orderId" => uniqid("MyOrderId")
));

/**
 * do the web-service call
 */
$response = $client->post("V4/Charge/CreatePayment", $store);

Hay dos tipos de respuestas posibles (definidas en answer._type):

Valor Descripción
V4/Payment Sin 3D Secure, la respuesta contiene el detalle de la transacción recién creada.
Charge/RedirectRequest Se requiere autenticación fuerte (como 3D Secure). Es necesario redirigir al comprador.

Para más información sobre el procesamiento de la respuesta V4/Charge/RedirectRequest y la autenticación fuerte como 3D Secure, consulte: Crear una transacción (PCI y 3D Secure).

Ejemplo de respuesta V4/Payment :

{
    "webService": "Charge/CreatePayment",
    "version": "V4",
    "applicationVersion": "4.1.2",
    "status": "SUCCESS",
    "answer": {
        "shopId": "28478261",
        "orderCycle": "CLOSED",
        "orderStatus": "PAID",
        "orderDetails": {
            "orderTotalAmount": 990,
            "orderCurrency": "EUR",
            "mode": "TEST",
            "orderId": "myOrderId-607382",
            "_type": "V4/OrderDetails"
        },
        "customer": {
            "email": "sample@example.com",
            "reference": null,
            "billingDetails": {
                "address": null,
                "category": null,
                "cellPhoneNumber": null,
                "city": null,
                "country": null,
                "district": null,
                "firstName": null,
                "identityCode": null,
                "language": "FR",
                "lastName": null,
                "phoneNumber": null,
                "state": null,
                "streetNumber": null,
                "title": null,
                "zipCode": null,
                "_type": "V4/Customer/BillingDetails"
            },
            "shippingDetails": {
                "address": null,
                "address2": null,
                "category": null,
                "city": null,
                "country": null,
                "deliveryCompanyName": null,
                "district": null,
                "firstName": null,
                "identityCode": null,
                "lastName": null,
                "legalName": null,
                "phoneNumber": null,
                "shippingMethod": null,
                "shippingSpeed": null,
                "state": null,
                "streetNumber": null,
                "zipCode": null,
                "_type": "V4/Customer/ShippingDetails"
            },
            "extraDetails": {
                "browserAccept": null,
                "fingerPrintId": null,
                "ipAddress": "90.71.64.161",
                "browserUserAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36",
                "_type": "V4/Customer/ExtraDetails"
            },
            "shoppingCart": {
                "insuranceAmount": null,
                "shippingAmount": null,
                "taxAmount": null,
                "cartItemInfo": null,
                "_type": "V4/Customer/ShoppingCart"
            },
            "_type": "V4/Customer/Customer"
        },
        "transactions": [
        {
            "shopId": "28478261",
            "uuid": "7af034f2883240c2876f6c61c7eab8ea",
            "amount": 990,
            "currency": "EUR",
            "paymentMethodType": "CARD",
            "paymentMethodToken": null,
            "status": "PAID",
            "detailedStatus": "AUTHORISED",
            "operationType": "DEBIT",
            "effectiveStrongAuthentication": "DISABLED",
            "creationDate": "2018-10-02T16:38:12+00:00",
            "errorCode": null,
            "errorMessage": null,
            "detailedErrorCode": null,
            "detailedErrorMessage": null,
            "metadata": null,
            "transactionDetails": {
            "liabilityShift": "NO",
            "effectiveAmount": 990,
            "effectiveCurrency": "EUR",
            "creationContext": "CHARGE",
            "cardDetails": {
                "paymentSource": "EC",
                "manualValidation": "NO",
                "expectedCaptureDate": "2018-10-02T16:38:12+00:00",
                "effectiveBrand": "CB",
                "pan": "497010XXXXXX0055",
                "expiryMonth": 11,
                "expiryYear": 2021,
                "country": "FR",
                "emisorCode": null,
                "effectiveProductCode": "F",
                "legacyTransId": "916940",
                "legacyTransDate": "2018-10-02T16:38:12+00:00",
                "paymentMethodSource": "NEW",
                "authorizationResponse": {
                "amount": 990,
                "currency": "EUR",
                "authorizationDate": "2018-10-02T16:38:12+00:00",
                "authorizationNumber": "3fcdf2",
                "authorizationResult": "0",
                "authorizationMode": "FULL",
                "_type": "V4/PaymentMethod/Details/Cards/CardAuthorizationResponse"
                },
                "captureResponse": {
                    "refundAmount": null,
                    "captureDate": null,
                    "captureFileNumber": null,
                    "refundCurrency": null,
                    "_type": "V4/PaymentMethod/Details/Cards/CardCaptureResponse"
                    },
                "threeDSResponse": {
                    "authenticationResultData": {
                    "transactionCondition": "COND_3D_ERROR",
                    "enrolled": "UNKNOWN",
                    "status": "UNKNOWN",
                    "eci": null,
                    "xid": null,
                    "cavvAlgorithm": null,
                    "cavv": null,
                    "signValid": null,
                    "brand": "VISA",
                    "_type": "V4/PaymentMethod/Details/Cards/CardAuthenticationResponse"
                    },
                "_type": "V4/PaymentMethod/Details/Cards/ThreeDSResponse"
                },
                "installmentNumber": null,
                "markAuthorizationResponse": {
                    "amount": null,
                    "currency": null,
                    "authorizationDate": null,
                    "authorizationNumber": null,
                    "authorizationResult": null,
                    "_type": "V4/PaymentMethod/Details/Cards/MarkAuthorizationResponse"
                    },
                "_type": "V4/PaymentMethod/Details/CardDetails"
                },
            "parentTransactionUuid": null,
            "mid": "6969696",
            "sequenceNumber": 1,
            "_type": "V4/TransactionDetails"
            },
            "_type": "V4/PaymentTransaction"
            }
        ],
        "serverDate": "2018-10-02T16:38:13+00:00",
        "_type": "V4/Payment"
    },
    "ticket": null,
    "serverDate": "2018-10-02T16:38:13+00:00",
    "applicationProvider": "PAYZEN",
    "metadata": null,
    "_type": "V4/WebService/Response"
}

Más información aquí: Charge/CreatePayment.

Verificar el estado de la transacción

Para conocer el estado de la transacción es necesario analizar el valor de la propiedad answer.orderStatus:

ESTADO DESCRIPCIÓN
UNPAID La transacción no se ha pagado.
RUNNING La transacción está a la espera de un evento.
PAID La transacción ha sido pagada.

Para más detalles sobre la estructura de la respuesta: Charge/CreatePayment.

Para descubrir todos nuestros servicios web, le invitamos a usar nuestro playground interactivo.

Para más información sobre la gestión de los estados, consulte: Ciclo de vida de una transacción.