Creating a transaction (PCI)

If you are PCI-DSS certified, you have the right to collect sensitive information related to the payment method on your website. You can then create a new transaction using the Charge/CreatePayment Web Service by directly passing the information related to the payment method.

Prepare one''s environment

If you use PHP with our SDK, we recommend to store your keys in a configuration file.

Example with test keys:

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

Do not forget to replace them with your personal keys.

For more information, see Server SDKs and Prerequisites

Create a new transaction

In order to create a new transaction using a new payment method, one must use the Charge/CreatePayment Web Service:

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

Two types of responses are possible (defined in answer._type):

Value Description
V4/Payment No 3D Secure, the response contains the details of the newly created transaction.
V4/Charge/RedirectRequest Strong authentication (such as 3D Secure) is required. The buyer must be redirected.

For more information on processing of the V4/Charge/RedirectRequest response and strong authentication, such as 3D Secure, go to: Creating a transaction (PCI and 3D Secure)

Example of V4/Payment response:

{
    "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"
}

For more information, see Charge/CreatePayment.

Verify the transaction status

To view the transaction status, one must analyze the value of the answer.orderStatus property:

STATUS DESCRIPTION
UNPAID The transaction has not been paid.
RUNNING The transaction is expecting an event.
PAID The transaction has been paid.

For more information on the structure of the response: Charge/CreatePayment.

You can use our interactive playground to discover all our Web Services.

For more information on handling statuses, go to: Transaction lifecycle.