Giter Site home page Giter Site logo

przelewy24-php's Introduction

Przelewy24 PHP library

PHP wrapper for www.przelewy24.pl.

Requirements

  • PHP >=7.1.3

Installation

composer require mnastalski/przelewy24-php

Usage

Creating an instance

use Przelewy24\Przelewy24;

$przelewy24 = new Przelewy24([
    'merchant_id' => '12345',
    'crc' => 'aef0...',
    'live' => false, // `true` for production/live mode
]);

Creating a transaction

$transaction = $przelewy24->transaction([
    'session_id' => 'unique order identifier from your application',
    'url_return' => 'url to return to post transaction',
    'url_status' => 'url to which the transaction status webhook will be sent',
    'amount' => 'transaction amount as an integer (1.25 PLN = 125)',
    'description' => 'transaction description',
    'email' => 'buyer email address',
]);

Retrieve the transaction's token:

$transaction->token();

Retrieve the redirect URL to the payment gateway:

$transaction->redirectUrl();

Listening for transaction status webhook

$webhook = $przelewy24->handleWebhook();

Verifying a transaction

$przelewy24->verify([
    'session_id' => 'unique order identifier from your application',
    'order_id' => $webhook->orderId(),   // przelewy24 order id
    'amount' => 'transaction amount as an integer (1.25 PLN = 125)',
]);

Error handling

Should Przelewy24's API return an erroneous response, an ApiResponseException::class (which extends Przelewy24Exception::class) will be thrown. You can therefore use a try/catch block to handle any errors:

use Przelewy24\Exceptions\Przelewy24Exception;

try {
    $przelewy24->transaction([
        // ...
    ]);
} catch (Przelewy24Exception $e) {
    // Handle the error...
}

przelewy24-php's People

Contributors

mnastalski avatar

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.