Git Product home page Git Product logo

php-sdk's Introduction

Build Status

wallee PHP Library

The wallee PHP library wraps around the wallee API. This library facilitates your interaction with various services such as transactions, accounts, and subscriptions.

Documentation

wallee Web Service API

Requirements

  • PHP 5.6.0 and above

Installation

You can use Composer or install manually

Composer

The preferred method is via composer. Follow the installation instructions if you do not already have composer installed.

Once composer is installed, execute the following command in your project root to install this library:

composer require wallee/sdk

Manual Installation

Alternatively you can download the package in its entirety. The Releases page lists all stable versions.

Uncompress the zip file you download, and include the autoloader in your project:

require_once '/path/to/php-sdk/autoload.php';

Usage

The library needs to be configured with your account's space id, user id, and secret key which are available in your wallee account dashboard. Set space_id, user_id, and api_secret to their values.

Configuring a Service

require_once(__DIR__ . '/autoload.php');

// Configuration
$spaceId = 405;
$userId = 512;
$secret = 'FKrO76r5VwJtBrqZawBspljbBNOxp5veKQQkOnZxucQ=';

// Setup API client
$client = new \Wallee\Sdk\ApiClient($userId, $secret);

// Get API service instance
$client->getTransactionService();
$client->getTransactionPaymentPageService();

To get started with sending transactions, please review the example below:

require_once(__DIR__ . '/autoload.php');

// Configuration
$spaceId = 405;
$userId = 512;
$secret = 'FKrO76r5VwJtBrqZawBspljbBNOxp5veKQQkOnZxucQ=';

// Setup API client
$client = new \Wallee\Sdk\ApiClient($userId, $secret);

// Create transaction
$lineItem = new \Wallee\Sdk\Model\LineItemCreate();
$lineItem->setName('Red T-Shirt');
$lineItem->setUniqueId('5412');
$lineItem->setSku('red-t-shirt-123');
$lineItem->setQuantity(1);
$lineItem->setAmountIncludingTax(29.95);
$lineItem->setType(\Wallee\Sdk\Model\LineItemType::PRODUCT);


$transactionPayload = new \Wallee\Sdk\Model\TransactionCreate();
$transactionPayload->setCurrency('EUR');
$transactionPayload->setLineItems(array($lineItem));
$transactionPayload->setAutoConfirmationEnabled(true);

$transaction = $client->getTransactionService()->create($spaceId, $transactionPayload);

// Create Payment Page URL:
$redirectionUrl = $client->getTransactionPaymentPageService()->paymentPageUrl($spaceId, $transaction->getId());

header('Location: ' . $redirectionUrl);

HTTP Client

You can either use php curl or php socket extentions. It is recommend you install the necessary extentions and enable them on your system.

You have to ways two specify which HTTP client you prefer.

$userId = 512;
$secret = 'FKrO76r5VwJtBrqZawBspljbBNOxp5veKQQkOnZxucQ=';

// Setup API client
$client = new \Wallee\Sdk\ApiClient($userId, $secret);

$httpClientType = \Wallee\Sdk\Http\HttpClientFactory::TYPE_CURL; // or \Wallee\Sdk\Http\HttpClientFactory::TYPE_SOCKET

$client->setHttpClientType($httpClientType);

//Setup a custom connection timeout if needed. (Default value is: 25 seconds)
$client->setConnectionTimeout(20);

You can also specify the HTTP client via the WLE_HTTP_CLIENT environment variable. The possible string values are curl or socket.

<?php
putenv('WLE_HTTP_CLIENT=curl');
?>

Integrating Webhook Payload Signing Mechanism into webhook callback handler

The HTTP request which is sent for a state change of an entity now includes an additional field state, which provides information about the update of the monitored entity's state. This enhancement is a result of the implementation of our webhook encryption mechanism.

Payload field state provides direct information about the state update of the entity, making additional API calls to retrieve the entity state redundant.

⚠️ Warning: Generic Pseudocode

The provided pseudocode is intentionally generic and serves to illustrate the process of enhancing your API to leverage webhook payload signing. It is not a complete implementation.

Please ensure that you adapt and extend this code to meet the specific needs of your application, including appropriate security measures and error handling. For a detailed webhook payload signing mechanism understanding we highly recommend referring to our comprehensive Webhook Payload Signing Documentation.

public function handleWebhook() {
    $requestPayload = file_get_contents('php://input');
    $signature = $_SERVER['HTTP_X_SIGNATURE'] ?? '';

    if (empty($signature)) {
        // Make additional API call to retrieve the entity state
        // ...
    } else {
        if ($client->getWebhookEncryptionService()->isContentValid($signature, $requestPayload)) {
            // Parse requestPayload to extract 'state' value
            // $state = ...
            // Process entity's state change
            // $this->processEntityStateChange($state);
            // ...
        }
    }

    // Process the received webhook data
    // ...

}

License

Please see the license file for more information.

php-sdk's People

Contributors

andrewrowanwallee avatar edgaraswallee avatar nicoeigenmanncw avatar sauliususoniswallee avatar schurter-wallee avatar vttn avatar wallee-deployment-user avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-sdk's Issues

can't get response code

while integrate to laravel app i got to redirect to payment page and simulate success and fail but can't get response code for what happens with payment system

sample code does not work

The sample code does not work.

Apart from the variable naming which is not correct
e.g. $client is initialised but then $apiClient is used
same goes for $services and $apiService

even after fixing the above, i do get the following exception

Wallee\Sdk\ApiException: [1217B46F-7AC4-2272-1409-586DE1476CF9] The entity query filter requires the type property. in Wallee\Sdk\Service\AccountService->countWithHttpInfo() (Zeile 147 in /vendor/wallee/sdk/lib/Service/AccountService.php).

Transaction Details

Sorry to bother you on this way, but I stuck somehow (and yes, I have read the documentary)
On the payment-response-page I run this code to check the transaction state:

$client = new \Wallee\Sdk\ApiClient($userId, $applicationKey);
$transactionService = new \Wallee\Sdk\Service\TransactionService($client);
$trData             = $transactionService->read($spaceId, $tranactionId);
$state              = $trData->getState();

But if the payment is successful I need some more details of the transaction, e.g. (Cardholder-Name, Cardbrand and -number, Card valid until....)

How can get those details?
Can someone point me in the right direction?
That would be nice

Roger

Error after callApi (result of buildPaymentPageUrl)

Pull request: #3

The sent request does either not contain the request parameter 'id' or it is invalid (e.g. wrong format).

The call from API returns this error. Upon further inspection, I found that this is caused by the buildRequestUrl method which uses http_build_query function which by default uses '&' as a separator. Normally if posting to another php5.3 machine this will not be a problem.

But if you post to a server with a newer PHP version or tomcat java server or something else the & might not be handled properly.

To overcome this specify:

http_build_query($array, '', '&');

and NOT

http_build_query($array);

in buildRequestUrl method. More specifically, change buildRequestUrl method in ApiClient.php to the following:

        /**
	 * Returns the request url.
	 *
	 * @param string $path the request path
	 * @param array $queryParams an array of query parameters
	 * @return string
	 */
	private function buildRequestUrl($path, $queryParams) {
		$url = $this->getBasePath() . $path;
		if (!empty($queryParams)) {
			$url = ($url . '?' . http_build_query($queryParams, '', '&'));
		}
		return $url;
	}

how webhook works

hi all, reading the documentation I can't understand how the webhook works. Once the payment process has been done, I need to redirect the user to a page, but from here on it's not clear to me how I can take the data and extrapolate it. I have already set up the webhook link from the panel. thank you

Feedback for release 3.1.4

Hi wallee dev team

I just wanted to let you know that you added a non optional parameter in the function Wallee\Sdk\ApiClient::callApi() in your latest Patch Release 3.1.4.
Naturally this triggered a bunch of warnings on our end.

Next time, could you add a hint in the release notes?

Thank for your work

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.