Skip to content
Reindert Vetter edited this page Nov 17, 2021 · 17 revisions

Requirements

  • The Plug&Pay SDK works with PHP version >= 7.4.

Installation with Composer

//

Contribute

//

Authentication

//

Exceptions

Your application will be better and more stable if you take the exceptions into account. It is therefore good to catch the errors when they arise. Then you can decide for yourself how you want to deal with the error.

use PlugAndPay\Sdk\Exception\NotFoundException;
use PlugAndPay\Sdk\Exception\RelationNotLoadedException;
use PlugAndPay\Sdk\Exception\ValidationException;

try {

    // Place your code that uses the SDK inside this block.

} catch (ValidationException $exception) {

    # The information that has been sent is incorrect. If
    # you want to forward this in your response, this would
    # return an HTTP status Unprocessable Entity (422).
 
    // All messages separated by a space
    $message = $exception->getMessage();
    // First notification of the first error. There can be
    // multiple errors with the same field
    $exception->errors()[0]->message());
    // The field that did not pass the validation successfully.
    $exception->errors()[0]->field());

 } catch (NotFoundException $exception) {
 
    # Entry not found. You probably gave the wrong id to
    # the service. You have to solve this error in your
    # application, otherwise you would expect an HTTP
    # Internal Server Error (500).
    
} catch (RelationNotLoadedException $exception) {

    # You are trying to extract a relation from an entity
    # that has not yet been loaded. You can include this
    # by using the `include()` method of the service. You
    # have to solve this error in your application, otherwise
    # you would expect an HTTP Internal Server Error (500).
    
} catch (DecodeResponseException $exception) {

    # Failed to decode the response. You would expect an
    # HTTP Internal Server Error (500) and you have to
    # contact Plug&Pay customer service.
    
}
Clone this wiki locally