• França
lyra.com
Procurando
Categoria
Tags
pagina inicial
Suporte técnico

Teste rápido

Está página permite ver rapidamente como criar uma transação com nossos Web Service Rest de pagamento.

Preparar seu ambiente

Se você usar PHP com nosso SDK, recomendamos salvar todas suas chaves em um arquivo de configuração.

Exemplo com as chaves de testes:

https://github.com/lyra/rest-php-examples/blob/master/www/keys.PCI.php

<?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");

Não esqueça de substituí-las pelas suas chaves pessoais.

Para maiores informações, consultar SDKs server e Pré-requisitos

Criar uma transação

Para criar uma nova transação a partir de um novo meio de pagamento, é preciso usar o Web Service Charge/CreatePayment :

/pt-BR/rest/V4.0/api/kb/authentication.html
https://github.com/lyra/rest-php-examples/blob/master/www/PCI.php#L9-L49
https://api.lyra.com/api-payment/V4/Charge/CreatePayment
{
    "amount": 990,
    "currency": "EUR",
    "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);

Dois tipos de respostas são possíveis (definido em answer._type ):

VALOR Descrição
V4/Payment Sem 3D-Secure, a resposta apresenta o detalhe da transação que foi criada.
V4/Charge/Redirect/Request Uma autenticação forte (como 3D-Secure) é requerida. Precisa redirecionar o comprador.

Para maiores informações sobre o tratamento da resposta V4/Charge/RedirectRequest e a autenticação forte como o 3D-Secure, favor consultar: Criar uma transação (PCI e 3D Secure).

Exemplo de resposta V4/Payment :

{
    "webService": "Charge/CreatePayment",
    "version": "V4",
    "applicationVersion": "4.1.2",
    "status": "SUCCESS",
    "answer": {
        "shopId": "69876357",
        "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": "69876357",
            "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": "LYRA",
    "metadata": null,
    "_type": "V4/WebService/Response"
}

Para maiores informações consultar Charge/CreatePayment.

Verificar o status da transação

Para saber o status da transação, é preciso analisar o valor da propriedade answer.orderStatus :

Status Descrição
UNPAID A transação não foi paga.
RUNNING A transação está esperando um evento.
PAID A transação foi paga.

Para maiores detalhes sobre a estrutura da resposta: Charge/CreatePayment.

Você pode usar nosso playground interactif para descobrir todos nossos Web Services.

Para maiores informações sobre o gerenciamento dos status, consultar: Ciclo de vida das transações.

Jobs
Legal
GDPR
25.22-1.11