PHP code example of oxygenzsas / composer_lib_paypal
1. Go to this page and download the library: Download oxygenzsas/composer_lib_paypal library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
oxygenzsas / composer_lib_paypal example snippets
aypal config et création de classe anonyme pour l'heritage */
$client = new class(
'xxxxxxxxxxx' /* clientID */
,'xxxxxxxxxxxxx' /* SecretID */
, 'https://api-m.sandbox.paypal.com' /* url API sandox vs prod */
, 'EUR' /* devise */
, 'https://sandbox.paypal.com/sdk/js' /* url sdk js */
,'http://localhost:8080' /* url de la page unique de paiement */
, true /* active SSL */
) extends \OxygenzSAS\Paypal\Paypal {
protected function getAmountFromAttribute(string $attribute) :int
{
$data = json_decode($attribute, true);
/** @todo recuperer ici le montant du paiement a partir des données de attributes */
return 1234; // return amount
}
};
/** Database config (PDO) */
\OxygenzSAS\Paypal\Database::setDsn('sqlite:'.__DIR__.'/database.db');
\OxygenzSAS\Paypal\Database::setUsername(null);
\OxygenzSAS\Paypal\Database::setPassword(null);
\OxygenzSAS\Paypal\Database::setOptions([]);
/** init database if necessary */
$client->initDatabase();
/** doi etre appelé sur la page de paiement car il creer les routes sur cette meme page */
$client->initRoute();
if($client->createOrderFromToken('xxxxx', 100, 'EUR') === false){
throw new EXception('Echec de creation de la commande a partir du paypal_vault_id');
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.