From b868f3651bb66db2bae2c6e27cf29f038a413aeb Mon Sep 17 00:00:00 2001 From: ProcessOut Fountain Date: Fri, 17 Jan 2025 11:42:40 +0000 Subject: [PATCH] feat: add-new-operation-error-message-field --- README.md | 2 +- init.php | 2 +- src/Customer.php | 34 +++++++++++++++++++ src/Invoice.php | 61 ++++++++++++++++++++++++++++++++++ src/Networking/Request.php | 2 +- src/ProcessOut.php | 18 +++++----- src/Token.php | 12 +++---- src/TransactionOperation.php | 64 ++++++++++++++++++++++++++++++++++++ 8 files changed, 177 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 23257b5..893e7be 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ The package's installation is done using composer. Simply add these lines to you ```json { "require": { - "processout/processout-php": "^7.1.0" + "processout/processout-php": "^7.2.0" } } ``` diff --git a/init.php b/init.php index 724a87c..cb99285 100644 --- a/init.php +++ b/init.php @@ -81,8 +81,8 @@ include_once(dirname(__FILE__) . "/src/ErrorCodes.php"); include_once(dirname(__FILE__) . "/src/CategoryErrorCodes.php"); include_once(dirname(__FILE__) . "/src/ExternalThreeDS.php"); -include_once(dirname(__FILE__) . "/src/NativeAPMTransactionDetails.php"); include_once(dirname(__FILE__) . "/src/NativeAPMTransactionDetailsGateway.php"); include_once(dirname(__FILE__) . "/src/NativeAPMTransactionDetailsInvoice.php"); +include_once(dirname(__FILE__) . "/src/NativeAPMTransactionDetails.php"); include_once(dirname(__FILE__) . "/src/GatewayRequest.php"); diff --git a/src/Customer.php b/src/Customer.php index 226f03b..7a9f8d0 100755 --- a/src/Customer.php +++ b/src/Customer.php @@ -94,6 +94,12 @@ class Customer implements \JsonSerializable */ protected $lastName; + /** + * Company name of the customer (for business customers only) + * @var string + */ + protected $companyName; + /** * Address of the customer * @var string @@ -545,6 +551,28 @@ public function setLastName($value) return $this; } + /** + * Get CompanyName + * Company name of the customer (for business customers only) + * @return string + */ + public function getCompanyName() + { + return $this->companyName; + } + + /** + * Set CompanyName + * Company name of the customer (for business customers only) + * @param string $value + * @return $this + */ + public function setCompanyName($value) + { + $this->companyName = $value; + return $this; + } + /** * Get Address1 * Address of the customer @@ -973,6 +1001,9 @@ public function fillWithData($data) if(! empty($data['last_name'])) $this->setLastName($data['last_name']); + if(! empty($data['company_name'])) + $this->setCompanyName($data['company_name']); + if(! empty($data['address1'])) $this->setAddress1($data['address1']); @@ -1046,6 +1077,7 @@ public function jsonSerialize() { "email" => $this->getEmail(), "first_name" => $this->getFirstName(), "last_name" => $this->getLastName(), + "company_name" => $this->getCompanyName(), "address1" => $this->getAddress1(), "address2" => $this->getAddress2(), "city" => $this->getCity(), @@ -1277,6 +1309,7 @@ public function create($options = array()) "email" => $this->getEmail(), "first_name" => $this->getFirstName(), "last_name" => $this->getLastName(), + "company_name" => $this->getCompanyName(), "address1" => $this->getAddress1(), "address2" => $this->getAddress2(), "city" => $this->getCity(), @@ -1354,6 +1387,7 @@ public function save($options = array()) "email" => $this->getEmail(), "first_name" => $this->getFirstName(), "last_name" => $this->getLastName(), + "company_name" => $this->getCompanyName(), "address1" => $this->getAddress1(), "address2" => $this->getAddress2(), "city" => $this->getCity(), diff --git a/src/Invoice.php b/src/Invoice.php index 4af65c2..0f27b86 100755 --- a/src/Invoice.php +++ b/src/Invoice.php @@ -2291,4 +2291,65 @@ public function delete($invoiceId, $options = array()) return array_values($returnValues)[0]; } + /** + * Refresh invoice by its ID with PSP. + * @param string $invoiceId + * @param array $options + * @return $this + */ + public function syncWithPsp($invoiceId, $options = array()) + { + $this->fillWithData($options); + + $request = new Request($this->client); + $path = "/invoices/" . urlencode($invoiceId) . "/sync-with-psp"; + + $data = array( + + ); + + $response = $request->put($path, $data, $options); + $returnValues = array(); + + + // Handling for field invoice + $body = $response->getBody(); + $body = $body['invoice']; + $returnValues['syncWithPsp'] = $this->fillWithData($body); + + return array_values($returnValues)[0]; + } + + /** + * Update invoice by its ID. + * @param string $invoiceId + * @param array $options + * @return $this + */ + public function update($invoiceId, $options = array()) + { + $this->fillWithData($options); + + $request = new Request($this->client); + $path = "/invoices/" . urlencode($invoiceId) . ""; + + $data = array( + "amount" => $this->getAmount(), + "tax" => $this->getTax(), + "details" => $this->getDetails(), + "shipping" => $this->getShipping() + ); + + $response = $request->put($path, $data, $options); + $returnValues = array(); + + + // Handling for field invoice + $body = $response->getBody(); + $body = $body['invoice']; + $returnValues['update'] = $this->fillWithData($body); + + return array_values($returnValues)[0]; + } + } diff --git a/src/Networking/Request.php b/src/Networking/Request.php index 7acad78..58bd6ae 100644 --- a/src/Networking/Request.php +++ b/src/Networking/Request.php @@ -31,7 +31,7 @@ protected function prepare($options, $len = null) $headers = array( 'API-Version: 1.4.0.0', 'Content-Type: application/json', - 'User-Agent: ProcessOut PHP-Bindings/7.1.0' + 'User-Agent: ProcessOut PHP-Bindings/7.2.0' ); if (! empty($options['idempotencyKey'])) $headers[] = 'Idempotency-Key: ' . $options['idempotencyKey']; diff --git a/src/ProcessOut.php b/src/ProcessOut.php index 79a7180..25e1def 100644 --- a/src/ProcessOut.php +++ b/src/ProcessOut.php @@ -694,15 +694,6 @@ public function newExternalThreeDS($prefill = array()) { return new ExternalThreeDS($this, $prefill); } - /** - * Create a new NativeAPMTransactionDetails instance - * @param array|null $prefill array used to prefill the object - * @return NativeAPMTransactionDetails - */ - public function newNativeAPMTransactionDetails($prefill = array()) { - return new NativeAPMTransactionDetails($this, $prefill); - } - /** * Create a new NativeAPMTransactionDetailsGateway instance * @param array|null $prefill array used to prefill the object @@ -721,4 +712,13 @@ public function newNativeAPMTransactionDetailsInvoice($prefill = array()) { return new NativeAPMTransactionDetailsInvoice($this, $prefill); } + /** + * Create a new NativeAPMTransactionDetails instance + * @param array|null $prefill array used to prefill the object + * @return NativeAPMTransactionDetails + */ + public function newNativeAPMTransactionDetails($prefill = array()) { + return new NativeAPMTransactionDetails($this, $prefill); + } + } diff --git a/src/Token.php b/src/Token.php index bafe9d5..fa13148 100755 --- a/src/Token.php +++ b/src/Token.php @@ -59,7 +59,7 @@ class Token implements \JsonSerializable protected $cardId; /** - * Type of the token. Can be card or gateway_token + * Type of the token. Can be card, bank_account or gateway_token * @var string */ protected $type; @@ -95,7 +95,7 @@ class Token implements \JsonSerializable protected $cancelUrl; /** - * Summary of the customer token, such as a description of the card used or the email of a PayPal account + * Summary of the customer token, such as a description of the card used or bank account or the email of a PayPal account * @var string */ protected $summary; @@ -338,7 +338,7 @@ public function setCardId($value) /** * Get Type - * Type of the token. Can be card or gateway_token + * Type of the token. Can be card, bank_account or gateway_token * @return string */ public function getType() @@ -348,7 +348,7 @@ public function getType() /** * Set Type - * Type of the token. Can be card or gateway_token + * Type of the token. Can be card, bank_account or gateway_token * @param string $value * @return $this */ @@ -470,7 +470,7 @@ public function setCancelUrl($value) /** * Get Summary - * Summary of the customer token, such as a description of the card used or the email of a PayPal account + * Summary of the customer token, such as a description of the card used or bank account or the email of a PayPal account * @return string */ public function getSummary() @@ -480,7 +480,7 @@ public function getSummary() /** * Set Summary - * Summary of the customer token, such as a description of the card used or the email of a PayPal account + * Summary of the customer token, such as a description of the card used or bank account or the email of a PayPal account * @param string $value * @return $this */ diff --git a/src/TransactionOperation.php b/src/TransactionOperation.php index 3c3d3ee..5c9efbc 100755 --- a/src/TransactionOperation.php +++ b/src/TransactionOperation.php @@ -124,6 +124,12 @@ class TransactionOperation implements \JsonSerializable */ protected $errorCode; + /** + * Error message returned when attempting the operation, if any + * @var string + */ + protected $errorMessage; + /** * Additionnal context saved when processing the transaction on the specific PSP * @var dictionary @@ -160,6 +166,12 @@ class TransactionOperation implements \JsonSerializable */ protected $schemeId; + /** + * Indicates whether the transaction was processed with a network token instead of raw card details + * @var boolean + */ + protected $processedWithNetworkToken; + /** * Payment type of the transaction * @var string @@ -621,6 +633,28 @@ public function setErrorCode($value) return $this; } + /** + * Get ErrorMessage + * Error message returned when attempting the operation, if any + * @return string + */ + public function getErrorMessage() + { + return $this->errorMessage; + } + + /** + * Set ErrorMessage + * Error message returned when attempting the operation, if any + * @param string $value + * @return $this + */ + public function setErrorMessage($value) + { + $this->errorMessage = $value; + return $this; + } + /** * Get GatewayData * Additionnal context saved when processing the transaction on the specific PSP @@ -774,6 +808,28 @@ public function setSchemeId($value) return $this; } + /** + * Get ProcessedWithNetworkToken + * Indicates whether the transaction was processed with a network token instead of raw card details + * @return bool + */ + public function getProcessedWithNetworkToken() + { + return $this->processedWithNetworkToken; + } + + /** + * Set ProcessedWithNetworkToken + * Indicates whether the transaction was processed with a network token instead of raw card details + * @param bool $value + * @return $this + */ + public function setProcessedWithNetworkToken($value) + { + $this->processedWithNetworkToken = $value; + return $this; + } + /** * Get PaymentType * Payment type of the transaction @@ -924,6 +980,9 @@ public function fillWithData($data) if(! empty($data['error_code'])) $this->setErrorCode($data['error_code']); + if(! empty($data['error_message'])) + $this->setErrorMessage($data['error_message']); + if(! empty($data['gateway_data'])) $this->setGatewayData($data['gateway_data']); @@ -942,6 +1001,9 @@ public function fillWithData($data) if(! empty($data['scheme_id'])) $this->setSchemeId($data['scheme_id']); + if(! empty($data['processed_with_network_token'])) + $this->setProcessedWithNetworkToken($data['processed_with_network_token']); + if(! empty($data['payment_type'])) $this->setPaymentType($data['payment_type']); @@ -981,12 +1043,14 @@ public function jsonSerialize() { "gateway_operation_id" => $this->getGatewayOperationId(), "arn" => $this->getArn(), "error_code" => $this->getErrorCode(), + "error_message" => $this->getErrorMessage(), "gateway_data" => $this->getGatewayData(), "payment_data_three_d_s_request" => $this->getPaymentDataThreeDSRequest(), "payment_data_three_d_s_authentication" => $this->getPaymentDataThreeDSAuthentication(), "payment_data_network_authentication" => $this->getPaymentDataNetworkAuthentication(), "initial_scheme_transaction_id" => $this->getInitialSchemeTransactionId(), "scheme_id" => $this->getSchemeId(), + "processed_with_network_token" => $this->getProcessedWithNetworkToken(), "payment_type" => $this->getPaymentType(), "metadata" => $this->getMetadata(), "gateway_fee" => $this->getGatewayFee(),