1. Go to this page and download the library: Download dansmaculotte/monetico-php 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/ */
dansmaculotte / monetico-php example snippets
use DansMaCulotte\Monetico\Monetico;
$monetico = new Monetico(
'EPT_CODE',
'SECURITY_KEY',
'COMPANY_CODE'
);
use DansMaCulotte\Monetico\Monetico;
use DansMaCulotte\Monetico\Requests\PurchaseRequest;
use DansMaCulotte\Monetico\Resources\BillingAddressResource;
use DansMaCulotte\Monetico\Resources\ShippingAddressResource;
use DansMaCulotte\Monetico\Resources\ClientResource;
$monetico = new Monetico(
'EPT_CODE',
'SECURITY_KEY',
'COMPANY_CODE'
);
$purchase = new PurchaseRequest([
'reference' => 'ABCDEF123',
'description' => 'Documentation',
'language' => 'FR',
'email' => '[email protected]',
'amount' => 42,
'currency' => 'EUR',
'dateTime' => new DateTime(),
'successUrl' => 'http://localhost/thanks',
'errorUrl' => 'http://localhost/oops',
]);
$billingAddress = new BillingAddressResource([
'name' => 'dans ma culotte',
'addressLine1' => '42 rue des serviettes',
'city' => 'Coupeville',
'postalCode' => '42000',
'country' => 'FR',
]);
$purchase->setBillingAddress($billingAddress);
$shippingAddress = new ShippingAddressResource([
'name' => 'dans ma culotte',
'addressLine1' => '42 rue des serviettes',
'city' => 'Coupeville',
'postalCode' => '42000',
'country' => 'FR',
]);
$purchase->setShippingAddress($shippingAddress);
$client = new ClientResource([
'civility' => 'Mr',
'firstName' => 'John',
'lastName' => 'Snow',
]);
$purchase->setClient($client);
$url = PurchaseRequest::getUrl();
$fields = $monetico->getFields($purchase);
use DansMaCulotte\Monetico\Monetico;
use DansMaCulotte\Monetico\Responses\PurchaseResponse;
use DansMaCulotte\Monetico\Receipts\PurchaseReceipt;
$data = json_decode([/* bank request body */], true);
$monetico = new Monetico(
'EPT_CODE',
'SECURITY_KEY',
'COMPANY_CODE'
);
$response = new PurchaseResponse($data);
$result = $monetico->validate($response);
$receipt = new PurchaseReceipt($result);
use DansMaCulotte\Monetico\Monetico;
use DansMaCulotte\Monetico\Requests\RecoveryRequest;
use DansMaCulotte\Monetico\Responses\RecoveryResponse;
$monetico = new Monetico(
'EPT_CODE',
'SECURITY_KEY',
'COMPANY_CODE'
);
$recovery = new RecoveryRequest([
'reference' => 'AXCDEF123',
'language' => 'FR',
'amount' => 42.42,
'amountToRecover' => 0,
'amountRecovered' => 0,
'amountLeft' => 42.42,
'currency' => 'EUR',
'orderDate' => new DateTime(),
'dateTime' => new DateTime(),
]);
$url = RecoveryRequest::getUrl();
$fields = $monetico->getFields($recovery);
$client = new Http\Client();
$data = $client->request('POST', $url, $fields);
// $data = json_decode($data, true);
$response = new RecoveryResponse($data);
use DansMaCulotte\Monetico\Monetico;
use DansMaCulotte\Monetico\Requests\CancelRequest;
use DansMaCulotte\Monetico\Responses\CancelResponse;
$monetico = new Monetico(
'EPT_CODE',
'SECURITY_KEY',
'COMPANY_CODE'
);
$cancel = new CancelRequest([
'dateTime' => new DateTime(),
'orderDate' => new DateTime(),
'reference' => 'ABC123',
'language' => 'FR',
'currency' => 'EUR',
'amount' => 100,
'amountRecovered' => 0,
]);
$url = CancelRequest::getUrl();
$fields = $monetico->getFields($cancel);
$client = new GuzzleHttp\Client();
$data = $client->request('POST', $url, $fields);
// $data = json_decode($data, true);
$response = new CancelResponse($data);
use DansMaCulotte\Monetico\Monetico;
use DansMaCulotte\Monetico\Requests\RefundRequest;
use DansMaCulotte\Monetico\Responses\RefundResponse;
$monetico = new Monetico(
'EPT_CODE',
'SECURITY_KEY',
'COMPANY_CODE'
);
$refund = new RefundRequest([
'dateTime' => new DateTime(),
'orderDatetime' => new DateTime(),
'recoveryDatetime' => new DateTime(),
'authorizationNumber' => '1222',
'reference' => 'ABC123',
'language' => 'FR',
'currency' => 'EUR',
'amount' => 100,
'refundAmount' => 50,
'maxRefundAmount' => 80,
]);
$url = RefundRequest::getUrl();
$fields = $monetico->getFields($refund);
$client = new GuzzleHttp\Client();
$data = $client->request('POST', $url, $fields);
// $data = json_decode($data, true);
$response = new RefundResponse($data);
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.