The WeGetFinancing PHP SDK provides convenient access to the WeGetFinancing API from applications written in the PHP language.

4.0.0 2024-02-27 10:25 UTC

This package is auto-updated.

Last update: 2024-04-27 10:48:11 UTC


README

WeGetFinancing

PHP-SDK

Maintainability Test Coverage Quality Assurance CI Test CI PHPStan

The WeGetFinancing SDK for PHP makes it easy for developers to access the WeGetFinancing API in their PHP code and integrate our payment gateway in their e-commerce, CRM, ERP, and any related web applications. You can get started in minutes by installing the SDK through Composer or by downloading a single zip from our latest release.

Index

  1. Minimum Requirements
  2. Install
  3. How to use

Minimum Requirements

To run the SDK, your system will need to meet the minimum requirements of having PHP >= 7.4 with ext-json.

Install

Using Composer is the recommended way to install the WeGetFinancing PHP-SDK. The SDK is available via Packagist under the wegetfinancing/php-sdk package. If Composer is installed globally on your system, you can run the following in the base directory of your project to add the SDK as a dependency:

composer require `wegetfinancing/php-sdk`

How to use

  1. Require the composer autoload and the packages.
    <?php
    
    require 'vendor/autoload.php';
    
    use WeGetFinancing\SDK\Client;
    use WeGetFinancing\SDK\Entity\Request\AuthRequestEntity;
    use WeGetFinancing\SDK\Entity\Request\LoanRequestEntity;
  2. Make an AuthResponseEntity and use it to initialise the client
    $auth = AuthRequestEntity::make([
        'username' => '***',
        'password'  => '***',
        'merchantId' => '***',
        'url' => 'https://***'
    ]);
    
    $client = Client::Make($auth);
  3. Make an LoanRequestEntity, for more information about the parameter to use, please refer to the official documentation.
    $request = LoanRequestEntity::make([
        'first_name' => '***',
        'last_name' => '***',
        'shipping_amount' => 1.2,
        'version' => '1.9',
        'email' => '***@example.com',
        'phone' => '0123456789',
        'merchant_transaction_id' => '***',
        'success_url' => 'https://yoururl.com/successurl',   // this is facultative
        'failure_url' => 'https://yoururl.com/failureurl',   // this is facultative
        'postback_url' => 'https://yoururl.com/postbackurl', // this is facultative
        'billing_address' => [
            'street1' => '***',
            'city' => '***',
            'state' => '***',
            'zipcode' => '***',
        ],
        'shipping_address' => [
            'street1' => '***',
            'city' => '***',
            'state' => '***',
            'zipcode' => '***',
        ],
        'cart_items' => [
            [
                'sku' => '***',
                'display_name' => '***',
                'unit_price' => '***',
                'quantity' => ***,
                'unit_tax' => **.*,
                'category' => '***',      // Facultative
            ]
        ]
    ]);
  4. Use the LoanRequestEntity to make an application and receive a LoanResponseEntity with the result of it.
    $response = $client->requestNewLoan($request);