Payments
extends AbstractApiResourceGroup
in package
Class Payments
Tags
Table of Contents
Methods
- check() : PaymentCheckResponse
- Makes POST "/api/v5/payment/check" request.
- createInvoice() : PaymentCreateInvoiceResponse
- Makes POST "/api/v5/payment/create-invoice" request.
- updateInvoice() : SuccessResponse
- Makes POST "/api/v5/payment/update-invoice" request.
Methods
check()
Makes POST "/api/v5/payment/check" request.
public
check(PaymentCheckRequest $request) : PaymentCheckResponse
Example:
use RetailCrm\Api\Enum\Currency;
use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\Payments\ApiCheckRequest;
use RetailCrm\Api\Model\Request\Payments\PaymentCheckRequest;
$client = SimpleClientFactory::createClient('https://test.retailcrm.pro', 'apiKey');
$request = new ApiCheckRequest();
$request->invoiceUuid = '5b1b2e9d-b7f1-48f4-acb9-4bfce04b30cf';
$request->currency = Currency::RUB;
$request->amount = .5;
try {
$response = $client->payments->check(new PaymentCheckRequest($request));
} catch (ApiExceptionInterface $exception) {
echo sprintf(
'Error from RetailCRM API (status code: %d): %s',
$exception->getStatusCode(),
$exception->getMessage()
);
if (count($exception->getErrorResponse()->errors) > 0) {
echo PHP_EOL . 'Errors: ' . implode(', ', $exception->getErrorResponse()->errors);
}
return;
}
echo 'Result: ' . print_r($response->result, true);
Parameters
- $request : PaymentCheckRequest
Tags
Return values
PaymentCheckResponsecreateInvoice()
Makes POST "/api/v5/payment/create-invoice" request.
public
createInvoice(PaymentCreateInvoiceRequest $request) : PaymentCreateInvoiceResponse
Example:
use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\Payments\ApiCreateInvoiceRequest;
use RetailCrm\Api\Model\Request\Payments\PaymentCreateInvoiceRequest;
$client = SimpleClientFactory::createClient('https://test.retailcrm.pro', 'apiKey');
$request = new ApiCreateInvoiceRequest();
$request->paymentId = 4571;
$request->returnUrl = 'https://example.com';
try {
$response = $client->payments->createInvoice(new PaymentCreateInvoiceRequest($request));
} catch (ApiExceptionInterface $exception) {
echo sprintf(
'Error from RetailCRM API (status code: %d): %s',
$exception->getStatusCode(),
$exception->getMessage()
);
if (count($exception->getErrorResponse()->errors) > 0) {
echo PHP_EOL . 'Errors: ' . implode(', ', $exception->getErrorResponse()->errors);
}
return;
}
echo 'Result: ' . print_r($response->result, true);
Parameters
- $request : PaymentCreateInvoiceRequest
Tags
Return values
PaymentCreateInvoiceResponseupdateInvoice()
Makes POST "/api/v5/payment/update-invoice" request.
public
updateInvoice(PaymentUpdateInvoiceRequest $request) : SuccessResponse
Example:
use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\Payments\ApiUpdateInvoiceRequest;
use RetailCrm\Api\Model\Request\Payments\PaymentUpdateInvoiceRequest;
$client = SimpleClientFactory::createClient('https://test.retailcrm.pro', 'apiKey');
$request = new ApiUpdateInvoiceRequest();
$request->paymentId = 'd6458333-fff3-4fd0-9b23-4e6344451f8e';
$request->invoiceUuid = '5b1b2e9d-b7f1-48f4-acb9-4bfce04b30cf';
$request->invoiceUrl = 'https://example.com/newUrl';
try {
$response = $client->payments->updateInvoice(new PaymentUpdateInvoiceRequest($request));
} catch (ApiExceptionInterface $exception) {
echo sprintf(
'Error from RetailCRM API (status code: %d): %s',
$exception->getStatusCode(),
$exception->getMessage()
);
if (count($exception->getErrorResponse()->errors) > 0) {
echo PHP_EOL . 'Errors: ' . implode(', ', $exception->getErrorResponse()->errors);
}
}
Parameters
- $request : PaymentUpdateInvoiceRequest