From a0ff35246885b304a76852416051a0d1cb07314f Mon Sep 17 00:00:00 2001 From: ProcessOut Fountain Date: Mon, 8 Jul 2024 14:25:23 +0200 Subject: [PATCH] BREAKING CHANGE: breaking: change response types for invoices-authorize, invoices-capture, invoices-native-payment; breaking: create/update card; add invoice expiry; add invoice qr_code; add invoice delete; add project public metadata; add hosted payment page support --- README.md | 2 +- init.php | 1 - src/CardShipping.php | 96 ++++++++++++++ src/CardUpdateRequest.php | 72 +--------- src/Invoice.php | 129 ++++++++++++++++-- src/InvoiceExternalFraudTools.php | 18 +-- src/InvoiceShipping.php | 96 ++++++++++++++ src/InvoicesProcessNativePaymentResponse.php | 131 ------------------- src/Networking/Request.php | 2 +- src/ProcessOut.php | 9 -- src/Project.php | 3 +- src/Token.php | 3 +- src/Transaction.php | 34 +++++ 13 files changed, 363 insertions(+), 233 deletions(-) delete mode 100755 src/InvoicesProcessNativePaymentResponse.php diff --git a/README.md b/README.md index b16be30..5595750 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": "^6.33.0" + "processout/processout-php": "^7.0.0" } } ``` diff --git a/init.php b/init.php index 41d4776..07b22cb 100644 --- a/init.php +++ b/init.php @@ -75,6 +75,5 @@ 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/InvoicesProcessNativePaymentResponse.php"); include_once(dirname(__FILE__) . "/src/GatewayRequest.php"); diff --git a/src/CardShipping.php b/src/CardShipping.php index b8e0fa6..dca5d1d 100755 --- a/src/CardShipping.php +++ b/src/CardShipping.php @@ -58,6 +58,24 @@ class CardShipping implements \JsonSerializable */ protected $phone; + /** + * First name of the card shipping + * @var string + */ + protected $firstName; + + /** + * Last name of the card shipping + * @var string + */ + protected $lastName; + + /** + * Email of the card shipping + * @var string + */ + protected $email; + /** * CardShipping constructor * @param ProcessOut\ProcessOut $client @@ -232,6 +250,72 @@ public function setPhone($value) return $this; } + /** + * Get FirstName + * First name of the card shipping + * @return string + */ + public function getFirstName() + { + return $this->firstName; + } + + /** + * Set FirstName + * First name of the card shipping + * @param string $value + * @return $this + */ + public function setFirstName($value) + { + $this->firstName = $value; + return $this; + } + + /** + * Get LastName + * Last name of the card shipping + * @return string + */ + public function getLastName() + { + return $this->lastName; + } + + /** + * Set LastName + * Last name of the card shipping + * @param string $value + * @return $this + */ + public function setLastName($value) + { + $this->lastName = $value; + return $this; + } + + /** + * Get Email + * Email of the card shipping + * @return string + */ + public function getEmail() + { + return $this->email; + } + + /** + * Set Email + * Email of the card shipping + * @param string $value + * @return $this + */ + public function setEmail($value) + { + $this->email = $value; + return $this; + } + /** * Fills the current object with the new values pulled from the data @@ -261,6 +345,15 @@ public function fillWithData($data) if(! empty($data['phone'])) $this->setPhone($data['phone']); + if(! empty($data['first_name'])) + $this->setFirstName($data['first_name']); + + if(! empty($data['last_name'])) + $this->setLastName($data['last_name']); + + if(! empty($data['email'])) + $this->setEmail($data['email']); + return $this; } @@ -277,6 +370,9 @@ public function jsonSerialize() { "country_code" => $this->getCountryCode(), "zip" => $this->getZip(), "phone" => $this->getPhone(), + "first_name" => $this->getFirstName(), + "last_name" => $this->getLastName(), + "email" => $this->getEmail(), ); } diff --git a/src/CardUpdateRequest.php b/src/CardUpdateRequest.php index 427f466..31a279b 100755 --- a/src/CardUpdateRequest.php +++ b/src/CardUpdateRequest.php @@ -17,19 +17,7 @@ class CardUpdateRequest implements \JsonSerializable protected $client; /** - * Card update type. Possible values: "new-cvc2" or "other" - * @var string - */ - protected $updateType; - - /** - * Card update reason. - * @var string - */ - protected $updateReason; - - /** - * Customer preferred scheme, such as carte bancaire vs visa + * Customer preferred scheme, such as carte bancaire vs visa. Can be set to none to clear the previous value * @var string */ protected $preferredScheme; @@ -47,53 +35,9 @@ public function __construct(ProcessOut $client, $prefill = array()) } - /** - * Get UpdateType - * Card update type. Possible values: "new-cvc2" or "other" - * @return string - */ - public function getUpdateType() - { - return $this->updateType; - } - - /** - * Set UpdateType - * Card update type. Possible values: "new-cvc2" or "other" - * @param string $value - * @return $this - */ - public function setUpdateType($value) - { - $this->updateType = $value; - return $this; - } - - /** - * Get UpdateReason - * Card update reason. - * @return string - */ - public function getUpdateReason() - { - return $this->updateReason; - } - - /** - * Set UpdateReason - * Card update reason. - * @param string $value - * @return $this - */ - public function setUpdateReason($value) - { - $this->updateReason = $value; - return $this; - } - /** * Get PreferredScheme - * Customer preferred scheme, such as carte bancaire vs visa + * Customer preferred scheme, such as carte bancaire vs visa. Can be set to none to clear the previous value * @return string */ public function getPreferredScheme() @@ -103,7 +47,7 @@ public function getPreferredScheme() /** * Set PreferredScheme - * Customer preferred scheme, such as carte bancaire vs visa + * Customer preferred scheme, such as carte bancaire vs visa. Can be set to none to clear the previous value * @param string $value * @return $this */ @@ -121,12 +65,6 @@ public function setPreferredScheme($value) */ public function fillWithData($data) { - if(! empty($data['update_type'])) - $this->setUpdateType($data['update_type']); - - if(! empty($data['update_reason'])) - $this->setUpdateReason($data['update_reason']); - if(! empty($data['preferred_scheme'])) $this->setPreferredScheme($data['preferred_scheme']); @@ -139,8 +77,6 @@ public function fillWithData($data) */ public function jsonSerialize() { return array( - "update_type" => $this->getUpdateType(), - "update_reason" => $this->getUpdateReason(), "preferred_scheme" => $this->getPreferredScheme(), ); } @@ -160,8 +96,6 @@ public function update($cardId, $options = array()) $path = "/cards/" . urlencode($cardId) . ""; $data = array( - "update_type" => $this->getUpdateType(), - "update_reason" => $this->getUpdateReason(), "preferred_scheme" => $this->getPreferredScheme() ); diff --git a/src/Invoice.php b/src/Invoice.php index 593101a..d9ed6f5 100755 --- a/src/Invoice.php +++ b/src/Invoice.php @@ -94,6 +94,12 @@ class Invoice implements \JsonSerializable */ protected $url; + /** + * base64-encoded QR code for the invoice URL + * @var string + */ + protected $urlQrcode; + /** * Name of the invoice * @var string @@ -202,6 +208,12 @@ class Invoice implements \JsonSerializable */ protected $createdAt; + /** + * Date at which the invoice will expire + * @var string + */ + protected $expiresAt; + /** * Risk information * @var object @@ -650,6 +662,28 @@ public function setUrl($value) return $this; } + /** + * Get UrlQrcode + * base64-encoded QR code for the invoice URL + * @return string + */ + public function getUrlQrcode() + { + return $this->urlQrcode; + } + + /** + * Set UrlQrcode + * base64-encoded QR code for the invoice URL + * @param string $value + * @return $this + */ + public function setUrlQrcode($value) + { + $this->urlQrcode = $value; + return $this; + } + /** * Get Name * Name of the invoice @@ -1046,6 +1080,28 @@ public function setCreatedAt($value) return $this; } + /** + * Get ExpiresAt + * Date at which the invoice will expire + * @return string + */ + public function getExpiresAt() + { + return $this->expiresAt; + } + + /** + * Set ExpiresAt + * Date at which the invoice will expire + * @param string $value + * @return $this + */ + public function setExpiresAt($value) + { + $this->expiresAt = $value; + return $this; + } + /** * Get Risk * Risk information @@ -1523,6 +1579,9 @@ public function fillWithData($data) if(! empty($data['url'])) $this->setUrl($data['url']); + if(! empty($data['url_qrcode'])) + $this->setUrlQrcode($data['url_qrcode']); + if(! empty($data['name'])) $this->setName($data['name']); @@ -1577,6 +1636,9 @@ public function fillWithData($data) if(! empty($data['created_at'])) $this->setCreatedAt($data['created_at']); + if(! empty($data['expires_at'])) + $this->setExpiresAt($data['expires_at']); + if(! empty($data['risk'])) $this->setRisk($data['risk']); @@ -1650,6 +1712,7 @@ public function jsonSerialize() { "token_id" => $this->getTokenId(), "details" => $this->getDetails(), "url" => $this->getUrl(), + "url_qrcode" => $this->getUrlQrcode(), "name" => $this->getName(), "order_id" => $this->getOrderId(), "amount" => $this->getAmount(), @@ -1668,6 +1731,7 @@ public function jsonSerialize() { "require_backend_capture" => $this->getRequireBackendCapture(), "sandbox" => $this->getSandbox(), "created_at" => $this->getCreatedAt(), + "expires_at" => $this->getExpiresAt(), "risk" => $this->getRisk(), "shipping" => $this->getShipping(), "device" => $this->getDevice(), @@ -1725,7 +1789,7 @@ public function incrementAuthorization($amount, $options = array()) * Authorize the invoice using the given source (customer or token) * @param string $source * @param array $options - * @return Transaction + * @return array */ public function authorize($source, $options = array()) { @@ -1758,15 +1822,21 @@ public function authorize($source, $options = array()) $transaction = new Transaction($this->client); $returnValues['transaction'] = $transaction->fillWithData($body); + // Handling for field customer_action + $body = $response->getBody(); + $body = $body['customer_action']; + $customerAction = new CustomerAction($this->client); + $returnValues['customerAction'] = $customerAction->fillWithData($body); + - return array_values($returnValues)[0]; + return (object) $returnValues; } /** * Capture the invoice using the given source (customer or token) * @param string $source * @param array $options - * @return Transaction + * @return array */ public function capture($source, $options = array()) { @@ -1800,8 +1870,14 @@ public function capture($source, $options = array()) $transaction = new Transaction($this->client); $returnValues['transaction'] = $transaction->fillWithData($body); + // Handling for field customer_action + $body = $response->getBody(); + $body = $body['customer_action']; + $customerAction = new CustomerAction($this->client); + $returnValues['customerAction'] = $customerAction->fillWithData($body); + - return array_values($returnValues)[0]; + return (object) $returnValues; } /** @@ -1935,7 +2011,7 @@ public function showNativePaymentTransaction($invoiceId, $gatewayConfigurationId * Process the Native APM payment flow * @param string $invoiceId * @param array $options - * @return InvoicesProcessNativePaymentResponse + * @return array */ public function processNativePayment($invoiceId, $options = array()) { @@ -1953,13 +2029,20 @@ public function processNativePayment($invoiceId, $options = array()) $returnValues = array(); - // Handling for field + // Handling for field transaction $body = $response->getBody(); - $invoicesProcessNativePaymentResponse = new InvoicesProcessNativePaymentResponse($this->client); - $returnValues['invoicesProcessNativePaymentResponse'] = $invoicesProcessNativePaymentResponse->fillWithData($body); + $body = $body['transaction']; + $transaction = new Transaction($this->client); + $returnValues['transaction'] = $transaction->fillWithData($body); + + // Handling for field native_apm + $body = $response->getBody(); + $body = $body['native_apm']; + $nativeAPMResponse = new NativeAPMResponse($this->client); + $returnValues['nativeAPMResponse'] = $nativeAPMResponse->fillWithData($body); - return array_values($returnValues)[0]; + return (object) $returnValues; } /** @@ -2134,7 +2217,8 @@ public function create($options = array()) "billing" => $this->getBilling(), "unsupported_feature_bypass" => $this->getUnsupportedFeatureBypass(), "verification" => $this->getVerification(), - "auto_capture_at" => $this->getAutoCaptureAt() + "auto_capture_at" => $this->getAutoCaptureAt(), + "expires_at" => $this->getExpiresAt() ); $response = $request->post($path, $data, $options); @@ -2178,4 +2262,29 @@ public function find($invoiceId, $options = array()) return array_values($returnValues)[0]; } + /** + * Delete an invoice by its ID. Only invoices that have not been used yet can be deleted. + * @param string $invoiceId + * @param array $options + * @return bool + */ + public function delete($invoiceId, $options = array()) + { + $this->fillWithData($options); + + $request = new Request($this->client); + $path = "/invoices/" . urlencode($invoiceId) . ""; + + $data = array( + + ); + + $response = $request->delete($path, $data, $options); + $returnValues = array(); + + $returnValues['success'] = $response->isSuccess(); + + return array_values($returnValues)[0]; + } + } diff --git a/src/InvoiceExternalFraudTools.php b/src/InvoiceExternalFraudTools.php index 04559e1..f14bd80 100755 --- a/src/InvoiceExternalFraudTools.php +++ b/src/InvoiceExternalFraudTools.php @@ -18,19 +18,19 @@ class InvoiceExternalFraudTools implements \JsonSerializable /** * Forter - * @var string + * @var object */ protected $forter; /** * Ravelin - * @var string + * @var object */ protected $ravelin; /** * Signifyd - * @var string + * @var object */ protected $signifyd; @@ -50,7 +50,7 @@ public function __construct(ProcessOut $client, $prefill = array()) /** * Get Forter * Forter - * @return string + * @return object */ public function getForter() { @@ -60,7 +60,7 @@ public function getForter() /** * Set Forter * Forter - * @param string $value + * @param object $value * @return $this */ public function setForter($value) @@ -72,7 +72,7 @@ public function setForter($value) /** * Get Ravelin * Ravelin - * @return string + * @return object */ public function getRavelin() { @@ -82,7 +82,7 @@ public function getRavelin() /** * Set Ravelin * Ravelin - * @param string $value + * @param object $value * @return $this */ public function setRavelin($value) @@ -94,7 +94,7 @@ public function setRavelin($value) /** * Get Signifyd * Signifyd - * @return string + * @return object */ public function getSignifyd() { @@ -104,7 +104,7 @@ public function getSignifyd() /** * Set Signifyd * Signifyd - * @param string $value + * @param object $value * @return $this */ public function setSignifyd($value) diff --git a/src/InvoiceShipping.php b/src/InvoiceShipping.php index 54a4347..9bf65f7 100755 --- a/src/InvoiceShipping.php +++ b/src/InvoiceShipping.php @@ -100,6 +100,24 @@ class InvoiceShipping implements \JsonSerializable */ protected $relayStoreName; + /** + * First name for the shipment + * @var string + */ + protected $firstName; + + /** + * Last name for the shipment + * @var string + */ + protected $lastName; + + /** + * Email for the shipment + * @var string + */ + protected $email; + /** * InvoiceShipping constructor * @param ProcessOut\ProcessOut $client @@ -428,6 +446,72 @@ public function setRelayStoreName($value) return $this; } + /** + * Get FirstName + * First name for the shipment + * @return string + */ + public function getFirstName() + { + return $this->firstName; + } + + /** + * Set FirstName + * First name for the shipment + * @param string $value + * @return $this + */ + public function setFirstName($value) + { + $this->firstName = $value; + return $this; + } + + /** + * Get LastName + * Last name for the shipment + * @return string + */ + public function getLastName() + { + return $this->lastName; + } + + /** + * Set LastName + * Last name for the shipment + * @param string $value + * @return $this + */ + public function setLastName($value) + { + $this->lastName = $value; + return $this; + } + + /** + * Get Email + * Email for the shipment + * @return string + */ + public function getEmail() + { + return $this->email; + } + + /** + * Set Email + * Email for the shipment + * @param string $value + * @return $this + */ + public function setEmail($value) + { + $this->email = $value; + return $this; + } + /** * Fills the current object with the new values pulled from the data @@ -478,6 +562,15 @@ public function fillWithData($data) if(! empty($data['relay_store_name'])) $this->setRelayStoreName($data['relay_store_name']); + if(! empty($data['first_name'])) + $this->setFirstName($data['first_name']); + + if(! empty($data['last_name'])) + $this->setLastName($data['last_name']); + + if(! empty($data['email'])) + $this->setEmail($data['email']); + return $this; } @@ -501,6 +594,9 @@ public function jsonSerialize() { "phone" => $this->getPhone(), "expects_shipping_at" => $this->getExpectsShippingAt(), "relay_store_name" => $this->getRelayStoreName(), + "first_name" => $this->getFirstName(), + "last_name" => $this->getLastName(), + "email" => $this->getEmail(), ); } diff --git a/src/InvoicesProcessNativePaymentResponse.php b/src/InvoicesProcessNativePaymentResponse.php deleted file mode 100755 index 42a8287..0000000 --- a/src/InvoicesProcessNativePaymentResponse.php +++ /dev/null @@ -1,131 +0,0 @@ -client = $client; - - $this->fillWithData($prefill); - } - - - /** - * Get Transaction - * Transaction linked to this Native APM - * @return object - */ - public function getTransaction() - { - return $this->transaction; - } - - /** - * Set Transaction - * Transaction linked to this Native APM - * @param object $value - * @return $this - */ - public function setTransaction($value) - { - if (is_object($value)) - $this->transaction = $value; - else - { - $obj = new Transaction($this->client); - $obj->fillWithData($value); - $this->transaction = $obj; - } - return $this; - } - - /** - * Get NativeApm - * Native APM response - * @return object - */ - public function getNativeApm() - { - return $this->nativeApm; - } - - /** - * Set NativeApm - * Native APM response - * @param object $value - * @return $this - */ - public function setNativeApm($value) - { - if (is_object($value)) - $this->nativeApm = $value; - else - { - $obj = new NativeAPMResponse($this->client); - $obj->fillWithData($value); - $this->nativeApm = $obj; - } - return $this; - } - - - /** - * Fills the current object with the new values pulled from the data - * @param array $data - * @return InvoicesProcessNativePaymentResponse - */ - public function fillWithData($data) - { - if(! empty($data['transaction'])) - $this->setTransaction($data['transaction']); - - if(! empty($data['native_apm'])) - $this->setNativeApm($data['native_apm']); - - return $this; - } - - /** - * Implements the JsonSerializable interface - * @return object - */ - public function jsonSerialize() { - return array( - "transaction" => $this->getTransaction(), - "native_apm" => $this->getNativeApm(), - ); - } - - -} diff --git a/src/Networking/Request.php b/src/Networking/Request.php index 21820f0..bfc4b32 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/6.33.0' + 'User-Agent: ProcessOut PHP-Bindings/7.0.0' ); if (! empty($options['idempotencyKey'])) $headers[] = 'Idempotency-Key: ' . $options['idempotencyKey']; diff --git a/src/ProcessOut.php b/src/ProcessOut.php index 40d4d13..e3fa468 100644 --- a/src/ProcessOut.php +++ b/src/ProcessOut.php @@ -640,13 +640,4 @@ public function newNativeAPMTransactionDetails($prefill = array()) { return new NativeAPMTransactionDetails($this, $prefill); } - /** - * Create a new InvoicesProcessNativePaymentResponse instance - * @param array|null $prefill array used to prefill the object - * @return InvoicesProcessNativePaymentResponse - */ - public function newInvoicesProcessNativePaymentResponse($prefill = array()) { - return new InvoicesProcessNativePaymentResponse($this, $prefill); - } - } diff --git a/src/Project.php b/src/Project.php index 19384c4..ee5cc31 100755 --- a/src/Project.php +++ b/src/Project.php @@ -559,7 +559,8 @@ public function createSupervised($options = array()) "name" => $this->getName(), "default_currency" => $this->getDefaultCurrency(), "dunning_configuration" => $this->getDunningConfiguration(), - "applepay_settings" => (!empty($options["applepay_settings"])) ? $options["applepay_settings"] : null + "applepay_settings" => (!empty($options["applepay_settings"])) ? $options["applepay_settings"] : null, + "public_metadata" => (!empty($options["public_metadata"])) ? $options["public_metadata"] : null ); $response = $request->post($path, $data, $options); diff --git a/src/Token.php b/src/Token.php index a8c48fb..6718499 100755 --- a/src/Token.php +++ b/src/Token.php @@ -873,7 +873,8 @@ public function create($options = array()) "verify_metadata" => (!empty($options["verify_metadata"])) ? $options["verify_metadata"] : null, "set_default" => (!empty($options["set_default"])) ? $options["set_default"] : null, "verify_statement_descriptor" => (!empty($options["verify_statement_descriptor"])) ? $options["verify_statement_descriptor"] : null, - "invoice_return_url" => (!empty($options["invoice_return_url"])) ? $options["invoice_return_url"] : null + "invoice_return_url" => (!empty($options["invoice_return_url"])) ? $options["invoice_return_url"] : null, + "summary" => (!empty($options["summary"])) ? $options["summary"] : null ); $response = $request->post($path, $data, $options); diff --git a/src/Transaction.php b/src/Transaction.php index 426d7f7..ee9c9d4 100755 --- a/src/Transaction.php +++ b/src/Transaction.php @@ -2387,6 +2387,40 @@ public function all($options = array()) return array_values($returnValues)[0]; } + /** + * Get full transactions data for specified list of ids. + * @param array $options + * @return array + */ + public function list($options = array()) + { + $this->fillWithData($options); + + $request = new Request($this->client); + $path = "/transactions"; + + $data = array( + + ); + + $response = $request->post($path, $data, $options); + $returnValues = array(); + + + // Handling for field transactions + $a = array(); + $body = $response->getBody(); + foreach($body['transactions'] as $v) + { + $tmp = new Transaction($this->client); + $tmp->fillWithData($v); + $a[] = $tmp; + } + $returnValues['Transactions'] = $a; + + return array_values($returnValues)[0]; + } + /** * Find a transaction by its ID. * @param string $transactionId