Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/Payplug/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Payment
*/


public static function retrieve($data, Payplug $payplug = null, $isHostedField = false)
public static function retrieve($data, $payplug = null, $isHostedField = false)
{
return Resource\Payment::retrieve($data, $payplug, $isHostedField);
}
Expand Down Expand Up @@ -59,7 +59,7 @@ public static function abort($paymentId, $payplug = null)
* @return Resource\Payment|null The captured payment or null on error.
* @throws Exception\ConfigurationNotSetException
*/
public static function capture($paymentId, Payplug $payplug = null)
public static function capture($paymentId, $payplug = null)
{
$payment = Resource\Payment::fromAttributes(array('id' => $paymentId));
return $payment->capture($payplug);
Expand All @@ -72,7 +72,7 @@ public static function capture($paymentId, Payplug $payplug = null)
* @param $is_hosted_field
* @return mixed
*/
public static function authorize($data, Payplug $payplug = null, $is_hosted_field = false)
public static function authorize($data, $payplug = null, $is_hosted_field = false)
{
return Resource\Payment::authorize($data, $payplug, $is_hosted_field);

Expand Down Expand Up @@ -100,7 +100,7 @@ public static function create(array $data, $payplug = null)
* @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
Expand All @@ -109,5 +109,5 @@ public static function create(array $data, $payplug = null)
public static function listPayments($perPage = null, $page = null, $payplug = null)
{
return Resource\Payment::listPayments($perPage, $page, $payplug);
}
};
}
};
6 changes: 3 additions & 3 deletions lib/Payplug/Refund.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ class Refund {
/**
* Creates a refund on a payment.
*
* @param string|Payment $payment the payment id or the payment object
* @param string|Payment|array $payment the payment id or the payment object
* @param array $data API data for refund
* @param Payplug $payplug the client configuration
* @param $is_hosted_field indicates if the payment is using hosted fields
*
* @return null|Refund the refund object
* @throws Exception\ConfigurationNotSetException
*/
public static function create($payment, array $data = null, Payplug $payplug = null, $is_hosted_field = false)
public static function create($payment, $data = null, $payplug = null, $is_hosted_field = false)
{
return Resource\Refund::create($payment, $data, $payplug, $is_hosted_field);
}
Expand Down Expand Up @@ -52,4 +52,4 @@ public static function listRefunds($payment, $payplug = null)
{
return Resource\Refund::listRefunds($payment, $payplug);
}
}
}
28 changes: 20 additions & 8 deletions lib/Payplug/Resource/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,19 +126,31 @@ public function abort($payplug = null)
/**
* Captures a Payment.
*
* @param Payplug\Payplug $payplug the client configuration
* @param Payplug\Payplug|null $payplug the client configuration
* @param array|null $hostFieldsPayload
*
* @return null|Payment the captured payment or null on error
* @return null|Payment the captured payment or null on error
*
* @throws Payplug\Exception\ConfigurationNotSetException
* @throws Payplug\Exception\ConfigurationNotSetException
*/
public function capture(Payplug\Payplug $payplug = null)
public function capture($payplug = null, $hostFieldsPayload = null)
{
if ($payplug === null) {
$payplug = Payplug\Payplug::getDefaultConfiguration();
}

$httpClient = new Payplug\Core\HttpClient($payplug);

if ($hostFieldsPayload !== null) {
$response = $httpClient->post(
Payplug\Core\APIRoutes::$HOSTED_FIELDS_RESOURCE,
$hostFieldsPayload,
false
);

return $response['httpResponse'];
}

$response = $httpClient->patch(
Payplug\Core\APIRoutes::getRoute(Payplug\Core\APIRoutes::PAYMENT_RESOURCE, $this->id),
array('captured' => true)
Expand All @@ -151,15 +163,15 @@ public function capture(Payplug\Payplug $payplug = null)
* @description Authorize a Payment.
* @param $data
* @param Payplug\Payplug|null $payplug
* @param $is_hosted_field
* @param bool $is_hosted_field
* @return mixed|void
* @throws Payplug\Exception\ConfigurationNotSetException
* @throws Payplug\Exception\ConnectionException
* @throws Payplug\Exception\HttpException
* @throws Payplug\Exception\UndefinedAttributeException
* @throws Payplug\Exception\UnexpectedAPIResponseException
*/
public static function authorize($data, Payplug\Payplug $payplug = null, $is_hosted_field = false)
public static function authorize($data, $payplug = null, $is_hosted_field = false)
{
if ($payplug === null) {
$payplug = Payplug\Payplug::getDefaultConfiguration();
Expand All @@ -182,15 +194,15 @@ public static function authorize($data, Payplug\Payplug $payplug = null, $is_hos
/**
* @param $data
* @param Payplug\Payplug|null $payplug
* @param $is_hosted_field
* @param bool $is_hosted_field
* @return array|Payment
* @throws Payplug\Exception\ConfigurationNotSetException
* @throws Payplug\Exception\ConnectionException
* @throws Payplug\Exception\HttpException
* @throws Payplug\Exception\UndefinedAttributeException
* @throws Payplug\Exception\UnexpectedAPIResponseException
*/
public static function retrieve($data, Payplug\Payplug $payplug = null, $is_hosted_field = false)
public static function retrieve($data, $payplug = null, $is_hosted_field = false)
{
if ($payplug === null) {
$payplug = Payplug\Payplug::getDefaultConfiguration();
Expand Down
6 changes: 3 additions & 3 deletions lib/Payplug/Resource/Refund.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ public static function fromAttributes(array $attributes)
/**
* Creates a refund on a payment.
*
* @param string|Payment $refund_data the payment id or the payment object
* @param string|Payment|array $refund_data the payment id or the payment object
* @param array $data API data for refund
* @param Payplug\Payplug $payplug the client configuration
* @param $is_hosted_field
* @param bool $is_hosted_field
*
* @return null|Refund the refund object
* @throws Payplug\Exception\ConfigurationNotSetException
*/
public static function create($refund_data, array $data = null, Payplug\Payplug $payplug = null, $is_hosted_field = false)
public static function create($refund_data, $data = null, $payplug = null, $is_hosted_field = false)
{
if ($payplug === null) {
$payplug = Payplug\Payplug::getDefaultConfiguration();
Expand Down
Loading
Loading