PHP code example of signifyd / signifyd-php

1. Go to this page and download the library: Download signifyd/signifyd-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

signifyd / signifyd-php example snippets



    // This might differ depending on the location of the file from which you your project
    


    // This might differ depending on the location of the file from which you your project
    ew \Signifyd\Core\Api\CheckoutApi($settings);

    ....
    // Checkout data
    $checkoutData = [
        "orderId"    => "ORDER-10045",
        "checkoutId" => "CHECKOUT-10045",
        "purchase" => [
            // Data related to the purchase event represented in this Checkout Creation request.
        ],
        "checkoutPaymentDetails" => [
            // Data related to the payment method and billing address used at checkout.
        ],
        "userAccount" => [
            // User account data if the buyer has an account.
        ],
    ];
    $checkoutResponse = $checkoutApi->createCheckout($checkoutData);
    ....

    ....
    $checkout = new \Signifyd\Models\Checkout();
    // Purchase array data or Purchase Object
    $checkout->setPurchase($purchase);
    
    // CheckoutPaymentDetails array data or CheckoutPaymentDetails Object
    $checkout->setCheckoutPaymentDetails($checkoutPaymentDetails);
    
    // userAccount array data or userAccount Object
    $checkout->setUserAccount($userAccount);
    
    $checkoutResponse = $checkoutApi->createCheckout($checkout);

    ....
    $orderId = 'ORDER-10045';
    $decisionResponse = $checkoutApi->getDecision($orderId);
    ....


    // This might differ depending on the location of the file from which you your project
    


    // This might differ depending on the location of the file from which you your project
    = new \Signifyd\Core\Api\TransactionApi($settings);

    ....
    $transactionData = [
        "orderId"    => "ORDER-10045",
        "checkoutId" => "CHECKOUT-10045",
        "transactions" => [
            [
                "transactionId"        => "TXN-78912",
                "currency"             => "USD",
                "amount"               => 129.99,
                "paymentMethod"        => "CREDIT_CARD",
                "gateway"              => "stripe",
                "gatewayStatusCode"    => "200",
                "gatewayStatusMessage" => "approved",
                "type"                 => "AUTHORIZATION",
                "avsResponseCode"      => "Y",
                "cvvResponseCode"      => "M",
                "checkoutPaymentDetails" => [
                    "cardBin"   => "411111",
                    "cardLast4" => "1111"
                ]
            ]
        ]
    ];
    $transactionResponse = $transactionApi->createTransaction($transactionData);
    ....


    // This might differ depending on the location of the file from which you your project
    


    // This might differ depending on the location of the file from which you your project
    Signifyd\Core\Api\SaleApi($settings);

    ....
    // Sale data
    $saleData = [
        "orderId" => "ORDER-10046",
        "purchase" => [
            // Data related to the purchase event represented in this Sale Creation request.
        ],
        "transactions" => [
            // Data related to the payment transaction(s) for this order.
        ],
        "userAccount" => [
            // User account data if the buyer has an account.
        ],
    ];
    $saleResponse = $saleApi->createSale($saleData);
    ....

    ....
    $sale = new \Signifyd\Models\Sale();
    // Purchase array data or Purchase Object
    $sale->setPurchase($purchase);
    
    // Transaction array data or Transaction Object
    $sale->setTransactions($transactions);
    
    // userAccount array data or userAccount Object
    $sale->setUserAccount($userAccount);
    
    $saleResponse = $saleApi->createSale($sale);


    // This might differ depending on the location of the file from which you your project
    


    // This might differ depending on the location of the file from which you your project
    = new \Signifyd\Core\Api\FulfillmentApi($settings);

    ....
    $fulfillmentData = [
        "orderId" => "ORDER-10046",
        "fulfillments" => [
            // Fulfillment data
        ]
    ];
    $fulfillmentResponse = $fulfillmentApi->createFulfillment($fulfillmentData);
    ....

    ....
    $client = new \GuzzleHttp\Client();
    $response = $client->request('POST', 'https://api.signifyd.com/v3/orders/events/reroutes', [
        'headers' => [
            'accept'        => 'application/json',
            'content-type'  => 'application/json',
            'Authorization' => 'Basic ' . base64_encode('YOUR_API_KEY:'),
        ],
        'json' => [
            'orderId'   => 'ORDER-10045',
            'shipments' => [
                [
                    'destination' => [
                        'fullName'      => 'Jane Smith',
                        'streetAddress' => '456 New Ave',
                        'city'          => 'Austin',
                        'provinceCode'  => 'TX',
                        'postalCode'    => '73301',
                        'countryCode'   => 'US',
                    ],
                ],
            ],
        ],
    ]);
    echo $response->getBody();
    ....

    ....
    $client = new \GuzzleHttp\Client();
    $response = $client->request('GET', 'https://api.signifyd.com/v3/orders/ORDER-10045/decision', [
        'headers' => [
            'accept'        => 'application/json',
            'Authorization' => 'Basic ' . base64_encode('YOUR_API_KEY:'),
        ],
    ]);
    echo $response->getBody();
    ....

    ....
    $client = new \GuzzleHttp\Client();
    $response = $client->request('GET', 'https://api.signifyd.com/v3/orders/ORDER-10045/decisions', [
        'headers' => [
            'accept'        => 'application/json',
            'Authorization' => 'Basic ' . base64_encode('YOUR_API_KEY:'),
        ],
    ]);
    echo $response->getBody();
    ....

    ....
    $client = new \GuzzleHttp\Client();
    $response = $client->request('POST', 'https://api.signifyd.com/v3/orders/events/returns/attempts', [
        'headers' => [
            'accept'        => 'application/json',
            'content-type'  => 'application/json',
            'Authorization' => 'Basic ' . base64_encode('YOUR_API_KEY:'),
        ],
        'json' => [
            'orderId'      => 'ORDER-10045',
            'returnId'     => 'RETURN-001',
            'returnDate'   => '2024-09-20T10:00:00Z',
            'returnPolicy' => 'EVALUATE',
            'returnedItems' => [
                [
                    'itemId'       => 'SKU-001',
                    'itemName'     => 'Wireless Headphones',
                    'itemQuantity' => 1,
                    'itemPrice'    => 129.99,
                ],
            ],
            'refund' => [
                'amount'   => 129.99,
                'currency' => 'USD',
            ],
        ],
    ]);
    echo $response->getBody();
    ....

    ....
    $client = new \GuzzleHttp\Client();
    $response = $client->request('POST', 'https://api.signifyd.com/v3/orders/events/returns/executions', [
        'headers' => [
            'accept'        => 'application/json',
            'content-type'  => 'application/json',
            'Authorization' => 'Basic ' . base64_encode('YOUR_API_KEY:'),
        ],
        'json' => [
            'orderId'      => 'ORDER-10045',
            'returnId'     => 'RETURN-001',
            'returnStatus' => 'REFUNDED',
            'executedAt'   => '2024-09-21T14:00:00Z',
        ],
    ]);
    echo $response->getBody();
    ....

    ....
    $client = new \GuzzleHttp\Client();
    $response = $client->request('POST', 'https://api.signifyd.com/v3/orders/events/returns/records', [
        'headers' => [
            'accept'        => 'application/json',
            'content-type'  => 'application/json',
            'Authorization' => 'Basic ' . base64_encode('YOUR_API_KEY:'),
        ],
        'json' => [
            'orderId'      => 'ORDER-10045',
            'returnId'     => 'RETURN-002',
            'returnStatus' => 'REFUNDED',
            'returnDate'   => '2024-09-21T14:00:00Z',
            'returnedItems' => [
                [
                    'itemId'       => 'SKU-202',
                    'itemQuantity' => 1,
                    'itemPrice'    => 74.99,
                ],
            ],
            'refund' => [
                'amount'            => 74.99,
                'currency'          => 'USD',
                'refundTransactionId' => 'TXN-REFUND-001',
            ],
        ],
    ]);
    echo $response->getBody();
    ....

    ....
    $client = new \GuzzleHttp\Client();
    $response = $client->request('POST', 'https://api.signifyd.com/v3/orders/events/returns/feedback', [
        'headers' => [
            'accept'        => 'application/json',
            'content-type'  => 'application/json',
            'Authorization' => 'Basic ' . base64_encode('YOUR_API_KEY:'),
        ],
        'json' => [
            'orderId'       => 'ORDER-10045',
            'returnId'      => 'RETURN-001',
            'returnOutcome' => 'GOOD',
            'feedbackAt'    => '2024-09-25T10:00:00Z',
        ],
    ]);
    echo $response->getBody();
    ....

    ....
    $client = new \GuzzleHttp\Client();
    $response = $client->request('POST', 'https://api.signifyd.com/v3/orders/events/chargebacks', [
        'headers' => [
            'accept'        => 'application/json',
            'content-type'  => 'application/json',
            'Authorization' => 'Basic ' . base64_encode('YOUR_API_KEY:'),
        ],
        'json' => [
            'orderId'      => 'ORDER-10045',
            'chargebackId' => 'CB-78901',
            'chargeback'   => [
                'amount'   => 74.99,
                'currency' => 'USD',
                'reason'   => 'FRAUD',
            ],
        ],
    ]);
    echo $response->getBody();
    ....

    ....
    $client = new \GuzzleHttp\Client();
    $response = $client->request('POST', 'https://api.signifyd.com/v3/orders/events/chargebacks/stages', [
        'headers' => [
            'accept'        => 'application/json',
            'content-type'  => 'application/json',
            'Authorization' => 'Basic ' . base64_encode('YOUR_API_KEY:'),
        ],
        'json' => [
            'orderId'         => 'ORDER-10045',
            'chargebackId'    => 'CB-78901',
            'chargebackStage' => 'CHARGEBACK',
            'dueDate'         => '2024-10-15T00:00:00Z',
        ],
    ]);
    echo $response->getBody();
    ....


    // This might differ depending on the location of the file from which you your project
    


    // This might differ depending on the location of the file from which you your project
    w \Signifyd\Core\Api\WebhookApi($settings);

    ....
    $webhook = new \Signifyd\Models\Webhook([
        "url"     => "https://your-store.com/signifyd/webhook",
        "event"   => "ORDER_CHECKPOINT_ACTION_UPDATE",
        "enabled" => true
    ]);
    $webhookResponse = $webhookApi->createWebhook($webhook);
    ....

    ....
    $webhook = new \Signifyd\Models\Webhook([
        // Webhook data
    ]);
    $webhookResponse = $webhookApi->updateWebhook($webhook);
    ....

    ....
    $webhookResponse = $webhookApi->getWebhooks();
    ....

    ....
    $webhook = new \Signifyd\Models\Webhook([
        // Webhook data
    ]);
    $webhookResponse = $webhookApi->deleteWebhook($webhook);
    ....

    ....
    $client = new \GuzzleHttp\Client();
    $response = $client->request('POST', 'https://api.signifyd.com/v2/consumers/events/modifications', [
        'headers' => [
            'accept'       => 'application/json',
            'content-type' => 'application/json',
            'Authorization' => 'Basic ' . base64_encode('YOUR_API_KEY:'),
        ],
        'json' => [
            'modifiedField'    => 'FIELD_EMAIL',
            'modifiedAt'       => '2024-09-15T14:23:00Z',
            'newEmail'         => '[email protected]',
            'loginMethodType'  => 'PASSWORD',
            'userFingerprint'  => 'abc123fingerprint',
            'emailIdentifier'  => '[email protected]',
            'device'           => [
                'browserIpAddress' => '192.168.1.1',
            ],
        ],
    ]);
    echo $response->getBody();
    ....

    ....
    $client = new \GuzzleHttp\Client();
    $response = $client->request('POST', 'https://api.signifyd.com/v2/consumers/events/logins', [
        'headers' => [
            'accept'       => 'application/json',
            'content-type' => 'application/json',
            'Authorization' => 'Basic ' . base64_encode('YOUR_API_KEY:'),
        ],
        'json' => [
            'loginMethodType'  => 'PASSWORD',
            'loginResult'      => 'SUCCESS',
            'loginAt'          => '2024-09-15T14:23:00Z',
            'loginAccountId'   => 'ACC-9876',
            'isNewDevice'      => false,
            'emailIdentifier'  => '[email protected]',
            'device'           => [
                'browserIpAddress' => '192.168.1.1',
            ],
        ],
    ]);
    echo $response->getBody();
    ....

    ....
    $client = new \GuzzleHttp\Client();
    $response = $client->request('POST', 'https://api.signifyd.com/v2/consumers/events/openings', [
        'headers' => [
            'accept'       => 'application/json',
            'content-type' => 'application/json',
            'Authorization' => 'Basic ' . base64_encode('YOUR_API_KEY:'),
        ],
        'json' => [
            'openingId'       => 'OPENING-10001',
            'fullName'        => 'John Doe',
            'accountNumber'   => 'ACC-9876',
            'email'           => '[email protected]',
            'verifiedEmail'   => true,
            'phone'           => '5555551212',
            'verifiedPhone'   => false,
            'createdAt'       => '2024-09-15T14:23:00Z',
            'signupMethod'    => 'PASSWORD',
            'accountType'     => 'SILVER',
            'emailIdentifier' => '[email protected]',
            'device'          => [
                'browserIpAddress' => '192.168.1.1',
            ],
        ],
    ]);
    echo $response->getBody();
    ....

    ....
    $client = new \GuzzleHttp\Client();
    $response = $client->request('GET', 'https://api.signifyd.com/v3/partners/0/organizations/12345', [
        'headers' => [
            'accept'        => 'application/json',
            'Authorization' => 'Basic ' . base64_encode('YOUR_API_KEY:'),
        ],
    ]);
    echo $response->getBody();
    ....

    ....
    $client = new \GuzzleHttp\Client();
    $response = $client->request('POST', 'https://api.signifyd.com/v3/partners/0/organizations/12345/members', [
        'headers' => [
            'accept'        => 'application/json',
            'content-type'  => 'application/json',
            'Authorization' => 'Basic ' . base64_encode('YOUR_API_KEY:'),
        ],
        'json' => [
            'userId' => 123456,
            'role'   => 'MEMBER',
        ],
    ]);
    echo $response->getBody();
    ....

    ....
    $client = new \GuzzleHttp\Client();
    $response = $client->request('POST', 'https://api.signifyd.com/v3/partners/0/users', [
        'headers' => [
            'accept'       => 'application/json',
            'content-type' => 'application/json',
            'Authorization' => 'Basic ' . base64_encode('YOUR_API_KEY:'),
        ],
        'json' => [
            'email' => '[email protected]',
        ],
    ]);
    echo $response->getBody();
    ....

    ....
    $client = new \GuzzleHttp\Client();
    $response = $client->request('POST', 'https://api.signifyd.com/v3/partners/0/teams', [
        'headers' => [
            'accept'       => 'application/json',
            'content-type' => 'application/json',
            'Authorization' => 'Basic ' . base64_encode('YOUR_API_KEY:'),
        ],
        'json' => [
            'orgId'               => 12345,
            'name'                => 'Initrode East Division',
            'website'             => 'https://initrode-east.com',
            'chargebackSettings'  => 'CHARGEBACKSETTINGS_DIRECT',
            'merchantDescription' => 'A retail store chain',
        ],
    ]);
    echo $response->getBody();
    ....

    ....
    $client = new \GuzzleHttp\Client();
    $response = $client->request('GET', 'https://api.signifyd.com/v3/partners/0/teams/789123', [
        'headers' => [
            'accept'        => 'application/json',
            'Authorization' => 'Basic ' . base64_encode('YOUR_API_KEY:'),
        ],
    ]);
    echo $response->getBody();
    ....

    ....
    $client = new \GuzzleHttp\Client();
    $response = $client->request('POST', 'https://api.signifyd.com/v3/partners/0/teams/789123', [
        'headers' => [
            'accept'       => 'application/json',
            'content-type' => 'application/json',
            'Authorization' => 'Basic ' . base64_encode('YOUR_API_KEY:'),
        ],
        'json' => [
            'name'                => 'Initrode East Division',
            'website'             => 'https://initrode-east.com',
            'merchantDescription' => 'A retail store chain',
        ],
    ]);
    echo $response->getBody();
    ....

    ....
    $client = new \GuzzleHttp\Client();
    $response = $client->request('POST', 'https://api.signifyd.com/v3/partners/0/teams/789123/live', [
        'headers' => [
            'accept'        => 'application/json',
            'Authorization' => 'Basic ' . base64_encode('YOUR_API_KEY:'),
        ],
    ]);
    echo $response->getBody();
    ....

    ....
    $client = new \GuzzleHttp\Client();
    $response = $client->request('POST', 'https://api.signifyd.com/v3/partners/0/teams/789123/products', [
        'headers' => [
            'accept'       => 'application/json',
            'content-type' => 'application/json',
            'Authorization' => 'Basic ' . base64_encode('YOUR_API_KEY:'),
        ],
        'json' => [
            'product' => 'GFP',
        ],
    ]);
    echo $response->getBody();
    ....

    ....
    $client = new \GuzzleHttp\Client();
    $response = $client->request('GET', 'https://api.signifyd.com/v3/partners/0/teams/789123/members', [
        'headers' => [
            'accept'        => 'application/json',
            'Authorization' => 'Basic ' . base64_encode('YOUR_API_KEY:'),
        ],
        'query' => [
            'limit'  => 50,
            'offset' => 0,
        ],
    ]);
    echo $response->getBody();
    ....

    ....
    $client = new \GuzzleHttp\Client();
    $response = $client->request('POST', 'https://api.signifyd.com/v3/partners/0/teams/789123/members', [
        'headers' => [
            'accept'       => 'application/json',
            'content-type' => 'application/json',
            'Authorization' => 'Basic ' . base64_encode('YOUR_API_KEY:'),
        ],
        'json' => [
            'userId' => 123456,
            'role'   => 'REVIEWER',
        ],
    ]);
    echo $response->getBody();
    ....

    ....
    $client = new \GuzzleHttp\Client();
    $response = $client->request('POST', 'https://api.signifyd.com/v3/partners/0/teams/789123/members/123456', [
        'headers' => [
            'accept'       => 'application/json',
            'content-type' => 'application/json',
            'Authorization' => 'Basic ' . base64_encode('YOUR_API_KEY:'),
        ],
        'json' => [
            'role' => 'ADMIN',
        ],
    ]);
    echo $response->getBody();
    ....

    ....
    $client = new \GuzzleHttp\Client();
    $response = $client->request('GET', 'https://api.signifyd.com/v3/partners/0/teams/789123/members/123456', [
        'headers' => [
            'accept'        => 'application/json',
            'Authorization' => 'Basic ' . base64_encode('YOUR_API_KEY:'),
        ],
    ]);
    echo $response->getBody();
    ....

    ....
    $client = new \GuzzleHttp\Client();
    $response = $client->request('DELETE', 'https://api.signifyd.com/v3/partners/0/teams/789123/members/123456', [
        'headers' => [
            'accept'        => 'application/json',
            'Authorization' => 'Basic ' . base64_encode('YOUR_API_KEY:'),
        ],
    ]);
    echo $response->getBody();
    ....

    ....
    $client = new \GuzzleHttp\Client();
    $response = $client->request('GET', 'https://api.signifyd.com/v3/partners/0/members', [
        'headers' => [
            'accept'        => 'application/json',
            'Authorization' => 'Basic ' . base64_encode('YOUR_API_KEY:'),
        ],
        'query' => [
            'limit'  => 50,
            'offset' => 0,
        ],
    ]);
    echo $response->getBody();
    ....

    ....
    $client = new \GuzzleHttp\Client();
    $response = $client->request('POST', 'https://api.signifyd.com/v3/partners/0/members', [
        'headers' => [
            'accept'       => 'application/json',
            'content-type' => 'application/json',
            'Authorization' => 'Basic ' . base64_encode('YOUR_API_KEY:'),
        ],
        'json' => [
            'userId' => 123456,
            'role'   => 'REVIEWER',
        ],
    ]);
    echo $response->getBody();
    ....

    ....
    $client = new \GuzzleHttp\Client();
    $response = $client->request('POST', 'https://api.signifyd.com/v3/partners/0/members/123456', [
        'headers' => [
            'accept'       => 'application/json',
            'content-type' => 'application/json',
            'Authorization' => 'Basic ' . base64_encode('YOUR_API_KEY:'),
        ],
        'json' => [
            'role' => 'ADMIN',
        ],
    ]);
    echo $response->getBody();
    ....

    ....
    $client = new \GuzzleHttp\Client();
    $response = $client->request('GET', 'https://api.signifyd.com/v3/partners/0/members/123456', [
        'headers' => [
            'accept'        => 'application/json',
            'Authorization' => 'Basic ' . base64_encode('YOUR_API_KEY:'),
        ],
    ]);
    echo $response->getBody();
    ....

    ....
    $client = new \GuzzleHttp\Client();
    $response = $client->request('DELETE', 'https://api.signifyd.com/v3/partners/0/members/123456', [
        'headers' => [
            'accept'        => 'application/json',
            'Authorization' => 'Basic ' . base64_encode('YOUR_API_KEY:'),
        ],
    ]);
    echo $response->getBody();
    ....

    $addressData = ['streetAddress' => '2 Broadway', '...'];
    $address = new \Signifyd\Models\Address($addressData);

    $address = new \Signifyd\Models\Address();
    $address->setStreetAddress('2 Broadway');

    $checkoutData = ['orderId' => 'ORDER-10045', 'purchase' => new \Signifyd\Models\Purchase(), '...'];
    $checkout = new \Signifyd\Models\Checkout($checkoutData);

    $checkout = new \Signifyd\Models\Checkout();
    $checkout->setOrderId('ORDER-10045');
    $checkout->setPurchase(new \Signifyd\Models\Purchase());

    $paymentData = ['paymentMethod' => 'CREDIT_CARD', 'cardBin' => '411111', '...'];
    $checkoutPaymentDetails = new \Signifyd\Models\CheckoutPaymentDetails($paymentData);

    $checkoutPaymentDetails = new \Signifyd\Models\CheckoutPaymentDetails();
    $checkoutPaymentDetails->setPaymentMethod('CREDIT_CARD');
    $checkoutPaymentDetails->setCardBin('411111');

    $discountCodeData = ['code' => '598218sdareqw74fds', '...'];
    $discountCode = new \Signifyd\Models\DiscountCode($discountCodeData);

    $discountCode = new \Signifyd\Models\DiscountCode();

    $productData = ['itemId' => 'SKU-001', '...'];
    $product = new \Signifyd\Models\Product($productData);

    $product = new \Signifyd\Models\Product();

    $purchaseData = ['browserIpAddress' => '192.168.1.1', '...'];
    $purchase = new \Signifyd\Models\Purchase($purchaseData);

    $purchase = new \Signifyd\Models\Purchase();

    $saleData = ['orderId' => 'ORDER-10046', 'purchase' => new \Signifyd\Models\Purchase(), '...'];
    $sale = new \Signifyd\Models\Sale($saleData);

    $sale = new \Signifyd\Models\Sale();
    $sale->setOrderId('ORDER-10046');
    $sale->setPurchase(new \Signifyd\Models\Purchase());

    $shipmentData = ['shipper' => 'Fedex', '...'];
    $shipment = new \Signifyd\Models\Shipment($shipmentData);

    $shipment = new \Signifyd\Models\Shipment();

    $teamData = ['teamId' => 1, '...'];
    $team = new \Signifyd\Models\Team($teamData);

    $team = new \Signifyd\Models\Team();

    $transactionData = ['transactionId' => 'TXN-78912', 'gateway' => 'stripe', '...'];
    $transaction = new \Signifyd\Models\Transaction($transactionData);

    $transaction = new \Signifyd\Models\Transaction();
    $transaction->setTransactionId('TXN-78912');
    $transaction->setGateway('stripe');

    $userData = ['email' => '[email protected]', '...'];
    $userAccount = new \Signifyd\Models\UserAccount($userData);

    $userAccount = new \Signifyd\Models\UserAccount();

    $webhookData = ['event' => 'ORDER_CHECKPOINT_ACTION_UPDATE', 'url' => 'Your Url'];
    $webhook = new \Signifyd\Models\Webhook($webhookData);

    $webhook = new \Signifyd\Models\Webhook();

$ php composer.phar 

$ php composer.phar 

$ php composer.phar install