Probar rápidamente
Esta página ofrece una descripción rápida de cómo crear una transacción de pago con nuestro Web Service Rest.
Preparar su entorno
Si usa PHP con nuestro SDK, le recomendamos que agrupe sus claves en un archivo de configuración.
Ejemplo con claves de test:
Recuerde sustituirlas por sus claves personales.
Para más información, vea Servidor de SDK y Requisitos previos
Crear una transacción
Para crear una nueva transacción a partir de un nuevo modo de pago, es necesario utilizar el Web Service Charge/CreatePayment :
{ "amount": 180, "currency": "PEN", "paymentForms": [ { "paymentMethodType": "CARD", "pan": "4970100000000055", "expiryMonth": "11", "expiryYear": "21", "securityCode": "123" } ] } }
Son posibles dos tipos de respuestas (definidas en answer._type):
VALOR | Descripción |
---|---|
V4/Payment | Sin 3-D Secure, la respuesta contiene el detalle de la transacción recién creada. |
Charge/RedirectRequest | Se requiere autentificación fuerte (como 3-D Secure). Hay que redirigir al comprador. |
Para más información sobre el procesamiento de la respuesta V4/Charge/RedirectRequest y autentificación fuerte como el 3-D Secure, consulte: Crear una transacción (PCI y 3-D Secure).
Ejemplo de respuesta V4/Payment :
{ "webService": "Charge/CreatePayment", "version": "V4", "applicationVersion": "4.1.2", "status": "SUCCESS", "answer": { "shopId": "89289758", "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": "89289758", "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": "MCW", "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, hay que analizar el valor de la propiedad answer.orderStatus:
STATUT | Descripción |
---|---|
UNPAID | La transacción no ha sido pagada. |
RUNNING | La transacción está a la espera de un evento. |
PAID | La transacción ha sido pagada. |
Para más información sobre la estructura de la respuesta: Charge/CreatePayment.
Puede usar nuestro Playground interactivo para descubrir todos nuestros Web Services.
Para más información sobre la gestión de los estados, consulte: Ciclo de vida de una transacción.