# installer Payplug Ubuntu 22.004 LTS sur LXC 

apt update && sudo apt upgrade -y
sudo apt install apache2 php libapache2-mod-php php-curl php-mbstring php-xml unzip git vim -y
sudo apt install composer -y


cd /WEB
composer require payplug/payplug-php


cat > payer.php << 'EOF'
<?php
require __DIR__ . '/vendor/autoload.php';

\Payplug\Payplug::setSecretKey('sk_test_7e2VZdmzzU2LURTEmhErlj');

$payment = \Payplug\Payment::create(array(
    'amount'   => 100, // Montant en centimes
    'currency' => 'EUR',
    'billing'  => array(
        'title'       => 'mr',
        'first_name'  => 'John',
        'last_name'   => 'Doe',
        'email'       => 'john.doe@example.com',
        'address1'    => '123 Rue Exemple',
        'postcode'    => '75001',
        'city'        => 'Paris',
        'country'     => 'FR',
        'language'    => 'fr'
    ),
    'shipping' => array(
        'title'        => 'mr',
        'first_name'   => 'John',
        'last_name'    => 'Doe',
        'email'        => 'john.doe@example.com',
        'address1'     => '123 Rue Exemple',
        'postcode'     => '75001',
        'city'         => 'Paris',
        'country'      => 'FR',
        'language'     => 'fr',
        'delivery_type'=> 'BILLING'
    ),
    'hosted_payment' => array(
        'return_url' => 'http://votre-site.com/retour?id=123',
        'cancel_url' => 'http://votre-site.com/annulation?id=123'
    ),
    'notification_url' => 'https://votre-site.com/notifications?id=123',
    'metadata' => array(
        'customer_id' => '123'
    )
));

header('Location: ' . $payment->hosted_payment->payment_url);
exit;
EOF













cat >  /etc/apache2/sites-enabled/000-default.conf  << FIN_SCRIPT
<VirtualHost   *:80>
    DocumentRoot /WEB/
	<Directory /WEB>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>	
</VirtualHost>
FIN_SCRIPT

service apache2 restart	

