Skip to content

SDK Installation and Usage

Here, you'll find detailed instructions on how to install and use the Senfenico packages for both PHP and Python. These packages allow you to integrate Senfenico's payment services into your applications quickly and efficiently.

PHP SDK

Requirements

  • PHP Version: 7.3.0 and later.
  • Composer: A dependency manager for PHP.

Installation

Using Composer

You can install the PHP bindings via Composer. Run the following command in your terminal:

composer require senfenico/senfenico-php

Once installed, you can include the autoload script to start using the SDK in your project:

require_once 'vendor/autoload.php';

Manual Installation

If you do not wish to use Composer, you can manually download the latest release of the Senfenico PHP SDK on github. After downloading, include the init.php file in your project:

require_once '/path/to/senfenico-php/init.php';

Accessing API Response Fields

When you make an API call using the Senfenico PHP SDK, the response is returned as an object. You can access the different fields of the response object directly.

$senfenico = new \Senfenico\Senfenico('sk_test_...');
$checkout = $senfenico->checkout->initialize([
    'amount' => 1000,
    'success_url' => 'https://yourwebsite.com/success',
    'cancel_url' => 'https://yourwebsite.com/cancel',
]);

// Accessing fields from the response
$status = $checkout->status;
$reference = $checkout->data->reference;
$authorization_url = $checkout->data->authorization_url;

echo $status; // true
echo $reference; // "chk_de1ca053573c40a29a9fe95e7ad91d7e"
echo $authorization_url; // "https://api.senfenico.com/v1/checkout_payment/payment_page/chk_de1ca053573c40a29a9fe95e7ad91d7e/"

Example Response Here is a typical JSON response from the API:

Checkout initialized
{
    "status": true,
    "message": "Checkout initialized",
    "data": {
        "reference": "chk_de1ca053573c40a29a9fe95e7ad91d7e",
        "authorization_url": "https://api.senfenico.com/v1/checkout_payment/payment_page/chk_de1ca053573c40a29a9fe95e7ad91d7e/",
        "live_mode": false
    }
}

Python SDK

Installation

You can install the Python SDK using pip, which is the package installer for Python. Run the following command in your terminal:

pip install senfenico

Accessing API Response Fields

When you make an API call using the Senfenico PHP SDK, the response is returned as an object. You can access the different fields of the response object directly.

import senfenico

senfenico.api_key = 'sk_test_...'

checkout = senfenico.Checkout.initialize(amount=1000, success_url='https://yourwebsite.com/success', cancel_url='http://www.website.com/cancel')

# Accessing fields from the response
status = checkout.status
reference = checkout.data.reference
authorization_url = checkout.data.authorization_url

print(status)  # True
print(reference)  # "chk_de1ca053573c40a29a9fe95e7ad91d7e"
print(authorization_url)  # "https://api.senfenico.com/v1/checkout_payment/payment_page/chk_de1ca053573c40a29a9fe95e7ad91d7e/"

Example Response Here is a typical JSON response from the API:

Checkout initialized
{
    "status": true,
    "message": "Checkout initialized",
    "data": {
        "reference": "chk_de1ca053573c40a29a9fe95e7ad91d7e",
        "authorization_url": "https://api.senfenico.com/v1/checkout_payment/payment_page/chk_de1ca053573c40a29a9fe95e7ad91d7e/",
        "live_mode": false
    }
}