payplug / payplug-php
A simple PHP library for PayPlug public API.
Installs: 504 072
Dependents: 6
Suggesters: 1
Security: 0
Stars: 21
Watchers: 10
Forks: 6
Open Issues: 5
Requires
- php: >=5.3.0
- ext-curl: *
- ext-openssl: *
Requires (Dev)
- phpdocumentor/phpdocumentor: 2.*
- phpunit/phpunit: 5.7.*
- dev-master
- 3.6.0
- v3.5.7
- 3.5.6
- 3.5.5
- 3.5.4
- 3.5.3
- 3.5.2
- 3.5.1
- 3.5.0
- 3.4.1
- 3.4.0.x-dev
- 3.4.0
- 3.3.3
- 3.3.2
- 3.3.1
- 3.3.0
- 3.2.0
- 3.1.0
- 3.0.0
- 2.7.0
- 2.6.0
- 2.5.1
- 2.4.0
- 2.3.0
- 2.2.1
- 2.2.0
- 2.0.0
- dev-Mock-MPDC
- dev-PRE-1935-fix-send-mock
- dev-PRE-1935-save-data-on-MPDC
- dev-PRE-2007-add-bearer-token-mpdc
- dev-PRE-2117-add-php-8.x-compatibility
- dev-PRE-2258-implement-applepay-method
- dev-PRE-2604-Unified-Authent-request-client-id-and-secret
- dev-PRE-2605-request-jwt-develop
- dev-PRE-2607-check-secret-key
- dev-PRE-2729-update-mpdc-url
- dev-PRE-299-automate-tag
- dev-PRE-342-get-publishable-keys
- dev-PRE-test
- dev-PRE-test-sonar
- dev-accountingreports
- dev-action-phpunit
- dev-add-matrix-php-version
- dev-deferred-payment
- dev-demo-test
- dev-develop
- dev-dotenv
- dev-dsp2-release
- dev-fbureau-readme
- dev-fix-composer
- dev-fix-getpubKeys
- dev-fix-lib-version
- dev-fix-phpdoc
- dev-fix-pubkeys
- dev-fix-retrieve-payment
- dev-get-oney-simulations
- dev-installment-plan
- dev-installment-plan-notification
- dev-patch-release
- dev-payplug-addresses
- dev-release-3.4.1
- dev-release-3.5.0
- dev-release-3.5.1
- dev-release-3.5.3
- dev-release-3.5.4
- dev-release-3.5.5
- dev-release-3.5.6
- dev-release-3.6
- dev-release-3.6.0
- dev-set-apiRoutes-fromPlugins
- dev-test-tag
- dev-typo-fix
- dev-update-cacert
- dev-update-cacert-1
- dev-update-cacert-2023
- dev-update-cacert-2024
- dev-update-lib-version
- dev-update-php-lib
- dev-update-readme
- dev-wip-bancontact
This package is auto-updated.
Last update: 2024-12-11 15:47:12 UTC
README
PHP library for the Payplug API
This is the documentation of Payplug's PHP library. It is designed to help developers use Payplug as a payment solution in a simple, yet robust way.
You can create a Payplug account at https://www.payplug.com/.
Maintenance
CA certificate (cacert.pem) should be updated every year during the first week of December. Go to https://curl.se/docs/caextract.html to get a recent one.
Prerequisites
Payplug's library relies on cURL to perform HTTP requests and requires OpenSSL (1.0.1 or newer) to secure transactions. You also need PHP 5.3 or newer for the Payplug PHP V2.
For version PHP 5.2 or older, you must refer to Payplug PHP V1.
Documentation
Please see https://docs.payplug.com/api for the latest documentation.
Installation
Option 1 - Strongly preferred) via composer:
- Get composer from the composer website.
- Make sure you have initialized your composer.json.
- Run composer require payplug/payplug-php from your project directory.
Option 2- clone the repository:
git clone https://github.com/payplug/payplug-php.git
Option 3) download as a tarball:
- Download the most recent tarball from the download page V2 (V2 for PHP 5.3 or newer)
- Download the most recent tarball from the download page V1 (V1 for PHP 5.2 or older)
- Unpack the tarball
- Put the files somewhere in your project
To get started, add the following to your PHP script (if you are not running a framework):
<?php require_once("PATH_TO_PAYPLUG/payplug_php/lib/init.php");
Project Git Workflow
This repository follows a specific Git workflow to ensure smooth collaboration and controlled releases. Please follow the steps outlined below when contributing to this project.
Git Workflow Steps
Create a feature or fix branch:
Before making any changes, create a new branch from the develop branch:
git checkout develop git pull origin develop git checkout -b <feature-name>
For a bug fix, use:
git checkout develop git pull origin develop git checkout -b <fix-name>
Work on your feature or fix:
Make your code changes and commit them to your feature or fix branch.
Create a merge request:
Once your feature or fix is ready, create a merge request from your branch to the develop branch. Get your changes reviewed by your peers.
Release preparation:
When it's time for a release, create an intermediary branch called release-<version-number> from the develop branch:
git checkout develop git pull origin develop git checkout -b release-<version-number>
Finalize the release:
Test the code on the release-<version-number> branch thoroughly. Fix any bugs or issues that arise.
Merge to master:
Once the release is tested and stable, create a merge request from the release-<version-number> branch to the master branch. This signifies a successful release.
Tag the release:
After the merge to master, create a new tag to mark the release version:
git checkout master git pull origin master git tag -a <version-number> -m "Release <version-number>" git push origin master --tags
Usage
Here's how simple it is to create a payment request:
<?php require_once("PATH_TO_PAYPLUG/payplug_php/lib/init.php"); // If not using a framework // Loads your account's parameters that you've previously downloaded and saved Payplug\Payplug::init(array( 'secretKey' => 'sk_live_YOUR_PRIVATE_KEY', 'apiVersion' => 'THE_API_VERSION_YOU_WANT', )); // Create a payment request of €9.99. The payment confirmation (IPN) will be sent to "'https://example.net/notifications?id='.$customer_id". // Note that all amounts must be expressed in centimes as positive whole numbers (€9.99 = 999 centimes). // Metadata allow you to include additional information when processing payments or refunds. $customer_id = '42710'; $payment = Payplug\Payment::create(array( 'amount' => 999, 'currency' => 'EUR', 'billing' => array( 'title' => 'mr', 'first_name' => 'John', 'last_name' => 'Watson', 'email' => 'john.watson@example.net', 'address1' => '221B Baker Street', 'postcode' => 'NW16XE', 'city' => 'London', 'country' => 'GB', 'language' => 'en' ), 'shipping' => array( 'title' => 'mr', 'first_name' => 'John', 'last_name' => 'Watson', 'email' => 'john.watson@example.net', 'address1' => '221B Baker Street', 'postcode' => 'NW16XE', 'city' => 'London', 'country' => 'GB', 'language' => 'en', 'delivery_type' => 'BILLING' ), 'hosted_payment' => array( 'return_url' => 'https://example.net/return?id='.$customer_id, 'cancel_url' => 'https://example.net/cancel?id='.$customer_id ), 'notification_url' => 'https://example.net/notifications?id='.$customer_id, 'metadata' => array( 'customer_id' => $customer_id ) )); // You will be able to find how the payment object is built in the documentation. // For instance, if you want to get a URL to the payment page, you can do: $paymentUrl = $payment->hosted_payment->payment_url; // Then, you can redirect the user to the payment page header("Location: $paymentUrl");
Go further:
Tests:
See tests/README.rst.
Project Owners
This project is maintained by:
- [Imène Lajili](https://github.com/ilajili)
- [Manuel Mesquita](https://github.com/PPmmesquita)
For any questions or concerns about the workflow, feel free to reach out to the project owners.