### Library Installation and Authentication Source: https://docs.payplug.com/api/guide-paymentrequest-en Guides on how to install the PayPlug libraries for PHP and Python, and how to authenticate API requests using secret keys. ```APIDOC ## Library Installation ### PHP 1. Download the library from GitHub: `github.com/payplug/payplug-php` 2. Include the library in your project: ```php require_once('PATH_TO_PAYPLUG/payplug_php/lib/init.php'); ``` ### Python 1. Download the library from GitHub: `github.com/payplug/payplug-python` 2. Import the library: ```python import payplug ``` ## Authentication ### Description Authenticate your API requests by including your secret key in all requests to verify your identity. ### Method (Not applicable, as this is setup) ### Endpoint (Not applicable, as this is setup) ### Parameters #### Request Body (Not applicable for authentication setup) ### Request Example #### PHP ```php \Payplug\Payplug::init(array( 'secretKey' => 'sk_live_YOUR_PRIVATE_KEY', 'apiVersion' => 'THE_API_VERSION', )); ``` #### Python ```python payplug.set_secret_key('sk_live_YOUR_PRIVATE_KEY') ``` ### Notes - API keys start with `sk_`. - Keys are available in the PayPlug portal under 'My account' > 'API Credentials'. - LIVE and TEST modes are accessible via the same endpoint; switch modes by providing the relevant secret key. - Refer to the changelog for the recommended API version. ``` -------------------------------- ### Install PayPlug Library Source: https://docs.payplug.com/api/downloads/payplug_api_guides_en_python Instructions for installing the PayPlug API library for PHP and Python. This involves downloading the library from GitHub and including it in your project files to enable API interactions. ```php 50000, 'currency' => 'EUR', 'payment_method' => 'bancontact', 'billing' => array( 'title' => 'mr', 'first_name' => 'John', 'last_name' => 'Watson', 'email' => 'john.watson@example.net', 'address1' => '1 rue de la Boetie', 'postcode' => '75008', 'city' => 'Paris', 'country' => 'FR', 'mobile_phone_number' => '+33612345678', 'language' => 'fr' ), 'shipping' => array( 'title' => 'mr', 'first_name' => 'John', 'last_name' => 'Watson', 'email' => 'john.watson@example.net', 'address1' => '1 rue de la Boetie', 'postcode' => '75008', 'city' => 'Paris', 'country' => 'FR', 'language' => 'fr', 'mobile_phone_number' => '+33612345678', 'delivery_type' => 'BILLING', 'company_name' => 'SuperCorp' ), 'notification_url' => 'https://example.net/notifications?id=42', 'hosted_payment' => array( 'return_url' => 'https://example.net/return?id=42' ) )); ``` -------------------------------- ### Install PayPlug Library Source: https://docs.payplug.com/api/guide-savecard-en Instructions on how to download and install the PayPlug SDK for PHP and Python. ```APIDOC ## Installing the Library 1. Download the library from GitHub: - PHP: github.com/payplug/payplug-php - Python: github.com/payplug/payplug-python 2. Add to your project: **PHP:** ```php require_once('PATH_TO_PAYPLUG/payplug_php/lib/init.php'); ``` **Python:** ```python import payplug ``` ``` -------------------------------- ### GET /v1/installment_plans/{id} Source: https://docs.payplug.com/api/apiref_powershell= Retrieve the details of a specific installment plan. ```APIDOC ## GET /v1/installment_plans/{id} ### Description Retrieves the details of a specific installment plan. ### Method GET ### Endpoint /v1/installment_plans/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the installment plan. ### Response #### Success Response (200 OK) - **id** (string) - The unique identifier for the installment plan. - **payment_id** (string) - The ID of the associated payment. - **plan** (object) - Details of the installment plan. #### Response Example ```json { "id": "ip_a1b2c3d4e5f6", "payment_id": "pay_a1b2c3d4e5f6", "plan": { "max_number": 3, "min_number": 2 } } ``` ``` -------------------------------- ### GET /v1/installment_plans/{installment_plan_id} Source: https://docs.payplug.com/api/downloads/payplug_api_apiref_python Retrieves the details of a specific installment plan using its ID. This endpoint is useful for checking the status and details of an existing installment plan. ```APIDOC ## Retrieve an Installment Plan ### Description Retrieves the information of a specific installment plan that has already been created. The request will return an `installment_plan` object if the ID provided is valid, and it will return an error object otherwise. ### Method GET ### Endpoint `/v1/installment_plans/{installment_plan_id}` ### Parameters #### Path Parameters - **installment_plan_id** (string) - Required - ID of the installment_plan to be retrieved. #### Query Parameters None #### Request Body None ### Request Example ```bash curl -X GET https://api.payplug.com/v1/installment_plans/inst_2JhnPxy4ABR4YBVW4UscWx \ -H "Authorization: Bearer sk_test_9898098098guGYUG9" \ -H "PayPlug-Version: 2019-08-06" ``` ```php ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier for the installment plan. - **object** (string) - The type of object, always "installment_plan". - **is_live** (boolean) - Indicates if the installment plan is in live mode. - **is_active** (boolean) - Indicates if the installment plan is currently active. - **currency** (string) - The currency of the installment plan (e.g., "EUR"). - **created_at** (integer) - Timestamp of when the installment plan was created. - **is_fully_paid** (boolean) - Indicates if the installment plan has been fully paid. - **billing** (object) - Details about the billing information. - **shipping** (object) - Details about the shipping information. - **hosted_payment** (object) - Information related to the hosted payment page. - **notification** (object) - Notification settings for the installment plan. - **schedule** (array) - An array of scheduled payment objects. - **failure** (object | null) - Information about any failure, or null if none. - **metadata** (object) - Custom data associated with the installment plan. #### Response Example ```json { "id": "inst_2JhnPxy4ABR4YBVW4UscWx", "object": "installment_plan", "is_live": true, "is_active": true, "currency": "EUR", "created_at": 1548326773, "is_fully_paid": false, "billing": { "title": "mr", "first_name": "John", "last_name": "Watson", "email": "john.watson@example.net", "mobile_phone_number": null, "landline_phone_number": null, "address1": "221B Baker Street", "address2": null, "postcode": "NW16XE", "city": "London", "state": null, "country": "GB", "language": "en" }, "shipping": { "title": "mr", "first_name": "John", "last_name": "Watson", "email": "john.watson@example.net", "mobile_phone_number": null, "landline_phone_number": null, "address1": "221B Baker Street", "address2": null, "postcode": "NW16XE", "city": "London", "state": null, "country": "GB", "language": "en", "delivery_type": "BILLING" }, "hosted_payment": { "payment_url": "https://secure.payplug.com/pay/2JhnPxy4ABR4YBVW4UscWx", "return_url": "https://example.net/success?id=42", "cancel_url": "https://example.net/cancel?id=42" }, "notification": { "url": "https://example.net/notifications?id=42" }, "schedule": [ { "date":"2019-02-02", "amount": 1000, "payment_ids": ["pay_12VazeAbq5ttYietdC2QxR"] }, { "date":"2019-03-02", "amount": 2050, "payment_ids": ["pay_2uazeAbq5ttYietdC2QxP"] }, { "date":"2019-04-02", "amount": 1026, "payment_ids": [] } ], "failure": null, "metadata": { "customer_id": 42 } } ``` ``` -------------------------------- ### Authentication and Versioning Example Source: https://docs.payplug.com/api/downloads/payplug_api_apiref_python Demonstrates how to authenticate API requests using a secret key and specify the API version via the `PayPlug-Version` header. Includes examples for cURL, PHP, and Python. ```APIDOC ## Authentication All API requests must use HTTPS. Authentication is performed by providing one of your secret keys in the HTTP `Authorization` header as a Bearer token. ### Method GET ### Endpoint /v1/payments ### Headers - **Authorization** (string) - Required - Your secret key (e.g., `Bearer sk_live_YOUR_SECRET_KEY`) - **PayPlug-Version** (string) - Optional - The API version to use (e.g., `2019-08-06`). Defaults to legacy version if not provided. ### Request Example (cURL) ```bash curl -X GET https://api.payplug.com/v1/payments \ -H "Authorization: Bearer sk_live_43b7e007298f57f732800a52" \ -H "PayPlug-Version: 2019-08-06" ``` ### Authentication Setup (PHP) ```php ``` ### Authentication Setup (Python) ```python import payplug payplug.set_secret_key('sk_live_43b7e007298f57f732800a52') ``` **Note:** Use `sk_live_` for live mode and `sk_test_` for test mode secret keys. ``` -------------------------------- ### Install PayPlug Library Source: https://docs.payplug.com/api/guide-savecard-en_php= Instructions on how to install the PayPlug library for PHP and Python. ```APIDOC ## Installing the PayPlug Library ### Description Download and include the PayPlug library in your project. ### Method Download/Include ### Endpoint N/A ### Parameters N/A ### Request Example **PHP:** ```php ``` **Python:** ```python import payplug ``` ### Response N/A ``` -------------------------------- ### GET /v1/installment_plans/{installment_plan_id} Source: https://docs.payplug.com/api/downloads/payplug_api_apiref_powershell Retrieves the details of a specific installment plan using its unique ID. This endpoint is useful for checking the status and information of an existing installment plan. ```APIDOC ## Retrieve an Installment Plan ### Description Retrieves the information of a specific installment plan that has already been created. The request will return an `installment_plan` object if the ID provided is valid, and it will return an error object otherwise. ### Method GET ### Endpoint /v1/installment_plans/{installment_plan_id} ### Parameters #### Path Parameters - **installment_plan_id** (string) - Required - ID of the installment_plan to be retrieved. #### Query Parameters None #### Request Body None ### Request Example ```bash $ curl -X GET https://api.payplug.com/v1/installment_plans/inst_2JhnPxy4ABR4YBVW4UscWx \ -H "Authorization: Bearer sk_test_9898098098guGYUG9" \ -H "PayPlug-Version: 2019-08-06" ``` ```php ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier of the installment plan. - **object** (string) - Type of the object, e.g., "installment_plan". - **is_live** (boolean) - Indicates if the plan is in live mode. - **is_active** (boolean) - Indicates if the plan is currently active. - **currency** (string) - The currency of the installment plan (e.g., "EUR"). - **created_at** (integer) - Timestamp of when the plan was created. - **is_fully_paid** (boolean) - Indicates if the plan has been fully paid. - **billing** (object) - Billing information for the customer. - **title** (string) - Customer's title. - **first_name** (string) - Customer's first name. - **last_name** (string) - Customer's last name. - **email** (string) - Customer's email address. - **mobile_phone_number** (string|null) - Customer's mobile phone number. - **landline_phone_number** (string|null) - Customer's landline phone number. - **address1** (string) - First line of the customer's address. - **address2** (string|null) - Second line of the customer's address. - **postcode** (string) - Customer's postcode. - **city** (string) - Customer's city. - **state** (string|null) - Customer's state/province. - **country** (string) - Customer's country code (ISO 3166-1 alpha-2). - **language** (string) - Customer's preferred language. - **shipping** (object) - Shipping information for the order. - **title** (string) - Recipient's title. - **first_name** (string) - Recipient's first name. - **last_name** (string) - Recipient's last name. - **email** (string) - Recipient's email address. - **mobile_phone_number** (string|null) - Recipient's mobile phone number. - **landline_phone_number** (string|null) - Recipient's landline phone number. - **address1** (string) - First line of the recipient's address. - **address2** (string|null) - Second line of the recipient's address. - **postcode** (string) - Recipient's postcode. - **city** (string) - Recipient's city. - **state** (string|null) - Recipient's state/province. - **country** (string) - Recipient's country code (ISO 3166-1 alpha-2). - **language** (string) - Recipient's preferred language. - **delivery_type** (string) - Type of delivery (e.g., "BILLING"). - **hosted_payment** (object) - Information related to the hosted payment page. - **payment_url** (string) - URL for the hosted payment page. - **return_url** (string) - URL to redirect to after successful payment. - **cancel_url** (string) - URL to redirect to if the payment is cancelled. - **notification** (object) - Notification settings. - **url** (string) - URL to send notifications to. - **schedule** (array) - An array of scheduled payment objects. - **date** (string) - The scheduled date for the payment. - **amount** (integer) - The amount for this installment. - **payment_ids** (array) - List of payment IDs associated with this installment. - **failure** (object|null) - Information about any payment failure. - **metadata** (object) - Custom key-value pairs associated with the plan. - **customer_id** (integer) - Example custom field. #### Response Example ```json { "id": "inst_2JhnPxy4ABR4YBVW4UscWx", "object": "installment_plan", "is_live": true, "is_active": true, "currency": "EUR", "created_at": 1548326773, "is_fully_paid": false, "billing": { "title": "mr", "first_name": "John", "last_name": "Watson", "email": "john.watson@example.net", "mobile_phone_number": null, "landline_phone_number": null, "address1": "221B Baker Street", "address2": null, "postcode": "NW16XE", "city": "London", "state": null, "country": "GB", "language": "en" }, "shipping": { "title": "mr", "first_name": "John", "last_name": "Watson", "email": "john.watson@example.net", "mobile_phone_number": null, "landline_phone_number": null, "address1": "221B Baker Street", "address2": null, "postcode": "NW16XE", "city": "London", "state": null, "country": "GB", "language": "en", "delivery_type": "BILLING" }, "hosted_payment": { "payment_url": "https://secure.payplug.com/pay/2JhnPxy4ABR4YBVW4UscWx", "return_url": "https://example.net/success?id=42", "cancel_url": "https://example.net/cancel?id=42" }, "notification": { "url": "https://example.net/notifications?id=42" }, "schedule": [ { "date":"2019-02-02", "amount": 1000, "payment_ids": ["pay_12VazeAbq5ttYietdC2QxR"] }, { "date":"2019-03-02", "amount": 2050, "payment_ids": ["pay_22uazeAbq5ttYietdC2QxP"] }, { "date":"2019-04-02", "amount": 1026, "payment_ids": [] } ], "failure": null, "metadata": { "customer_id": 42 } } ``` ``` -------------------------------- ### Abort Installment Plan using PHP Source: https://docs.payplug.com/api/downloads/payplug_api_apiref_powershell These PHP examples show two ways to abort an installment plan. The first aborts directly using the installment plan ID. The second retrieves an existing installment plan object and then calls the abort method on it. Both methods require the Payplug PHP SDK. ```php abort(); ``` -------------------------------- ### Python SDK Examples for Payment Object Source: https://docs.payplug.com/api/apiref Code examples in Python demonstrating how to access attributes and chain relations within the payment object. ```APIDOC ```python # Get an attribute of the payment object: # Print the payment amount print(str(payment.amount)) # Print the payment id print(str(payment.id)) # Print the payment creation time in an human readable way print(datetime.datetime.fromtimestamp(payment.created_at).strftime('%d/%m/%Y %H:%M:%S')) # Chain relations between objects: # Print the payment URL print(payment.hosted_payment.payment_url) # Print the customer email print(payment.customer.email) # Retrieve metadata print(payment.metadata['customer_id']) print(payment.metadata['type']) ``` ``` -------------------------------- ### Abort Installment Plan using cURL Source: https://docs.payplug.com/api/downloads/payplug_api_apiref_powershell This example demonstrates how to abort an installment plan using a cURL request. It sends a PATCH request to the Payplug API endpoint with the installment plan ID and sets the 'aborted' parameter to true in the JSON payload. Requires Authorization and PayPlug-Version headers. ```shell $ curl -X PATCH https://api.payplug.com/v1/installment_plans/inst_2JhnPxy4ABR4YBVW4UscWx \ -H "Authorization: Bearer sk_test_9898098098guGYUG9" \ -H "PayPlug-Version: 2019-08-06" \ -H "Content-Type: application/json" \ -d '{"aborted": true}' ``` -------------------------------- ### PHP SDK Examples for Payment Object Source: https://docs.payplug.com/api/apiref Code examples in PHP demonstrating how to access attributes and chain relations within the payment object. ```APIDOC ```php amount); // Print the payment id echo htmlentities($payment->id); // Print the payment creation time in an human readable way echo htmlentities(date('d/m/Y H:i:s', $payment->created_at)); // Chain relations between objects: // Print the payment URL echo htmlentities($payment->hosted_payment->payment_url); // Print the customer email echo htmlentities($payment->billing->email); // Retrieve metadata echo htmlentities($payment->metadata['customer_id']); echo htmlentities($payment->metadata['type']); ?> ``` ``` -------------------------------- ### POST /oney/simulations Source: https://docs.payplug.com/api/downloads/payplug_api_guides_en_php Simulates Oney payment options to display pop-in data for installment payments. ```APIDOC ## POST /oney/simulations ### Description Simulates Oney payment options to display pop-in data for installment payments. ### Method POST ### Endpoint /oney/simulations ### Parameters #### Request Body - **amount** (integer) - Required - The total amount for the simulation in cents. - **country** (string) - Required - The country code for the simulation (e.g., 'FR'). - **operations** (array of strings) - Required - A list of Oney operations to simulate (e.g., ['x3_with_fees', 'x4_with_fees']). ### Request Example ```json { "amount": 17266, "country": "FR", "operations": [ "x3_with_fees", "x4_with_fees" ] } ``` ### Response #### Success Response (200) - **result** (boolean) - Indicates if the simulation was successful. - **simulations** (object) - An object containing simulation results for each requested operation. - **x3_with_fees** (object) - Simulation details for 3 installments with fees. - **installments** (array of objects) - Details of each installment. - **date** (string) - The due date for the installment. - **amount** (integer) - The amount for the installment. - **total_cost** (integer) - The total cost of the Oney payment. - **nominal_annual_percentage_rate** (float) - The nominal annual percentage rate. - **effective_annual_percentage_rate** (float) - The effective annual percentage rate. - **down_payment_amount** (integer) - The amount of the down payment. - **x4_with_fees** (object) - Simulation details for 4 installments with fees (structure identical to x3_with_fees). #### Response Example ```json { "result": true, "simulations": { "x3_with_fees": { "installments": [ { "date": "2021-01-22T01:00:00.000Z", "amount": 5755 }, { "date": "2021-02-22T01:00:00.000Z", "amount": 5755 }, { "date": "2021-03-22T01:00:00.000Z", "amount": 5756 } ], "total_cost": 380, "nominal_annual_percentage_rate": 18.05, "effective_annual_percentage_rate": 19.62, "down_payment_amount": 4697 }, "x4_with_fees": { "installments": [ { "date": "2021-01-22T01:00:00.000Z", "amount": 4316 }, { "date": "2021-02-22T01:00:00.000Z", "amount": 4316 }, { "date": "2021-03-22T01:00:00.000Z", "amount": 4317 } ], "total_cost": 380, "nominal_annual_percentage_rate": 18.05, "effective_annual_percentage_rate": 19.62, "down_payment_amount": 4697 } } } ``` ``` -------------------------------- ### Install PayPlug Libraries (PHP, Python) Source: https://docs.payplug.com/api/guide-paymentrequest-en_python= Instructions for installing the PayPlug API libraries for PHP and Python. This involves downloading the library from GitHub and including it in your project files. ```php __