dansmaculotte / monetico-php
PHP SDK for Monetico Payment Service
Installs: 41 236
Dependents: 1
Suggesters: 0
Security: 0
Stars: 13
Watchers: 6
Forks: 17
Open Issues: 6
Requires
- php: ^7.2|^8.0
- ext-json: *
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.13
- nesbot/carbon: ^2.27
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-12-10 20:01:05 UTC
README
This library aims to facilitate the usage of Monetico Service Methods
Installation
Requirements
- PHP 7.2
You can install the package via composer:
composer require dansmaculotte/monetico-php
Usage
Monetico
use DansMaCulotte\Monetico\Monetico; $monetico = new Monetico( 'EPT_CODE', 'SECURITY_KEY', 'COMPANY_CODE' );
Purchase
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' => 'john@snow.stark', '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);
Recovery
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);
Cancel
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);
Refund
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);
License
The MIT License (MIT). Please see License File for more information.