Download the PHP package cashmos/cashmos-php-api without Composer
On this page you can find all versions of the php package cashmos/cashmos-php-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package cashmos-php-api
PHP API for Cashmos Payments
The is the official PHP SDK for Cashmos Payment Processing.
Installation
The SDK can be easily installed using composer. To install, run the following command on your terminal or command prompt on Windows (make sure composer is installed and available in your project directory).
composer require cashmos/cashmos-php-api
If you don't want to use composer, you may directly download a zip file from among the releases.
Authentication & Cashmos Services
To consume any of the services offered by this SDK, you'll need the
client id
and secret
for your business account. These can be viewed under the
API tab of your business screen of Cashmos online.
Create a business at Cashmos.com if
you don't already have an account.
Order Processing
Use the following steps to process an order with Cashmos:
I. Create an order:
$order = new Cashmos\Services\Order\Order();
// Add items to order
$order->addItem(
new Cashmos\Services\Order\Item($name, $unitPrice, $quantity, $description),
);
$order->addItem(
new Cashmos\Services\Order\Item($name2, $unitPrice2, $quantity2, $description2),
);
// Set order total.
// Note that this is the total amount to be charged to the user.
// Cashmos does not do any item level calculations for total amount.
$order->setOrderTotal($orderTotal)
// You can add any custom data to the order which
// could be retrieved later after confirmation.
// This may be information used to identify the customer
// making the order, etc.
$customData = [
'foo' => 'bar'
];
$order->addCustomData($customData);
// Set return and cancel urls
$order->returnUrl('https://business.com/paid'); // Url when payment authorization was successful.
$order->cancelUrl('https://business.com/canceled'); // Url when payment authorization was canceled.
II. Process Order Authorization:
This step allows the user to choose their payment method and provide authorization for the purchase. However, the user's is NOT actually charged. Use the next step to confirm the order and actually charge the user.
$cashmos = new Cashmos\Cashmos($clientId, $secret);
$cashmos->process($order);
If the user authorizes the payment, Cashmos will return to the "returnUrl" provided with a payment token as a query parameter (?token="random-token"). This payment token is used to confirm the payment.
III. Confirm Order:
Prerequisites
Security Vulnerabilities
If you discover a security vulnerability in this API, please email the details of the vulnerability to [email protected].