NAV Navbar
Logo

- Quick guide -

Create a payment request

Send a payment request to a customer.


Which programming language do you prefer?

| PHP | Python |

Use arrow keys or space bar to navigate in the presentation.

Installing the Library

1- Download the library on GitHub:

github.com/payplug/payplug-php

github.com/payplug/payplug-python

2- Add to all your pages that use the API:

<?php
require_once('PATH_TO_PAYPLUG/payplug_php/lib/init.php');
import payplug

Authentication

Verify your identity when communicating with the API by providing a secret key in all your requests.

To submit your credentials, include your key in all pages that use the API:

<?php
\Payplug\Payplug::init(array(
  'secretKey' => 'sk_live_YOUR_PRIVATE_KEY',
  'apiVersion' => 'THE_API_VERSION',
));
payplug.set_secret_key('sk_live_YOUR_PRIVATE_KEY')

API keys start with “sk_”.
They are available in My account, then API Credentials in the PayPlug portal.

Access LIVE and TEST modes using the same endpoint. To switch between modes, simply provide the related secret key to the mode you wish to access.

Take a look at the changelog to know which api version you should use.

The payment request creation process

create a payment

  1. Create the payment request using sent_by for the delivery method; A link to a payment page will be generated.
  2. Based on the delivery method a SMS or an e-mail will be sent to your customer.
    Alternatively you can handle the redirection.
  3. After entering his card details, your customer is automatically redirected to the return page on your site.
  4. PayPlug sends you a confirmation via IPN (Instant Payment Notification).

Payment request delivery methods

With the payement request you can define the way you are delivering the URL to
the payment page to your customer :

Options  Expiration  Description
SMS Send a SMS to your customer with the payment URL.
EMAIL Send an e-mail to your customer with the payment URL.
OTHER A payment URL with no expiration is generated. You are responsible for sharing the payment URL to your customer.
NULL A payment URL is generated and will expire 15 minutes after the first access.

Creating a payment request by e-mail

The following code shows an example of a payment request that automatically sends an e-mail to your client with a link to the payment page:

<?php
$email = 'john.watson@example.net';
$amount = 33;
$customer_id = '42710';

$payment = \Payplug\Payment::create(array(
  'amount'           => $amount * 100,
  '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,
    'sent_by'        => 'EMAIL'
  ),
  'notification_url' => 'https://example.net/notifications?id='.$customer_id,
  'metadata'         => array(
    'customer_id'    => $customer_id
    )
));

$payment_url = $payment->hosted_payment->payment_url;
$payment_id = $payment->id;
payment_data = {
  'amount': 3300,
  'currency': 'EUR',
  'customer': {
    'email': 'john.watson@example.net'
  },
  'hosted_payment': {
    'return_url': 'https://example.net/return?id=42710',
    'cancel_url': 'https://example.net/cancel?id=42710',
    'sent_by': 'EMAIL',
  },
  'notification_url': 'https://example.net/notifications?id=42710',
  'metadata': {
    'customer_id': 42710,
  },
}
payment = payplug.Payment.create(**payment_data)
payment_id = str(payment.id)

IMPORTANT: Please note that all amounts must be expressed in centimes as positive whole numbers
(1€ = 100 centimes).

Creating a payment request by SMS

The following code shows an example of a payment request that automatically sends an SMS to your client with a link to the payment page:

<?php
$email = 'john.watson@example.net';
$phone_number = '+33600000000';
$amount = 33;
$customer_id = '42710';

$payment = \Payplug\Payment::create(array(
  'amount'           => $amount * 100,
  'currency'         => 'EUR',
  'billing'  => array(
    'title'                => 'mr',
    'first_name'           => 'John',
    'last_name'            => 'Watson',
    'email'                => $email,
    'mobile_phone_number'  => $phone_number,
    'address1'             => '221B Baker Street',
    'postcode'             => 'NW16XE',
    'city'                 => 'London',
    'country'              => 'GB',
    'language'             => 'en'
  ),
  'shipping'  => array(
    'title'                => 'mr',
    'first_name'           => 'John',
    'last_name'            => 'Watson',
    'email'                => $email,
    'mobile_phone_number'  => $phone_number,
    '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,
    'sent_by'        => 'SMS'
  ),
  'notification_url' => 'https://example.net/notifications?id='.$customer_id,
  'metadata'         => array(
    'customer_id'    => $customer_id
    )
));

$payment_url = $payment->hosted_payment->payment_url;
$payment_id = $payment->id;
payment_data = {
  'amount': 3300,
  'currency': 'EUR',
  'customer': {
    'email': 'john.watson@example.net',
    'phone_number':'+33600000000',
  },
  'hosted_payment': {
    'return_url': 'https://example.net/return?id=42710',
    'cancel_url': 'https://example.net/cancel?id=42710',
    'sent_by': 'SMS',
  },
  'notification_url': 'https://example.net/notifications?id=42710',
  'metadata': {
    'customer_id': 42710,
  },
}
payment = payplug.Payment.create(**payment_data)
payment_id = str(payment.id)

IMPORTANT: Please note that for sending a SMS, the phone_number key has to be provided.

Payment requests compatibility

Payment requests are now compatible with most of the API features. It will allow to build powerfull integrations.

API feature  Compatibility
Refund a payment request
Retrieve a payment request
Update a payment request
Capture a payment request
Abort a payment request
Save a card
Notifications  
Installment plans  

Links & Resources


[ Click to return to the beginning of presentation ]