Créer une transaction (PCI)

Si vous êtes certifié PCI-DSS, vous êtes habilité à collecter les informations sensibles du moyen de paiement sur votre site. Vous pouvez ensuite créer une nouvelle transaction à l’aide du Web Service Charge/CreatePayment en passant directement les informations du moyen de paiement.

Préparer son environement

Si vous utilisez PHP avec notre SDK, nous vous recommandons de regrouper vos clefs dans un fichier de configuration.

Exemple avec les clés de tests:

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

Pensez à les remplacer avec vos clés personnelles.

Pour plus d’informations, voir SDKs server et Prérequis

Créer une transaction

Pour créer une nouvelle transaction à partir d’un nouveau moyen de paiement, il faut utiliser le Web Service 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);

Deux types de réponses sont possibles (défini dans answer._type):

Valeur Description
V4/Payment Pas de 3D-Secure, la réponse contient le détail de la transaction nouvellement créée.
V4/Charge/RedirectRequest Une authentification forte (comme 3D-Secure) est requise. Il faut rediriger l’acheteur.

Pour plus d’informations sur le traitement de la réponse V4/Charge/RedirectRequest et l’authentification forte comme 3D-Secure, rendez-vous ici: Créer une transaction (PCI et 3D Secure).

Exemple de réponse 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": "PAYZEN",
    "metadata": null,
    "_type": "V4/WebService/Response"
}

Plus d’informations ici Charge/CreatePayment.

Vérifier le statut de la transaction

Pour connaitre le statut de la transaction, il faut analyser la valeur de la propriété answer.orderStatus:

STATUT DESCRIPTION
UNPAID La transaction n’est pas payée.
RUNNING La transaction est en attente d’un évènement.
PAID La transaction est payée.

Pour plus de détails sur la structure de la réponse: Charge/CreatePayment.

Vous pouvez utiliser notre playground interactif pour découvrir tous nos Web Services.

Pour plus d’informations sur la gestion des statuts, rendez-vous ici: Cycle de vie d’une transaction.