sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
public function radio(FieldContract $field): Htmlable { return $this->form->radio($field->get('name'), $field->get('value'), $field->get('checked')); }
Radio template. @param \Orchestra\Contracts\Html\Form\Field $field @return \Illuminate\Contracts\Support\Htmlable
entailment
public function select(FieldContract $field): Htmlable { $attributes = $this->html->decorate($field->get('attributes'), ['class' => 'form-control']); return $this->form->select( $field->get('name'), $this->asArray($field->get('options')), $field->get('value'), ...
Select template. @param \Orchestra\Contracts\Html\Form\Field $field @return \Illuminate\Contracts\Support\Htmlable
entailment
public function register($sType, $sUserFunction, $aOptions) { if($sType != $this->getName()) { return false; } if(!is_string($sUserFunction)) { throw new \Jaxon\Exception\Error($this->trans('errors.functions.invalid-declaration')); } ...
Register a user defined function @param string $sType The type of request handler being registered @param string $sUserFunction The name of the function being registered @param array|string $aOptions The associated options @return \Jaxon\Request\Request
entailment
public function getScript() { $di = jaxon()->di(); $code = ''; foreach(array_keys($this->aFunctions) as $sName) { $xFunction = $di->get($sName); $code .= $xFunction->getScript(); } return $code; }
Generate client side javascript code for the registered user functions @return string
entailment
public function canProcessRequest() { // Check the validity of the function name if(($this->sRequestedFunction) && !$this->validateFunction($this->sRequestedFunction)) { $this->sRequestedFunction = null; } return ($this->sRequestedFunction != null); }
Check if this plugin can process the incoming Jaxon request @return boolean
entailment
public function processRequest() { if(!$this->canProcessRequest()) { return false; } // Security check: make sure the requested function was registered. if(!key_exists($this->sRequestedFunction, $this->aFunctions)) { // Unable to find the requ...
Process the incoming Jaxon request @return boolean
entailment
public function make(callable $callback = null): BuilderContract { $builder = new TableBuilder( $this->app->make('request'), $this->app->make('translator'), $this->app->make('view'), new Grid($this->app, $this->config) ); return $builder->exte...
{@inheritdoc}
entailment
public function of(string $name, callable $callback = null): BuilderContract { if (! isset($this->names[$name])) { $this->names[$name] = $this->make($callback); $this->names[$name]->name = $name; } return $this->names[$name]; }
Create a new builder instance of a named builder. @param string $name @param callable|null $callback @return \Orchestra\Contracts\Html\Builder
entailment
public function validateUploadedFile($sName, array $aUploadedFile) { $this->sErrorMessage = ''; // Verify the file extension $xDefault = $this->xConfig->getOption('upload.default.types'); $aAllowed = $this->xConfig->getOption('upload.files.' . $sName . '.types', $xDefault); i...
Validate an uploaded file @param string $sName The uploaded file variable name @param array $aUploadedFile The file data received in the $_FILES array @return bool True if the file data are valid, and false if not
entailment
public function hasUploadedFiles() { if(($xUploadPlugin = $this->getPluginManager()->getRequestPlugin(self::FILE_UPLOAD)) == null) { return false; } return $xUploadPlugin->canProcessRequest(); }
Check if uploaded files are available @return boolean
entailment
public function saveUploadedFiles() { try { if(($xUploadPlugin = $this->getPluginManager()->getRequestPlugin(self::FILE_UPLOAD)) == null) { throw new Exception($this->trans('errors.upload.plugin')); } elseif(!$xUploadPlugin->canProcessR...
Check uploaded files validity and move them to the user dir @return boolean
entailment
public function getUploadedFiles() { if(($xUploadPlugin = $this->getPluginManager()->getRequestPlugin(self::FILE_UPLOAD)) == null) { return []; } return $xUploadPlugin->getUploadedFiles(); }
Get the uploaded files @return array
entailment
public function setUploadFileFilter(Closure $fFileFilter) { if(($xUploadPlugin = $this->getPluginManager()->getRequestPlugin(self::FILE_UPLOAD)) == null) { return; } $xUploadPlugin->setFileFilter($fFileFilter); }
Filter uploaded file name @param Closure $fFileFilter The closure which filters filenames @return void
entailment
public function buildFieldByType(string $type, $row, Fluent $control): FieldContract { $templates = $this->templates; $data = $this->buildFluentData($type, $row, $control); $method = $data->get('method'); $data->options($this->getOptionList($row, $control)); $data->checked(...
Build field by type. @param string $type @param mixed $row @param \Illuminate\Support\Fluent $control @return \Illuminate\Support\Fluent
entailment
public function buildFluentData(string $type, $row, Fluent $control): FieldContract { // set the name of the control $name = $control->get('name'); $value = $this->resolveFieldValue($name, $row, $control); $data = new Field([ 'method' => '', 'type' => '', ...
Build data. @param string $type @param mixed $row @param \Illuminate\Support\Fluent $control @return \Orchestra\Contracts\Html\Form\Field
entailment
protected function getOptionList($row, Fluent $control) { // set the value of options, if it's callable run it first $options = $control->get('options'); if ($options instanceof Closure) { $options = $options($row, $control); } return $options; }
Get options from control. @param mixed $row @param \Illuminate\Support\Fluent $control @return array|\Illuminate\Contracts\Support\Arrayable
entailment
public function render(array $templates, Fluent $field): string { $method = $field->get('method'); $template = $templates[$method] ?? [$this->presenter, $method]; if (! \is_callable($template)) { throw new InvalidArgumentException("Form template for [{$method}] is not available....
Render the field. @param array $templates @param \Illuminate\Support\Fluent $field @throws \InvalidArgumentException @return string
entailment
protected function resolveFieldType(string $value, Fluent $data): FieldContract { if (\preg_match('/^(input):([a-zA-Z]+)$/', $value, $matches)) { $value = $matches[2]; } $filterable = \in_array($value, \array_keys($this->templates)) || \method_exists($this->presenter, $value); ...
Resolve method name and type. @param string $value @param \Illuminate\Support\Fluent $data @return \Orchestra\Contracts\Html\Form\Field
entailment
protected function resolveFieldValue(string $name, $row, Fluent $control) { // Set the value from old input, followed by row value. $value = $control->get('value'); $model = \data_get($row, $name, $this->request->old($name)); if (! \is_null($model)) { return $model; ...
Resolve field value. @param string $name @param mixed $row @param \Illuminate\Support\Fluent $control @return mixed
entailment
public function render() { $grid = $this->grid; $data = [ 'grid' => $grid, 'format' => $grid->format, 'submit' => $this->translator->get($grid->submit), 'token' => $grid->token, 'meta' => $grid->viewData, ]; $view = $this-...
{@inheritdoc}
entailment
public function configure($sName, $sValue) { switch($sName) { // Set the separator case 'separator': if($sValue == '_' || $sValue == '.') { $this->separator = $sValue; } break; // Set the protected methods ...
Set configuration options / call options for each method @param string $sName The name of the configuration option @param string $sValue The value of the configuration option @return void
entailment
public function getMethods() { $aMethods = []; foreach($this->reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod) { $sMethodName = $xMethod->getShortName(); // Don't take magic __call, __construct, __destruct methods if(strlen($sMethodNa...
Return a list of methods of the callable object to export to javascript @return array
entailment
public function getRegisteredObject() { if($this->registeredObject == null) { $di = jaxon()->di(); // Use the Reflection class to get the parameters of the constructor if(($constructor = $this->reflectionClass->getConstructor()) != null) { ...
Return the registered callable object @return object
entailment
public function call($sMethod, $aArgs) { if(!$this->hasMethod($sMethod)) { return; } $reflectionMethod = $this->reflectionClass->getMethod($sMethod); $registeredObject = $this->getRegisteredObject(); return $reflectionMethod->invokeArgs($registeredObject, ...
Call the specified method of the registered callable object using the specified array of arguments @param string $sMethod The name of the method to call @param array $aArgs The arguments to pass to the method @return void
entailment
public function confirm($question, $yesScript, $noScript) { return $this->getConfirm()->confirm($question, $yesScript, $noScript); }
Get the script which makes a call only if the user answers yes to the given question @return string
entailment
public function initiate(array $config, ControlContract $control, Template $presenter): void { $control->setTemplates($config)->setPresenter($presenter); $this->control = $control; }
Load grid configuration. @param array $config @param \Orchestra\Contracts\Html\Form\Control $control @param \Orchestra\Contracts\Html\Form\Template $presenter @return void
entailment
protected function buildBasic($name, Closure $callback = null): void { if ($name instanceof Closure) { $callback = $name; $name = null; } ! empty($name) && $this->legend($name); $callback($this); }
Build basic fieldset. @param string|\Closure $name @param \Closure|null $callback @return void
entailment
public function control($type, $name, $callback = null) { list($name, $control) = $this->buildControl($name, $callback); if (\is_null($control->field)) { $control->field = $this->control->generate($type); } $this->controls[] = $control; $this->keyMap[$name] = \c...
Append a new control to the form. <code> // add a new control using just field name $fieldset->control('input:text', 'username'); // add a new control using a label (header title) and field name $fieldset->control('input:email', 'E-mail Address', 'email'); // add a new control by using a field name and closure $fiel...
entailment
public function find(string $name) { if (! \array_key_exists($name, $this->keyMap)) { throw new InvalidArgumentException("Name [{$name}] is not available."); } return $this->controls[$this->keyMap[$name]]; }
Find definition that match the given id. @param string $name @throws \InvalidArgumentException @return \Illuminate\Support\Fluent
entailment
public function legend($name = null) { if (! \is_null($name)) { $this->name = $name; } return $this->name; }
Set Fieldset Legend name. <code> $fieldset->legend('User Information'); </code> @param string|null $name @return string
entailment
public function minify($sJsFile, $sMinFile) { $xJsMinifier = new JsMinifier(); $xJsMinifier->add($sJsFile); $xJsMinifier->minify($sMinFile); return is_file($sMinFile); }
Minify javascript code @param string $sJsFile The javascript file to be minified @param string $sMinFile The minified javascript file @return boolean True if the file was minified
entailment
public function hasPageNumber() { foreach($this->aParameters as $xParameter) { if($xParameter->getType() == Jaxon::PAGE_NUMBER) { return true; } } return false; }
Check if the request has a parameter of type Jaxon::PAGE_NUMBER @return boolean
entailment
public function setPageNumber($nPageNumber) { // Set the value of the Jaxon::PAGE_NUMBER parameter foreach($this->aParameters as $xParameter) { if($xParameter->getType() == Jaxon::PAGE_NUMBER) { $xParameter->setValue(intval($nPageNumber)); ...
Set a value to the Jaxon::PAGE_NUMBER parameter @param integer $nPageNumber The current page number @return Request
entailment
private function setMessageArgs(array $aArgs) { array_walk($aArgs, function (&$xParameter) { $xParameter = Parameter::make($xParameter); }); $this->aMessageArgs = $aArgs; }
Create parameters for message arguments @param $aArgs The arguments @return void
entailment
public function getScript() { /* * JQuery variables sometimes depend on the context where they are used, eg. when their value depends on $(this). * When a confirmation question is added, the Jaxon calls are made in a different context, * making those variables invalid. * ...
Returns a string representation of the script output (javascript) from this request object @return string
entailment
public function trans($sText, array $aPlaceHolders = [], $sLanguage = null) { return Container::getInstance()->getTranslator()->trans($sText, $aPlaceHolders, $sLanguage); }
Get a translated string @param string $sText The key of the translated string @param string $aPlaceHolders The placeholders of the translated string @param string $sLanguage The language of the translated string @return string The translated string
entailment
public function getScript() { if(count($this->aCalls) == 0) { return $this->sSelector; } return $this->sSelector . '.' . implode('.', $this->aCalls); }
Generate the jQuery call. @return string
entailment
public static function create($payment, array $data = null, Payplug\Payplug $payplug = null) { if ($payplug === null) { $payplug = Payplug\Payplug::getDefaultConfiguration(); } if ($payment instanceof Payment) { $payment = $payment->id; } $httpClient ...
Creates a refund on a payment. @param string|Payment $payment the payment id or the payment object @param array $data API data for refund @param Payplug\Payplug $payplug the client configuration @return null|Refund the refund object @throws Payplug\Exception\Config...
entailment
public static function retrieve($payment, $refundId, Payplug\Payplug $payplug = null) { if ($payplug === null) { $payplug = Payplug\Payplug::getDefaultConfiguration(); } if ($payment instanceof Payment) { $payment = $payment->id; } $httpClient = new P...
Retrieves a refund object on a payment. @param string|Payment $payment the payment id or the payment object @param string $refundId the refund id @param Payplug\Payplug $payplug the client configuration @return null|Payplug\Resource\APIResource|Refund the refund object ...
entailment
public static function listRefunds($payment, Payplug\Payplug $payplug = null) { if ($payplug === null) { $payplug = Payplug\Payplug::getDefaultConfiguration(); } if ($payment instanceof Payment) { $payment = $payment->id; } $httpClient = new Payplug\C...
Lists the last refunds of a payment. @param string|Payment $payment the payment id or the payment object @param Payplug\Payplug $payplug the client configuration @return null|Refund[] an array containing the refunds on success. @throws Payplug\Exception\ConfigurationNotSetException @thr...
entailment
function getConsistentResource(Payplug\Payplug $payplug = null) { if (!array_key_exists('id', $this->_attributes)) { throw new Payplug\Exception\UndefinedAttributeException('The id of the refund is not set.'); } else if (!array_key_exists('payment_id', $this->_attributes)) { ...
Returns an API resource that you can trust. @param Payplug\Payplug $payplug the client configuration. @return Payplug\Resource\APIResource The consistent API resource. @throws Payplug\Exception\UndefinedAttributeException when the local resource is invalid.
entailment
protected function initialize(array $attributes) { parent::initialize($attributes); if (isset($attributes['customer'])) { $this->customer = PaymentCustomer::fromAttributes($attributes['customer']); } if (isset($attributes['failure'])) { $this->failure = Payme...
Initializes the resource. This method must be overridden when the resource has objects as attributes. @param array $attributes the attributes to initialize.
entailment
public function listPayments(Payplug\Payplug $payplug = null) { if ($payplug === null) { $payplug = Payplug\Payplug::getDefaultConfiguration(); } if (!array_key_exists('id', $this->getAttributes())) { throw new Payplug\Exception\UndefinedAttributeException( ...
List the payments of this installment plan. @param Payplug\Payplug $payplug the client configuration @return null|Payment[] the array of payments of this installment plan @throws Payplug\Exception\UndefinedAttributeException @throws Payplug\Exception\UnexpectedAPIResponseException
entailment
public static function retrieve($installmentPlanId, Payplug\Payplug $payplug = null) { if ($payplug === null) { $payplug = Payplug\Payplug::getDefaultConfiguration(); } $httpClient = new Payplug\Core\HttpClient($payplug); $response = $httpClient->get( Payplug...
Retrieves an InstallmentPlan. @param string $installmentPlanId the installment plan ID @param Payplug\Payplug $payplug the client configuration @return null|InstallmentPlan the retrieved installment plan or null on error @throws Payplug\Exception\ConfigurationNotSetException
entailment
public static function create(array $data, Payplug\Payplug $payplug = null) { if ($payplug === null) { $payplug = Payplug\Payplug::getDefaultConfiguration(); } $httpClient = new Payplug\Core\HttpClient($payplug); $response = $httpClient->post( Payplug\Core\AP...
Creates an InstallmentPlan. @param array $data API data for payment creation @param Payplug\Payplug $payplug the client configuration @return null|InstallmentPlan the created installment plan instance @throws Payplug\Exception\ConfigurationNotSetException
entailment
public static function treat($requestBody, $authentication = null) { $postArray = json_decode($requestBody, true); if ($postArray === null) { throw new Exception\UnknownAPIResourceException('Request body is not valid JSON.'); } $unsafeAPIResource = Resource\APIResource:...
This function treats a notification and verifies its authenticity. @param string $requestBody JSON Data sent by the notifier. @param Payplug $authentication The client configuration. @return Resource\IVerifiableAPIResource A safe API Resource. @throws Exception\UnknownAPIResourceException
entailment
public static function deleteCard($card, Payplug\Payplug $payplug = null) { if ($payplug === null) { $payplug = Payplug\Payplug::getDefaultConfiguration(); } if ($card instanceof Card) { $card = $card->id; } $httpClient = new Payplug\Core\HttpClient(...
Delete the card. @param Payplug\Card $card the card or card id @param Payplug\Payplug $payplug the client configuration @return Card the deleted card or null on error @throws Payplug\Exception\ConfigurationNotSetException
entailment
public function delete(Payplug\Payplug $payplug = null) { self::deleteCard($this->id, $payplug); }
Delete the card. @param Payplug\Payplug $payplug the client configuration @throws Payplug\Exception\ConfigurationNotSetException
entailment
public function post($resource, $data = null, $authenticated = true) { return $this->request('POST', $resource, $data, $authenticated); }
Sends a POST request to the API. @param string $resource the path to the remote resource @param array $data Request data @param bool $authenticated the request should be authenticated @return array the response in a dictionary with following keys: <pre> 'httpStatus' => The 2xx HTTP status c...
entailment
public static function addDefaultUserAgentProduct($product, $version = null, $comment = null) { self::$defaultUserAgentProducts[] = array($product, $version, $comment); }
Adds a default product for the User-Agent HTTP header sent for each HTTP request. @param string $product the product's name @param string $version the product's version @param string $comment a comment about the product
entailment
private static function formatUserAgentProduct($product, $version = null, $comment = null) { $productString = $product; if ($version) { $productString .= '/' . $version; } if ($comment) { $productString .= ' (' . $comment . ')'; } return $produ...
Formats a product for a User-Agent HTTP header. @param string $product the product name @param string $version (optional) product version @param string $comment (optional) comment about the product. @return string a formatted User-Agent string (`PRODUCT/VERSION (COMMENT)`)
entailment
public static function getUserAgent() { $curlVersion = curl_version(); // Do not move this inside $headers even if it is used only there. // PHP < 5.4 doesn't support call()['value'] directly. $userAgent = self::formatUserAgentProduct('PayPlug-PHP', ...
Gets the User-Agent HTTP header sent for each HTTP request.
entailment
private function request($httpVerb, $resource, array $data = null, $authenticated = true) { if (self::$REQUEST_HANDLER === null) { $request = new CurlRequest(); } else { $request = self::$REQUEST_HANDLER; } $userAgent = self::getUserAgent(); $...
Performs a request. @param string $httpVerb the HTTP verb (PUT, POST, GET, …) @param string $resource the path to the resource queried @param array $data the request content @param bool $authenticated the request should be authenticated @return array the response in a dictionary ...
entailment
private function throwRequestException($httpResponse, $httpStatus) { $exception = null; // Error 5XX if (substr($httpStatus, 0, 1) === '5') { throw new Payplug\Exception\PayplugServerException('Unexpected server error during the request.', $httpResponse, $httpSta...
Throws an exception from a given HTTP response and status. @param string $httpResponse the HTTP response @param int $httpStatus the HTTP status @throws Payplug\Exception\HttpException the generated exception from the request
entailment
protected function initialize(array $attributes) { parent::initialize($attributes); if (isset($attributes['card'])) { $this->card = PaymentCard::fromAttributes($attributes['card']); } if (isset($attributes['customer'])) { $this->customer = PaymentCustomer::fr...
Initializes the resource. This method must be overridden when the resource has objects as attributes. @param array $attributes the attributes to initialize.
entailment
public function refund(array $data = null, Payplug\Payplug $payplug = null) { if (!array_key_exists('id', $this->getAttributes())) { throw new Payplug\Exception\InvalidPaymentException("This payment object has no id. It can't be refunded."); } return Refund::create($this->id, $d...
Open a refund on the payment. @param array $data the refund data @param Payplug\Payplug $payplug the client configuration @return Refund|null the opened refund instance @throws Payplug\Exception\InvalidPaymentException when the id of the payment is invalid
entailment
public function listRefunds(Payplug\Payplug $payplug = null) { if (!array_key_exists('id', $this->getAttributes())) { throw new Payplug\Exception\InvalidPaymentException("This payment object has no id. You can't list refunds on it."); } return Refund::listRefunds($this->id, $pay...
List the refunds of this payment. @param Payplug\Payplug $payplug the client configuration @return null|Refund[] the array of refunds of this payment @throws Payplug\Exception\InvalidPaymentException @throws Payplug\Exception\UnexpectedAPIResponseException
entailment
public function capture(Payplug\Payplug $payplug = null) { if ($payplug === null) { $payplug = Payplug\Payplug::getDefaultConfiguration(); } $httpClient = new Payplug\Core\HttpClient($payplug); $response = $httpClient->patch( Payplug\Core\APIRoutes::getRoute(...
Captures a Payment. @param Payplug\Payplug $payplug the client configuration @return null|Payment the captured payment or null on error @throws Payplug\Exception\ConfigurationNotSetException
entailment
public static function retrieve($paymentId, Payplug\Payplug $payplug = null) { if ($payplug === null) { $payplug = Payplug\Payplug::getDefaultConfiguration(); } $httpClient = new Payplug\Core\HttpClient($payplug); $response = $httpClient->get( Payplug\Core\AP...
Retrieves a Payment. @param string $paymentId the payment ID @param Payplug\Payplug $payplug the client configuration @return null|Payment the retrieved payment or null on error @throws Payplug\Exception\ConfigurationNotSetException
entailment
public static function listPayments($perPage = null, $page = null, Payplug\Payplug $payplug = null) { if ($payplug === null) { $payplug = Payplug\Payplug::getDefaultConfiguration(); } $httpClient = new Payplug\Core\HttpClient($payplug); $pagination = array('per_page' => ...
List payments. @param Payplug\Payplug $payplug the client configuration @param int $perPage the number of results per page @param int $page the page number @return null|Payment[] the array of payments @throws Payplug\Exception\InvalidPaymentException @throws ...
entailment
public static function create(array $data, Payplug\Payplug $payplug = null) { if ($payplug === null) { $payplug = Payplug\Payplug::getDefaultConfiguration(); } $httpClient = new Payplug\Core\HttpClient($payplug); $response = $httpClient->post( Payplug\Core\AP...
Creates a Payment. @param array $data API data for payment creation @param Payplug\Payplug $payplug the client configuration @return null|Payment the created payment instance @throws Payplug\Exception\ConfigurationNotSetException
entailment
function getConsistentResource(Payplug\Payplug $payplug = null) { if (!array_key_exists('id', $this->_attributes)) { throw new Payplug\Exception\UndefinedAttributeException('The id of the payment is not set.'); } return Payment::retrieve($this->_attributes['id'], $payplug); ...
Returns an API resource that you can trust. @param Payplug\Payplug $payplug the client configuration. @return Payplug\Resource\APIResource The consistent API resource. @throws Payplug\Exception\UndefinedAttributeException when the local resource is invalid.
entailment
public static function getRoute($route, $resourceId = null, array $parameters = array(), array $pagination = array()) { foreach ($parameters as $parameter => $value) { $route = str_replace('{' . $parameter . '}', $value, $route); } $resourceIdUrl = $resourceId ? '/' . $resourceI...
Get the route to a specified resource. @param string $route One of the routes defined above @param string $resourceId The resource id you want to get. If null, will point to the endpoint. @param array $parameters The parameters required by the route. @param array $pagination The pagination parameters (mainly p...
entailment
public static function delete($card, Payplug $payplug = null) { return Resource\Card::deleteCard($card, $payplug); }
Delete a card. @param string|\Payplug\Resource\Card $card the card ID or object @param Payplug $payplug the client configuration @return null|Resource\Card the deleted card or null on error @throws Exception\ConfigurationNotSetException
entailment
public static function factory(array $attributes) { if (!array_key_exists('object', $attributes)) { throw new Payplug\Exception\UnknownAPIResourceException('Missing "object" property.'); } switch ($attributes['object']) { case 'payment': return Payplu...
Tries to recompose an API Resource from its attributes. For example, when you got it from a notification. The API Resource must have a known 'object' property. @param array $attributes The attributes of the object. @return IVerifiableAPIResource An unsafe API Resource. @throws Payplug\Exception\UnknownAPIReso...
entailment
public static function retrieve($paymentId, Payplug $payplug = null) { return Resource\Payment::retrieve($paymentId, $payplug); }
Retrieves a Payment. @param string $paymentId the payment ID @param Payplug $payplug the client configuration @return null|Resource\Payment the retrieved payment or null on error @throws Exception\ConfigurationNotSetException
entailment
public static function abort($paymentId, Payplug $payplug = null) { $payment = Resource\Payment::fromAttributes(array('id' => $paymentId)); return $payment->abort($payplug); }
Aborts a Payment. @param string $paymentId the payment ID @param Payplug $payplug the client configuration @return null|Resource\Payment the aborted payment or null on error @throws Exception\ConfigurationNotSetException
entailment
public static function create(array $data, Payplug $payplug = null) { return Resource\Payment::create($data, $payplug); }
Creates a Payment. @param array $data API data for payment creation @param Payplug $payplug the client configuration @return null|Resource\Payment the created payment instance @throws Exception\ConfigurationNotSetException
entailment
public static function listPayments($perPage = null, $page = null, Payplug $payplug = null) { return Resource\Payment::listPayments($perPage, $page, $payplug); }
List payments. @param int $perPage number of results per page @param int $page the page number @param Payplug $payplug the client configuration @return null|Resource\Payment[] the array of payments @throws Exception\InvalidPaymentException @throws Exceptio...
entailment
protected function createSignature($resource) { if (!$this->key) { throw new Exception('Missing api key'); } if (!$this->secret) { throw new Exception('Missing api secret'); } if (!$this->workspace) { throw new Excep...
@param string $resource @return string @throws Exception
entailment
public function request($method = self::REQUEST_POST, $resource, array $params = [], array $headers = []) { $signature = $this->createSignature($resource); $method = strtoupper($method); $options = [ 'headers' => array_merge($headers, [ 'X-Auth-Key' => $this->key...
@param string $method @param string $resource @param array $params @param array $headers @return \stdClass @throws \ActualReports\PDFGeneratorAPI\Exception
entailment
protected function handleRequest($method, $resource, $options) { $response = null; try { $response = $this->handleResponse($this->getHttpClient()->request($method, $resource, $options)); } catch (RequestException $e) { $this->handleException($e...
@param $method @param $resource @param $options @return \stdClass|null @throws \ActualReports\PDFGeneratorAPI\Exception
entailment
protected function handleException(RequestException $e) { $message = $e->getMessage(); $code = $e->getCode(); $response = $e->getResponse(); if ($response) { $contents = null; try { $contents = \GuzzleHttp\json_decode($resp...
@param \GuzzleHttp\Exception\RequestException $e @throws \ActualReports\PDFGeneratorAPI\Exception
entailment
protected function handleResponse(ResponseInterface $response) { $contents = $response->getBody()->getContents(); try { return $contents ? \GuzzleHttp\json_decode($contents) : null; } catch (\InvalidArgumentException $e) { throw new Exception('...
@param \Psr\Http\Message\ResponseInterface $response @return \stdClass @throws \ActualReports\PDFGeneratorAPI\Exception
entailment
public function getAll(array $access = [], array $tags = []) { $response = $this->request(self::REQUEST_GET, 'templates', [ 'access' => implode(',', $access), 'tags' => implode(',', $tags) ]); return $response->response; }
Returns list of templates available in active workspace @param array $access @param array $tags @return array @throws \ActualReports\PDFGeneratorAPI\Exception
entailment
public function get($template) { $response = $this->request(self::REQUEST_GET, 'templates/'.$template); return $response->response; }
Returns template configuration @param integer $template @return \stdClass @throws \ActualReports\PDFGeneratorAPI\Exception
entailment
public function create($name) { $response = $this->request(self::REQUEST_POST, 'templates', [ 'data' =>[ 'name' => $name, 'layout' => [ 'format' => 'A4', 'unit' => 'cm', 'orientation' => 'portrait', ...
Creates blank template into active workspace and returns template info @param string $name @return \stdClass @throws \ActualReports\PDFGeneratorAPI\Exception
entailment
public function copy($template, $newName = null) { $response = $this->request(self::REQUEST_POST, 'templates/'.$template.'/copy', [ 'name' => $newName ]); return $response->response; }
Creates copy of given template to active workspace @param integer $template @param string $newName @return \stdClass @throws \ActualReports\PDFGeneratorAPI\Exception
entailment
public function output($template, $data, $format = self::FORMAT_PDF, $name = null, array $params = []) { return $this->request(self::REQUEST_POST, 'templates/'.$template.'/output', array_merge([ 'data' => $data, 'format' => $format, 'name' => $name ], $params)); ...
Returns document as base64 encoded string for given template and data @param integer $template @param string|array|\stdClass $data @param string $format @param string $name @param array $params @return \stdClass @throws \ActualReports\PDFGeneratorAPI\Exception
entailment
public function editor($template, $data = null, array $params = []) { $resource = 'templates/'.$template.'/editor'; $params = array_merge([ 'key' => $this->key, 'workspace' => $this->workspace, 'signature' => $this->createSignature($resource) ], $params); ...
Creates editor url @param integer $template @param array|\stdClass|string $data @param array $params @return string @throws \ActualReports\PDFGeneratorAPI\Exception
entailment
protected static function stringToArray($string) { $data = null; try { $data = \GuzzleHttp\json_decode($string, true); } catch (\InvalidArgumentException $e) { } return $data; }
@param string $string @return array|null
entailment
protected static function dataToString($data) { if (!is_string($data)) { try { $data = \GuzzleHttp\json_encode($data); } catch (\InvalidArgumentException $e) { } } return $data; }
Turns data into string, @param array|string|\stdClass $data @return string
entailment
public static function retrieve($installmentPlanId, Payplug $payplug = null) { return Resource\InstallmentPlan::retrieve($installmentPlanId, $payplug); }
Retrieves an InstallmentPlan. @param string $installmentPlanId the installment plan ID @param Payplug $payplug the client configuration @return null|Resource\InstallmentPlan the retrieved installment plan or null on error @throws Exception\ConfigurationNotSetException
entailment
public static function abort($installmentPlanId, Payplug $payplug = null) { $installmentPlan = Resource\InstallmentPlan::fromAttributes(array('id' => $installmentPlanId)); return $installmentPlan->abort($payplug); }
Aborts an InstallmentPlan. @param string $installmentPlanId the installment plan ID @param Payplug $payplug the client configuration @return null|Resource\InstallmentPlan the aborted installment plan or null on error @throws Exception\ConfigurationNotSetException
entailment
public static function create(array $data, Payplug $payplug = null) { return Resource\InstallmentPlan::create($data, $payplug); }
Creates an InstallmentPlan. @param array $data API data for payment creation @param Payplug $payplug the client configuration @return null|Resource\InstallmentPlan the created payment instance @throws Exception\ConfigurationNotSetException
entailment
public static function create($payment, array $data = null, Payplug $payplug = null) { return Resource\Refund::create($payment, $data, $payplug); }
Creates a refund on a payment. @param string|Payment $payment the payment id or the payment object @param array $data API data for refund @param Payplug $payplug the client configuration @return null|Refund the refund object @throws Exception\ConfigurationNotSetExc...
entailment
public static function retrieve($payment, $refundId, Payplug $payplug = null) { return Resource\Refund::retrieve($payment, $refundId, $payplug); }
Retrieves a refund object on a payment. @param string|Payment $payment the payment id or the payment object @param string $refundId the refund id @param Payplug $payplug the client configuration @return null|Resource\APIResource|Refund the refund object @throws Excepti...
entailment
public static function listRefunds($payment, Payplug $payplug = null) { return Resource\Refund::listRefunds($payment, $payplug); }
Lists the last refunds of a payment. @param string|Payment $payment the payment id or the payment object @param Payplug $payplug the client configuration @return null|Refund[] an array containing the refunds on success. @throws Exception\ConfigurationNotSetException @throws Exception\UnexpectedAP...
entailment
public static function setSecretKey($token) { if (!is_string($token)) { throw new Exception\ConfigurationException('Expected string values for the token.'); } $clientConfiguration = new Payplug($token); self::setDefaultConfiguration($clientConfiguration); retur...
Initializes a Authentication and sets it as the new default global authentication. It also performs some checks before saving the authentication. <pre> Expected array format for argument $authentication : $authentication['TOKEN'] = 'YOUR TOKEN' </pre> @param string $token the authentication token @return Payplug...
entailment
public static function getKeysByLogin($email, $password) { $httpClient = new Core\HttpClient(null); $response = $httpClient->post( Core\APIRoutes::getRoute(Core\APIRoutes::KEY_RESOURCE), array('email' => $email, 'password' => $password), false ); r...
Retrieve existing API keys for an user, using his email and password. This function is for user-friendly interface purpose only. You should probably not use this more than once, login/password MUST NOT be stored and API Keys are enough to interact with API. @param string $email the user email @param string $passwo...
entailment
public static function getAccount(Payplug $payplug = null) { if ($payplug === null) { $payplug = Payplug::getDefaultConfiguration(); } $httpClient = new Core\HttpClient($payplug); $response = $httpClient->get(Core\APIRoutes::getRoute(Core\APIRoutes::ACCOUNT_RESOURCE)); ...
Retrieve account info. @param Payplug $payplug the client configuration @return null|array the account settings @throws Exception\ConfigurationNotSetException
entailment
public static function getPermissionsByLogin($email, $password) { $keys = self::getKeysByLogin($email, $password); $payplug = Payplug::setSecretKey($keys['httpResponse']['secret_keys']['live']); $httpClient = new Core\HttpClient($payplug); $response = $httpClient->get(Core\APIRoutes:...
Retrieve the account permissions, using email and password. This function is for user-friendly interface purpose only. You should probably not use this more than once, login/password MUST NOT be stored and API Keys are enough to interact with API. @param string $email the user email @param string $password the use...
entailment
function paymentInit(Payment $payment, $extensions = array()) { $payment->checkAndPrepare($this->config); $array = $payment->signAndExport($this); $this->writeToLog("payment/init started for payment with orderNo " . $payment->orderNo); try { $ret = $this->sendRequest( "payment/init", $array, "...
Performs payment/init API call. Use this to create new payment in payment gateway. After successful call, the $payment object will be updated by given PayID. @param Payment $payment Create and fill this object manually with real data. @param Extension[]|Extension $extensions Added extensions @return array Array with...
entailment
function getPaymentProcessUrl($payment) { $payId = $this->getPayId($payment); $payload = array( "merchantId" => $this->config->merchantId, "payId" => $payId, "dttm" => $this->getDTTM() ); $payload["signature"] = $this->signRequest($payload); $url = $this->sendRequest( "payment/process", $pay...
Generates URL to send customer's browser to after initiating the payment. Use this after you successfully called paymentInit() and redirect the customer's browser on the URL that this method returns manually, or use redirectToGateway(). @param string|Payment $payment Either PayID given during paymentInit(), or just t...
entailment
function getPaymentCheckoutUrl($payment, $oneClickPaymentCheckbox, $displayOmnibox = null, $returnCheckoutUrl = null) { $payId = $this->getPayId($payment); $payload = array( "merchantId" => $this->config->merchantId, "payId" => $payId, "dttm" => $this->getDTTM(), ...
Generates checkout URL to send customer's browser to after initiating the payment. @param string|Payment $payment Either PayID given during paymentInit(), or just the Payment object you used in paymentInit() @param int $oneClickPaymentCheckbox Flag to indicate whether to display the checkbox for saving card for futur...
entailment
function redirectToGateway($payment) { if (headers_sent($file, $line)) { $this->writeToLog("Can't redirect, headers sent at $file, line $line"); throw new Exception("Can't redirect the browser, headers were already sent at $file line $line"); } $url = $this->getPaymentProcessUrl($payment); $this->writeT...
Redirect customer's browser to payment gateway. Use this after you successfully called paymentInit() Note that HTTP headers must not have been sent before. @param string|Payment $payment Either PayID given during paymentInit(), or just the Payment object you used in paymentInit() @throws Exception If headers has be...
entailment
function paymentStatus($payment, $returnStatusOnly = true, $extensions = array()) { $payId = $this->getPayId($payment); $this->writeToLog("payment/status started for payment $payId"); $payload = array( "merchantId" => $this->config->merchantId, "payId" => $payId, "dttm" => $this->getDTTM() ); try ...
Check payment status by calling payment/status API method. Use this to check current status of some transaction. See ČSOB's wiki on Github for explanation of each status. Basically, they are: - 1 = new; after paymentInit() but before customer starts filling in his card number and authorising the transaction - 2 = in...
entailment
function paymentReverse($payment, $ignoreWrongPaymentStatusError = false, $extensions = array()) { $payId = $this->getPayId($payment); $payload = array( "merchantId" => $this->config->merchantId, "payId" => $payId, "dttm" => $this->getDTTM() ); $this->writeToLog("payment/reverse started for payment $...
Performs payment/reverse API call. Reversing payment means stopping payment that has not yet been processed by bank (usually about 1 working day after being created). Normally, payment must be in state 4 or 7 to be reversable. If the payment is not in an acceptable state, then the gateway returns an error code 150 an...
entailment
function paymentRecurrent($origPayment, Payment $newPayment) { trigger_error('paymentRecurrent() is deprecated now, please use paymentOneClick() instead.', E_USER_DEPRECATED); $origPayId = $this->getPayId($origPayment); $newOrderNo = $newPayment->orderNo; if (!$newOrderNo or !preg_match('~^\d{1,10}$~', $newO...
Performs payment/recurrent API call. Use this method to redo a payment that has already been marked as a template for recurring payments and approved by customer - see Payment::setRecurrentPayment() You need PayID of the original payment and a new Payment object. Only $orderNo, $totalAmount (sum of cart items added b...
entailment
function paymentOneClickStart(Payment $newPayment, $extensions = array()) { $newPayId = $newPayment->getPayId(); if (!$newPayId) { throw new Exception('Given Payment object does not have a PayId. Please provide a Payment object that was returned from paymentOneClickInit() method.'); } $payload = array( ...
Performs a payment/oneclick/start API call. Use this method to confirm a recurring one click payment that was previously initiated using paymentOneClickInit() method. @param Payment $newPayment @param Extension[]|Extension $extensions @return array|string
entailment