A Laravel package which simplifies working with 'Accept payment gateway' API
Install the package through Composer.
Run the Composer require command from the Terminal:
composer require mx13/accept
Requires PHP 7.2 and above.
Dependencies:
- guzzlehttp/guzzle
Run this console command after installation
php artisan accept:install
This command will add the following required lines to your project .env file
ACCEPT_API_KEY=
ACCEPT_INTEGRATION_ID=
ACCEPT_MERCHANT_ID=
ACCEPT_IFRAME_ID=
ACCEPT_HMAC_SECRET=
If you would like to override Accept package default configuration run the following command:
php artisan vendor:publish --tag=accept-config
$apiContext = new ApiContext(); // MX13\Accept\ApiContext
$item = new Item(); // MX13\Accept\Item
// Set item details
$item->setName('Product 1')
->setDescription('Some Product')
->setAmountCents(9900) // Item price in cents
->setQuantity(1);
$itemList = new ItemList(); // MX13\Accept\ItemList
// Set list of items
$itemList->setItems([$item]);
$amount = new Amount(); // MX13\Accept\Amount
// Set amount currency and amount in cents
$amount->setCurrency('EGP')
->setAmountCents($itemList->getTotal());
$billingData = new BillingData(); // MX13\Accept\BillingData
// Set billing data, mandatory by Accept and all required
$billingData->setApartment('237')
->setBuilding('101')
->setStreet('404')
->setPostalCode('655321')
->setCity('Minas Morgul')
->setState('Mordor')
->setCountry('Middle Earth')
->setEmail('[email protected]')
->setFirstName('Tyler')
->setLastName('Durden')
->setFloor('13')
->setPhoneNumber('(288) 555-1534');
$merchantOrderId = 'YT-1300'; // Order unique id generated by the merchant
$payment = new Payment($apiContext); // MX13\Accept\Payment
// Set your payment
$payment->setItems($itemList)
->setMerchantOrderId($merchantOrderId)
->setAmount($amount)
->setBillingData($billingData);
$payment->execute(); // Execute payment
Finally you can retrieve your iframe src by calling
$iframeUrl = $payment->getIframeUrl();