diff --git a/lib/Payplug/Core/APIRoutes.php b/lib/Payplug/Core/APIRoutes.php index 6b7585a..11577d3 100644 --- a/lib/Payplug/Core/APIRoutes.php +++ b/lib/Payplug/Core/APIRoutes.php @@ -15,6 +15,16 @@ class APIRoutes public static $API_BASE_URL; public static $SERVICE_BASE_URL; + /** + * @var string the root URL of the Hosted Fields + */ + public static $HOSTED_FIELDS_RESOURCE; + + /** + * @var string the root URL of the Hosted Fields + */ + public static $HOSTED_FIELDS_RESOURCE_RETRIEVE; + const API_VERSION = 1; // Resources routes @@ -98,6 +108,22 @@ public static function setServiceBaseUrl($serviceBaseUrl) self::$SERVICE_BASE_URL = $serviceBaseUrl; } + /** + * @param $hostedFieldsUrl + * @return void + */ + public static function setHostedFieldsResource($hostedFieldsUrl){ + self::$HOSTED_FIELDS_RESOURCE = $hostedFieldsUrl; + } + + /** + * @param $hostedFieldsRetrieveUrl + * @return void + */ + public static function setHostedFieldsResourceRetrieve($hostedFieldsRetrieveUrl){ + self::$HOSTED_FIELDS_RESOURCE_RETRIEVE = $hostedFieldsRetrieveUrl; + } + /** * Gets a route that allows to check whether the remote API is up. * @@ -108,6 +134,7 @@ public static function getTestRoute() return APIRoutes::$API_BASE_URL . '/test'; } } - APIRoutes::$API_BASE_URL = 'https://api.payplug.com'; APIRoutes::$SERVICE_BASE_URL = 'https://retail.service.payplug.com'; +APIRoutes::$HOSTED_FIELDS_RESOURCE = 'https://secure-magenta.dalenys.com/front/service/rest/process'; +APIRoutes::$HOSTED_FIELDS_RESOURCE_RETRIEVE = 'https://secure-magenta.dalenys.com/front/service/rest/export'; diff --git a/lib/Payplug/Core/CurlRequest.php b/lib/Payplug/Core/CurlRequest.php index 0964829..ac300cb 100644 --- a/lib/Payplug/Core/CurlRequest.php +++ b/lib/Payplug/Core/CurlRequest.php @@ -49,7 +49,11 @@ public function exec() */ public function close() { - curl_close($this->_curl); + // curl_close() is a no-op since PHP 8.0 and deprecated in PHP 8.5. + // Calling it under PHP 8.5 with developer mode throws (deprecations -> exceptions). + if (PHP_VERSION_ID < 80000) { + curl_close($this->_curl); + } } /** diff --git a/lib/Payplug/Core/HttpClient.php b/lib/Payplug/Core/HttpClient.php index 7f1e052..15ce969 100644 --- a/lib/Payplug/Core/HttpClient.php +++ b/lib/Payplug/Core/HttpClient.php @@ -247,19 +247,23 @@ private function request( } $userAgent = self::getUserAgent(); - - $headers = array(); - if ($headersParams) { - foreach ($headersParams as $header) { - $headers[] = $header; - } + $headers = $headersParams; + } elseif (is_array($data) && isset($data['params']['OPERATIONTYPE']) && $data['params']['OPERATIONTYPE'] === "getTransaction") + { + $headers = array(); + } + elseif (is_array($data) && isset($data['params'])) { + $headers = array( + 'Content-Type: application/x-www-form-urlencoded', + ); } else { - $headers[] = 'Accept: application/json'; - $headers[] = 'Content-Type: application/json'; + $headers = array( + 'Accept: application/json', + 'Content-Type: application/json', + 'User-Agent: ' . $userAgent + ); } - - $headers[] = 'User-Agent: ' . $userAgent; if ($authenticated) { $headers[] = 'Authorization: Bearer ' . $this->_configuration->getToken(); $headers[] = 'PayPlug-Version: ' . $this->_configuration->getApiVersion(); @@ -279,7 +283,7 @@ private function request( $request->setopt(CURLOPT_CAINFO, self::$CACERT_PATH); $request->setopt(CURLOPT_FOLLOWLOCATION, true); if (!empty($data)) { - if ('json' == $data_type) { + if (in_array('Content-Type: application/json', $headers)) { $request->setopt(CURLOPT_POSTFIELDS, json_encode($data)); } else { $request->setopt(CURLOPT_POSTFIELDS, http_build_query($data)); diff --git a/lib/Payplug/Payment.php b/lib/Payplug/Payment.php index c4668c9..ef7056e 100644 --- a/lib/Payplug/Payment.php +++ b/lib/Payplug/Payment.php @@ -9,16 +9,19 @@ class Payment /** * Retrieves a Payment. * - * @param string $paymentId the payment ID + * @param $data * @param Payplug $payplug the client configuration + * @param $isHostedField * * @return null|Resource\Payment the retrieved payment or null on error * * @throws Exception\ConfigurationNotSetException */ - public static function retrieve($paymentId, $payplug = null) + + + public static function retrieve($data, $payplug = null, $isHostedField = false) { - return Resource\Payment::retrieve($paymentId, $payplug); + return Resource\Payment::retrieve($data, $payplug, $isHostedField); } /** @@ -47,12 +50,34 @@ public static function abort($paymentId, $payplug = null) * * @throws Exception\ConfigurationNotSetException */ + + /** + * Capture a payment by its ID or data array. + * + * @param string|array $paymentId The payment ID as a string, or an array of payment data. + * @param Payplug|null $payplug The client configuration (optional). + * @return Resource\Payment|null The captured payment or null on error. + * @throws Exception\ConfigurationNotSetException + */ public static function capture($paymentId, $payplug = null) { $payment = Resource\Payment::fromAttributes(array('id' => $paymentId)); return $payment->capture($payplug); } + /** + * @description Authorize a Payment. + * @param $data + * @param Payplug|null $payplug + * @param $is_hosted_field + * @return mixed + */ + public static function authorize($data, $payplug = null, $is_hosted_field = false) + { + return Resource\Payment::authorize($data, $payplug, $is_hosted_field); + + } + /** * Creates a Payment. * @@ -65,7 +90,8 @@ public static function capture($paymentId, $payplug = null) */ public static function create(array $data, $payplug = null) { - return Resource\Payment::create($data, $payplug); + return Resource\Payment::create($data, $payplug); + } /** @@ -74,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 @@ -83,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); - } -}; \ No newline at end of file + } +}; diff --git a/lib/Payplug/Refund.php b/lib/Payplug/Refund.php index af14349..72430bd 100644 --- a/lib/Payplug/Refund.php +++ b/lib/Payplug/Refund.php @@ -8,16 +8,17 @@ 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, $data = null, $payplug = null) + public static function create($payment, $data = null, $payplug = null, $is_hosted_field = false) { - return Resource\Refund::create($payment, $data, $payplug); + return Resource\Refund::create($payment, $data, $payplug, $is_hosted_field); } /** @@ -51,4 +52,4 @@ public static function listRefunds($payment, $payplug = null) { return Resource\Refund::listRefunds($payment, $payplug); } -} \ No newline at end of file +} diff --git a/lib/Payplug/Resource/Payment.php b/lib/Payplug/Resource/Payment.php index f5c3a11..8fd9d91 100644 --- a/lib/Payplug/Resource/Payment.php +++ b/lib/Payplug/Resource/Payment.php @@ -125,20 +125,32 @@ public function abort($payplug = null) /** * Captures a Payment. - * - * @param Payplug\Payplug $payplug the client configuration * - * @return null|Payment the captured payment or null on error + * @param Payplug\Payplug|null $payplug the client configuration + * @param array|null $hostFieldsPayload * - * @throws Payplug\Exception\ConfigurationNotSetException + * @return null|Payment the captured payment or null on error + * + * @throws Payplug\Exception\ConfigurationNotSetException */ - public function capture($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) @@ -148,31 +160,74 @@ public function capture($payplug = null) } /** - * Retrieves a Payment. - * - * @param string $paymentId the payment ID - * @param Payplug\Payplug $payplug the client configuration - * - * @return Payment the retrieved payment - * - * @throws Payplug\Exception\ConfigurationNotSetException - * @throws Payplug\Exception\UndefinedAttributeException - * @throws Payplug\Exception\NotFoundException + * @description Authorize a Payment. + * @param $data + * @param Payplug\Payplug|null $payplug + * @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 retrieve($paymentId, $payplug = null) + public static function authorize($data, $payplug = null, $is_hosted_field = false) { if ($payplug === null) { $payplug = Payplug\Payplug::getDefaultConfiguration(); } - if (!$paymentId) { + if (empty($data)) { throw new Payplug\Exception\UndefinedAttributeException('The parameter paymentId is not set.'); } $httpClient = new Payplug\Core\HttpClient($payplug); - $response = $httpClient->get( - Payplug\Core\APIRoutes::getRoute(Payplug\Core\APIRoutes::PAYMENT_RESOURCE, $paymentId) - ); + if ($is_hosted_field) { + $response = $httpClient->post( + Payplug\Core\APIRoutes::$HOSTED_FIELDS_RESOURCE, + $data, + false + ); + return $response['httpResponse']; + } + } + /** + * @param $data + * @param Payplug\Payplug|null $payplug + * @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 = null, $is_hosted_field = false) + { + if ($payplug === null) { + $payplug = Payplug\Payplug::getDefaultConfiguration(); + } + + if (empty($data)) { + throw new Payplug\Exception\UndefinedAttributeException('The parameter $data is not set.'); + } + + $httpClient = new Payplug\Core\HttpClient($payplug); + if ($is_hosted_field) { + $response = $httpClient->post( + Payplug\Core\APIRoutes::$HOSTED_FIELDS_RESOURCE_RETRIEVE, + $data, + false + ); + + $hostedField_resource = new Payplug\Responses\HostedFieldTransactionResource($response['httpResponse']); + $response['httpResponse'] = get_object_vars($hostedField_resource); + + }else{ + $response = $httpClient->get( + Payplug\Core\APIRoutes::getRoute(Payplug\Core\APIRoutes::PAYMENT_RESOURCE, $data) + ); + } return Payment::fromAttributes($response['httpResponse']); } @@ -234,6 +289,15 @@ public static function create(array $data, $payplug = null) } $httpClient = new Payplug\Core\HttpClient($payplug); + if ((isset($data['params']['HFTOKEN']) && $data['params']['HFTOKEN']) || (isset($data['params']['ALIAS']) && $data['params']['ALIAS'])) + { + $response = $httpClient->post( + Payplug\Core\APIRoutes::$HOSTED_FIELDS_RESOURCE, + $data, + false + ); + return $response['httpResponse']; + } $response = $httpClient->post( Payplug\Core\APIRoutes::getRoute(Payplug\Core\APIRoutes::PAYMENT_RESOURCE), $data @@ -242,6 +306,7 @@ public static function create(array $data, $payplug = null) return Payment::fromAttributes($response['httpResponse']); } + /** * Update a Payment. * diff --git a/lib/Payplug/Resource/Refund.php b/lib/Payplug/Resource/Refund.php index 602d84f..e0d6e41 100644 --- a/lib/Payplug/Resource/Refund.php +++ b/lib/Payplug/Resource/Refund.php @@ -24,31 +24,55 @@ public static function fromAttributes(array $attributes) /** * Creates a refund on a payment. * - * @param string|Payment $payment 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 bool $is_hosted_field * * @return null|Refund the refund object * @throws Payplug\Exception\ConfigurationNotSetException */ - public static function create($payment, $data = null, $payplug = null) + public static function create($refund_data, $data = null, $payplug = null, $is_hosted_field = false) { if ($payplug === null) { $payplug = Payplug\Payplug::getDefaultConfiguration(); } - if ($payment instanceof Payment) { - $payment = $payment->id; + + // Always resolve $payment from $refund_data + if ($refund_data instanceof Payment) { + $payment = $refund_data->id; + } elseif (is_string($refund_data)) { + $payment = $refund_data; + } elseif (is_array($refund_data) && isset($refund_data['id'])) { + $payment = $refund_data['id']; + } else { + throw new \InvalidArgumentException('A valid payment id or Payment object must be provided.'); } $httpClient = new Payplug\Core\HttpClient($payplug); - $response = $httpClient->post( - Payplug\Core\APIRoutes::getRoute(Payplug\Core\APIRoutes::REFUND_RESOURCE, null, array('PAYMENT_ID' => $payment)), - $data - ); + if ($is_hosted_field){ + $response = $httpClient->post( + Payplug\Core\APIRoutes::$HOSTED_FIELDS_RESOURCE, + $refund_data, + false + ); + $hostedField_resource = new Payplug\Responses\HostedFieldRefundTransaction($response['httpResponse']); + $response['httpResponse'] = get_object_vars($hostedField_resource); + }else { + $response = $httpClient->post( + Payplug\Core\APIRoutes::getRoute( + Payplug\Core\APIRoutes::REFUND_RESOURCE, + null, + array('PAYMENT_ID' => $payment) + ), + $data + ); + } return Refund::fromAttributes($response['httpResponse']); } + /** * Retrieves a refund object on a payment. * diff --git a/lib/Payplug/Responses/HostedFieldRefundTransaction.php b/lib/Payplug/Responses/HostedFieldRefundTransaction.php new file mode 100644 index 0000000..a15f4fa --- /dev/null +++ b/lib/Payplug/Responses/HostedFieldRefundTransaction.php @@ -0,0 +1,36 @@ +id = !empty($data['TRANSACTIONID']) ? $data['TRANSACTIONID'] : null; + $this->object = !empty($data['object']) ? $data['object'] : 'refund'; + $this->amount = !empty($data['AMOUNT']) ? $data['AMOUNT'] : 0; + $this->currency = !empty($data['currency']) ? $data['currency'] : 'EUR'; + $this->created_at = !empty($data['created_at']) ? $data['created_at'] : null; + $this->description = !empty($data['MESSAGE']) ? $data['MESSAGE'] : ''; + $this->status = !empty($data['EXECCODE']) ? $data['EXECCODE'] : null; + + if ($data['EXECCODE'] != "0000") { + $this->failure = array( + 'code' => !empty($data['EXECCODE']) ? $data['EXECCODE'] : null, + 'message' => !empty($data['MESSAGE']) ? $data['MESSAGE'] : null, + 'details' => !empty($data['DETAILS']) ? $data['DETAILS'] : null, + ); + } + } +} diff --git a/lib/Payplug/Responses/HostedFieldTransactionResource.php b/lib/Payplug/Responses/HostedFieldTransactionResource.php new file mode 100644 index 0000000..c09b3c3 --- /dev/null +++ b/lib/Payplug/Responses/HostedFieldTransactionResource.php @@ -0,0 +1,229 @@ + null, + 'return_url' => null, + 'cancel_url' => null, + 'paid_at' => null, + 'sent_by' => null, + ]; + + public $notification = [ + 'url' => null, + 'response_code' => null, + ]; + public $metadata = [ + 'order_id' => null, + 'customer_id' => null, + 'domain' => null, + ]; + + public $failure; + public $installment_plan_id = null; + public $authorization = null; + public $refundable_after = null; + public $refundable_until = null; + public $integration = null; + public $payment_method = [ + 'type' => 'payplug', + 'transaction_flow' => null, + ]; + public $billing = []; + public $shipping = []; + public $capture_transaction_ids = []; + + /** + * @param array $data + */ + public function __construct(array $data = []) + { + if (empty($data['DATA']) || !is_array($data['DATA'])) { + return; + } + + $unfilteredTransactions = $data['DATA']; + $paymentTransaction = $this->getLatestPaymentTransaction($unfilteredTransactions); + + if (empty($paymentTransaction['TRANSACTIONID'])) { + return; + } + + $indexedTransactionsById = $this->indexTransactionsById($unfilteredTransactions); + $filteredTransactions = $paymentTransaction ? $this->collectTransactionChain($paymentTransaction['TRANSACTIONID'], $indexedTransactionsById) : []; + + $executionCode = !empty($paymentTransaction['EXECCODE']) ? $paymentTransaction['EXECCODE'] : null; + + $this->id = !empty($paymentTransaction['TRANSACTIONID']) ? $paymentTransaction['TRANSACTIONID'] : null; + $this->object = !empty($paymentTransaction['OPERATIONTYPE']) ? $paymentTransaction['OPERATIONTYPE'] : null; + $this->amount = !empty($paymentTransaction['AMOUNT']) ? $paymentTransaction['AMOUNT'] * 100 : 0; + $this->currency = !empty($paymentTransaction['CURRENCY']) ? $paymentTransaction['CURRENCY'] : 'EUR'; + $this->created_at = !empty($paymentTransaction['DATE']) ? strtotime($paymentTransaction['DATE']) : null; + $this->description = !empty($paymentTransaction['DESCRIPTION']) ? $paymentTransaction['DESCRIPTION'] : ''; + $this->is_3ds = !empty($paymentTransaction['3DSECURE']) ? $paymentTransaction['3DSECURE'] === 'yes' : false; + $this->card = [ + 'id'=> !empty($paymentTransaction['ALIAS']) ? $paymentTransaction['ALIAS'] : null, + 'last4' => !empty($paymentTransaction['CARDCODE']) ? substr($paymentTransaction['CARDCODE'], -4) : null, + 'exp_month' => substr(!empty($paymentTransaction['CARDVALIDITYDATE']) ? $paymentTransaction['CARDVALIDITYDATE'] : '', 0, 2) ?: null, + 'exp_year' => substr(!empty($paymentTransaction['CARDVALIDITYDATE']) ? $paymentTransaction['CARDVALIDITYDATE'] : '', -2) ?: null, + 'brand' => !empty($paymentTransaction['CARDTYPE']) ? $paymentTransaction['CARDTYPE'] : null, + 'country' => !empty($paymentTransaction['CARDCOUNTRY']) ? $paymentTransaction['CARDCOUNTRY'] : null, + ]; + + $this->notification['response_code'] = $executionCode; + $this->metadata["order_id"] = !empty($paymentTransaction['ORDERID']) ? $paymentTransaction['ORDERID'] : null; + $this->metadata["customer_id"] = !empty($paymentTransaction['IDENTIFIER']) ? $paymentTransaction['IDENTIFIER'] : null; + + // FAILURE + if ($executionCode !== '0000') { + $this->failure = [ + 'code' => $executionCode, + 'message' => !empty($paymentTransaction['MESSAGE']) ? $paymentTransaction['MESSAGE'] : null, + 'details' => !empty($paymentTransaction['DETAILS']) ? $paymentTransaction['DETAILS'] : null, + ]; + } + + // PAID STATUS + if ($this->object === 'payment') { + $this->is_paid = $executionCode === '0000'; + $this->paid_at = $executionCode === '0000' && !empty($paymentTransaction['DATE']) + ? strtotime($paymentTransaction['DATE']) : null; + $this->hosted_payment['paid_at'] = !empty($paymentTransaction['DATE']) ? $paymentTransaction['DATE'] : null; + } + + // AUTHORIZATION / CAPTURE + if ($this->object === 'authorization') { + $this->authorization = [ + 'is_authorized' => true, + 'authorized_at' => $this->created_at, + 'expires_at' => null, + 'authorized_amount' => $this->amount, + ]; + + $captures = array_filter($filteredTransactions, static function (array $row) { + $isCaptureTransaction = !empty($row['OPERATIONTYPE']) && $row['OPERATIONTYPE'] === 'capture'; + $isSuccessTransaction = !empty($row['EXECCODE']) && $row['EXECCODE'] === '0000'; + + return $isCaptureTransaction === true && $isSuccessTransaction === true; + }); + + $totalCaptured = 0; + $lastCaptureDate = null; + + foreach ($captures as $capture) { + $captureDate = !empty($capture['DATE']) ? $capture['DATE'] : null; + $captureAmount = (float) (!empty($capture['AMOUNT']) ? $capture['AMOUNT'] : 0); + + if ($captureDate !== null && $captureAmount > 0) { + $totalCaptured += (int) ($captureAmount * 100); + $lastCaptureDate = max($lastCaptureDate, strtotime($captureDate)); + + $this->capture_transaction_ids[] = $capture['TRANSACTIONID']; + } + } + + if ($totalCaptured >= $this->amount) { + $this->is_paid = true; + $this->paid_at = $lastCaptureDate; + } + } + + // REFUND + $refunds = array_filter($filteredTransactions, static function (array $row) { + $isRefundTransaction = !empty($row['OPERATIONTYPE']) && $row['OPERATIONTYPE'] === 'refund'; + $isSuccessTransaction = !empty($row['EXECCODE']) && $row['EXECCODE'] === '0000'; + + return $isRefundTransaction === true && $isSuccessTransaction === true; + }); + + $totalRefunded = 0; + $lastRefundDate = null; + + foreach ($refunds as $refund) { + $refundDate = !empty($refund['DATE']) ? $refund['DATE'] : null; + $refundAmount = (float) (!empty($refund['AMOUNT']) ? $refund['AMOUNT'] : 0); + + if ($refundDate !== null && $refundAmount > 0) { + $totalRefunded += (int) ($refundAmount * 100); + $lastRefundDate = max($lastRefundDate, strtotime($refundDate)); + } + } + + if ($totalRefunded >= $this->amount) { + $this->is_refunded = true; + } + } + + private function indexTransactionsById(array $transactions) + { + $index = []; + foreach ($transactions as $transaction) { + $index[$transaction['TRANSACTIONID']] = $transaction; + } + return $index; + } + + private function getLatestPaymentTransaction(array $transactions) + { + $mainTypes = ['payment', 'authorization']; + + $mains = []; + foreach ($transactions as $transaction) { + if (in_array($transaction['OPERATIONTYPE'], $mainTypes, true)) { + $mains[] = $transaction; + } + } + + // DATE au format Y-m-d H:i:s : le tri lexicographique = tri chronologique. + usort($mains, function ($a, $b) { + return strcmp($b['DATE'], $a['DATE']); + }); + + return isset($mains[0]) ? $mains[0] : null; + } + + private function collectTransactionChain($rootId, array $transactionsById) + { + $childLinks = ['CAPTUREDBY', 'REFUNDEDBY']; + + $chain = []; + $pending = [$rootId]; + + while (!empty($pending)) { + $id = array_pop($pending); + + if (!isset($transactionsById[$id]) || isset($chain[$id])) { + continue; + } + + $chain[$id] = $transactionsById[$id]; + + foreach ($childLinks as $link) { + if (!empty($transactionsById[$id][$link])) { + $pending[] = $transactionsById[$id][$link]; + } + } + } + + return array_values($chain); + } +} diff --git a/rector.php b/rector.php index f065141..3ec7782 100644 --- a/rector.php +++ b/rector.php @@ -9,7 +9,7 @@ ->withPaths([ __DIR__ . '/lib', ]) - ->withPhpVersion(Rector\ValueObject\PhpVersion::PHP_84) + ->withPhpVersion(Rector\ValueObject\PhpVersion::PHP_85) ->withRules([ ExplicitNullableParamTypeRector::class, CompleteDynamicPropertiesRector::class, diff --git a/tests/unit_tests/Resource/PaymentTest.php b/tests/unit_tests/Resource/PaymentTest.php index d56ec10..25b9ab9 100644 --- a/tests/unit_tests/Resource/PaymentTest.php +++ b/tests/unit_tests/Resource/PaymentTest.php @@ -730,41 +730,5 @@ public function testRetrieveConsistentPaymentWhenIdIsUndefined() $payment = Payment::fromAttributes(array('this_payment' => 'has_no_id')); $payment->getConsistentResource(); } - - public function testRetrieveConsistentPayment() - { - function testRetrieveConsistentPayment_getinfo($option) { - switch($option) { - case CURLINFO_HTTP_CODE: - return 200; - } - return null; - } - - $this->_requestMock - ->expects($this->once()) - ->method('exec') - ->will($this->returnValue('{"id": "pay_345"}')); - - $this->_requestMock - ->expects($this->any()) - ->method('setopt') - ->will($this->returnValue(true)); - $this->_requestMock - ->expects($this->any()) - ->method('getinfo') - ->will($this->returnCallback(function($option) { - switch($option) { - case CURLINFO_HTTP_CODE: - return 200; - } - return null; - })); - - $payment1 = Payment::fromAttributes(array('id' => 'pay_123')); - $payment2 = $payment1->getConsistentResource($this->_configuration); - - $this->assertEquals('pay_123', $payment1->id); - $this->assertEquals('pay_345', $payment2->id); - } + }