From 748a485813662265836d3cbaa81202f54ba55684 Mon Sep 17 00:00:00 2001 From: ProcessOut Fountain Date: Thu, 29 May 2025 14:04:56 +0200 Subject: [PATCH] feat: add customer and invoice reference_id; add balances customer action --- README.md | 2 +- init.php | 3 +- src/Activity.php | 6 +- src/Addon.php | 18 +- src/AlternativeMerchantCertificate.php | 8 +- ...pplePayAlternativeMerchantCertificates.php | 8 +- src/Balances.php | 86 ++++++++- src/BalancesCustomerAction.php | 117 ++++++++++++ src/Card.php | 6 +- src/CardCreateRequest.php | 6 +- src/CardInformation.php | 6 +- src/CardUpdateRequest.php | 6 +- src/Coupon.php | 18 +- src/Customer.php | 59 +++++- src/Discount.php | 12 +- src/Event.php | 6 +- src/ExportLayout.php | 24 ++- src/ExportLayoutConfigurationOptions.php | 6 +- src/GatewayConfiguration.php | 18 +- src/Invoice.php | 169 ++++++++++++------ src/Networking/Request.php | 2 +- src/Payout.php | 6 +- src/Plan.php | 18 +- src/ProcessOut.php | 27 ++- src/Product.php | 26 ++- src/Project.php | 18 +- src/ProjectSFTPSettingsPublic.php | 6 +- src/Refund.php | 6 +- src/Subscription.php | 48 +++-- src/Token.php | 24 ++- src/Transaction.php | 14 +- 31 files changed, 598 insertions(+), 181 deletions(-) create mode 100755 src/BalancesCustomerAction.php diff --git a/README.md b/README.md index 7b76760..f1334a5 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.3.0" + "processout/processout-php": "^7.4.0" } } ``` diff --git a/init.php b/init.php index eb0fb36..0a527de 100644 --- a/init.php +++ b/init.php @@ -19,6 +19,7 @@ include_once(dirname(__FILE__) . "/src/AlternativeMerchantCertificate.php"); include_once(dirname(__FILE__) . "/src/Balances.php"); include_once(dirname(__FILE__) . "/src/Balance.php"); +include_once(dirname(__FILE__) . "/src/BalancesCustomerAction.php"); include_once(dirname(__FILE__) . "/src/Card.php"); include_once(dirname(__FILE__) . "/src/CardInformation.php"); include_once(dirname(__FILE__) . "/src/Phone.php"); @@ -76,11 +77,11 @@ include_once(dirname(__FILE__) . "/src/TransactionOperation.php"); include_once(dirname(__FILE__) . "/src/Webhook.php"); include_once(dirname(__FILE__) . "/src/WebhookEndpoint.php"); -include_once(dirname(__FILE__) . "/src/CardCreateRequest.php"); include_once(dirname(__FILE__) . "/src/Device.php"); include_once(dirname(__FILE__) . "/src/CardContact.php"); include_once(dirname(__FILE__) . "/src/CardShipping.php"); include_once(dirname(__FILE__) . "/src/CardUpdateRequest.php"); +include_once(dirname(__FILE__) . "/src/CardCreateRequest.php"); include_once(dirname(__FILE__) . "/src/ErrorCodes.php"); include_once(dirname(__FILE__) . "/src/CategoryErrorCodes.php"); include_once(dirname(__FILE__) . "/src/ExternalThreeDS.php"); diff --git a/src/Activity.php b/src/Activity.php index 84f74da..20722a9 100755 --- a/src/Activity.php +++ b/src/Activity.php @@ -338,8 +338,10 @@ public function find($activityId, $options = array()) // Handling for field activity $body = $response->getBody(); - $body = $body['activity']; - $returnValues['find'] = $this->fillWithData($body); + if (isset($body['activity'])) { + $body = $body['activity']; + $returnValues['find'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } diff --git a/src/Addon.php b/src/Addon.php index de77963..20ff4d0 100755 --- a/src/Addon.php +++ b/src/Addon.php @@ -584,8 +584,10 @@ public function create($options = array()) // Handling for field addon $body = $response->getBody(); - $body = $body['addon']; - $returnValues['create'] = $this->fillWithData($body); + if (isset($body['addon'])) { + $body = $body['addon']; + $returnValues['create'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } @@ -614,8 +616,10 @@ public function find($subscriptionId, $addonId, $options = array()) // Handling for field addon $body = $response->getBody(); - $body = $body['addon']; - $returnValues['find'] = $this->fillWithData($body); + if (isset($body['addon'])) { + $body = $body['addon']; + $returnValues['find'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } @@ -651,8 +655,10 @@ public function save($options = array()) // Handling for field addon $body = $response->getBody(); - $body = $body['addon']; - $returnValues['save'] = $this->fillWithData($body); + if (isset($body['addon'])) { + $body = $body['addon']; + $returnValues['save'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } diff --git a/src/AlternativeMerchantCertificate.php b/src/AlternativeMerchantCertificate.php index 2907a23..69daef9 100755 --- a/src/AlternativeMerchantCertificate.php +++ b/src/AlternativeMerchantCertificate.php @@ -104,9 +104,11 @@ public function save($options = array()) // Handling for field alternative_merchant_certificate $body = $response->getBody(); - $body = $body['alternative_merchant_certificate']; - $alternativeMerchantCertificate = new AlternativeMerchantCertificate($this->client); - $returnValues['alternativeMerchantCertificate'] = $alternativeMerchantCertificate->fillWithData($body); + if (isset($body['alternative_merchant_certificate'])) { + $body = $body['alternative_merchant_certificate']; + $alternativeMerchantCertificate = new AlternativeMerchantCertificate($this->client); + $returnValues['alternativeMerchantCertificate'] = $alternativeMerchantCertificate->fillWithData($body); + } return array_values($returnValues)[0]; diff --git a/src/ApplePayAlternativeMerchantCertificates.php b/src/ApplePayAlternativeMerchantCertificates.php index e5fe68e..e593dd7 100755 --- a/src/ApplePayAlternativeMerchantCertificates.php +++ b/src/ApplePayAlternativeMerchantCertificates.php @@ -148,9 +148,11 @@ public function fetch($options = array()) // Handling for field applepay_certificates $body = $response->getBody(); - $body = $body['applepay_certificates']; - $applePayAlternativeMerchantCertificates = new ApplePayAlternativeMerchantCertificates($this->client); - $returnValues['applePayAlternativeMerchantCertificates'] = $applePayAlternativeMerchantCertificates->fillWithData($body); + if (isset($body['applepay_certificates'])) { + $body = $body['applepay_certificates']; + $applePayAlternativeMerchantCertificates = new ApplePayAlternativeMerchantCertificates($this->client); + $returnValues['applePayAlternativeMerchantCertificates'] = $applePayAlternativeMerchantCertificates->fillWithData($body); + } return array_values($returnValues)[0]; diff --git a/src/Balances.php b/src/Balances.php index 84ea30c..26f7a8f 100755 --- a/src/Balances.php +++ b/src/Balances.php @@ -22,6 +22,18 @@ class Balances implements \JsonSerializable */ protected $vouchers; + /** + * Available balance of the customer + * @var object + */ + protected $availableBalance; + + /** + * Customer action to be performed, such as redirecting to a URL + * @var object + */ + protected $customerAction; + /** * Balances constructor * @param ProcessOut\ProcessOut $client @@ -69,6 +81,64 @@ public function setVouchers($value) return $this; } + /** + * Get AvailableBalance + * Available balance of the customer + * @return object + */ + public function getAvailableBalance() + { + return $this->availableBalance; + } + + /** + * Set AvailableBalance + * Available balance of the customer + * @param object $value + * @return $this + */ + public function setAvailableBalance($value) + { + if (is_object($value)) + $this->availableBalance = $value; + else + { + $obj = new Balance($this->client); + $obj->fillWithData($value); + $this->availableBalance = $obj; + } + return $this; + } + + /** + * Get CustomerAction + * Customer action to be performed, such as redirecting to a URL + * @return object + */ + public function getCustomerAction() + { + return $this->customerAction; + } + + /** + * Set CustomerAction + * Customer action to be performed, such as redirecting to a URL + * @param object $value + * @return $this + */ + public function setCustomerAction($value) + { + if (is_object($value)) + $this->customerAction = $value; + else + { + $obj = new BalancesCustomerAction($this->client); + $obj->fillWithData($value); + $this->customerAction = $obj; + } + return $this; + } + /** * Fills the current object with the new values pulled from the data @@ -80,6 +150,12 @@ public function fillWithData($data) if(! empty($data['vouchers'])) $this->setVouchers($data['vouchers']); + if(! empty($data['available_balance'])) + $this->setAvailableBalance($data['available_balance']); + + if(! empty($data['customer_action'])) + $this->setCustomerAction($data['customer_action']); + return $this; } @@ -90,6 +166,8 @@ public function fillWithData($data) public function jsonSerialize() { return array( "vouchers" => $this->getVouchers(), + "available_balance" => $this->getAvailableBalance(), + "customer_action" => $this->getCustomerAction(), ); } @@ -117,9 +195,11 @@ public function find($tokenId, $options = array()) // Handling for field balances $body = $response->getBody(); - $body = $body['balances']; - $balances = new Balances($this->client); - $returnValues['balances'] = $balances->fillWithData($body); + if (isset($body['balances'])) { + $body = $body['balances']; + $balances = new Balances($this->client); + $returnValues['balances'] = $balances->fillWithData($body); + } return array_values($returnValues)[0]; diff --git a/src/BalancesCustomerAction.php b/src/BalancesCustomerAction.php new file mode 100755 index 0000000..d160970 --- /dev/null +++ b/src/BalancesCustomerAction.php @@ -0,0 +1,117 @@ +client = $client; + + $this->fillWithData($prefill); + } + + + /** + * Get Type + * Customer action type (such as url) + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * Set Type + * Customer action type (such as url) + * @param string $value + * @return $this + */ + public function setType($value) + { + $this->type = $value; + return $this; + } + + /** + * Get Value + * Value of the customer action. If type is an URL, URL to which you should redirect your customer + * @return string + */ + public function getValue() + { + return $this->value; + } + + /** + * Set Value + * Value of the customer action. If type is an URL, URL to which you should redirect your customer + * @param string $value + * @return $this + */ + public function setValue($value) + { + $this->value = $value; + return $this; + } + + + /** + * Fills the current object with the new values pulled from the data + * @param array $data + * @return BalancesCustomerAction + */ + public function fillWithData($data) + { + if(! empty($data['type'])) + $this->setType($data['type']); + + if(! empty($data['value'])) + $this->setValue($data['value']); + + return $this; + } + + /** + * Implements the JsonSerializable interface + * @return object + */ + public function jsonSerialize() { + return array( + "type" => $this->getType(), + "value" => $this->getValue(), + ); + } + + +} diff --git a/src/Card.php b/src/Card.php index 11ac868..8a7419b 100755 --- a/src/Card.php +++ b/src/Card.php @@ -1177,8 +1177,10 @@ public function find($cardId, $options = array()) // Handling for field card $body = $response->getBody(); - $body = $body['card']; - $returnValues['find'] = $this->fillWithData($body); + if (isset($body['card'])) { + $body = $body['card']; + $returnValues['find'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } diff --git a/src/CardCreateRequest.php b/src/CardCreateRequest.php index dedde4c..7b02917 100755 --- a/src/CardCreateRequest.php +++ b/src/CardCreateRequest.php @@ -653,8 +653,10 @@ public function create($options = array()) // Handling for field card $body = $response->getBody(); - $body = $body['card']; - $returnValues['create'] = $this->fillWithData($body); + if (isset($body['card'])) { + $body = $body['card']; + $returnValues['create'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } diff --git a/src/CardInformation.php b/src/CardInformation.php index dc4bcdd..7c0175b 100755 --- a/src/CardInformation.php +++ b/src/CardInformation.php @@ -297,8 +297,10 @@ public function fetch($iin, $options = array()) // Handling for field card_information $body = $response->getBody(); - $body = $body['card_information']; - $returnValues['fetch'] = $this->fillWithData($body); + if (isset($body['card_information'])) { + $body = $body['card_information']; + $returnValues['fetch'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } diff --git a/src/CardUpdateRequest.php b/src/CardUpdateRequest.php index 31a279b..442abfd 100755 --- a/src/CardUpdateRequest.php +++ b/src/CardUpdateRequest.php @@ -105,8 +105,10 @@ public function update($cardId, $options = array()) // Handling for field card $body = $response->getBody(); - $body = $body['card']; - $returnValues['update'] = $this->fillWithData($body); + if (isset($body['card'])) { + $body = $body['card']; + $returnValues['update'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } diff --git a/src/Coupon.php b/src/Coupon.php index 6a992a1..eb811fa 100755 --- a/src/Coupon.php +++ b/src/Coupon.php @@ -536,8 +536,10 @@ public function create($options = array()) // Handling for field coupon $body = $response->getBody(); - $body = $body['coupon']; - $returnValues['create'] = $this->fillWithData($body); + if (isset($body['coupon'])) { + $body = $body['coupon']; + $returnValues['create'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } @@ -565,8 +567,10 @@ public function find($couponId, $options = array()) // Handling for field coupon $body = $response->getBody(); - $body = $body['coupon']; - $returnValues['find'] = $this->fillWithData($body); + if (isset($body['coupon'])) { + $body = $body['coupon']; + $returnValues['find'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } @@ -593,8 +597,10 @@ public function save($options = array()) // Handling for field coupon $body = $response->getBody(); - $body = $body['coupon']; - $returnValues['save'] = $this->fillWithData($body); + if (isset($body['coupon'])) { + $body = $body['coupon']; + $returnValues['save'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } diff --git a/src/Customer.php b/src/Customer.php index 7a9f8d0..118b20c 100755 --- a/src/Customer.php +++ b/src/Customer.php @@ -202,6 +202,12 @@ class Customer implements \JsonSerializable */ protected $dateOfBirth; + /** + * Merchant reference ID, custom ID for this Customer provided by the API caller. At most 80 characters. Allowed only 1-byte ASCII characters from range 33 (inclusive) to 126 (inclusive) - non-whitespace, non-DEL characters. + * @var string + */ + protected $referenceId; + /** * Customer constructor * @param ProcessOut\ProcessOut $client @@ -954,6 +960,28 @@ public function setDateOfBirth($value) return $this; } + /** + * Get ReferenceId + * Merchant reference ID, custom ID for this Customer provided by the API caller. At most 80 characters. Allowed only 1-byte ASCII characters from range 33 (inclusive) to 126 (inclusive) - non-whitespace, non-DEL characters. + * @return string + */ + public function getReferenceId() + { + return $this->referenceId; + } + + /** + * Set ReferenceId + * Merchant reference ID, custom ID for this Customer provided by the API caller. At most 80 characters. Allowed only 1-byte ASCII characters from range 33 (inclusive) to 126 (inclusive) - non-whitespace, non-DEL characters. + * @param string $value + * @return $this + */ + public function setReferenceId($value) + { + $this->referenceId = $value; + return $this; + } + /** * Fills the current object with the new values pulled from the data @@ -1055,6 +1083,9 @@ public function fillWithData($data) if(! empty($data['date_of_birth'])) $this->setDateOfBirth($data['date_of_birth']); + if(! empty($data['reference_id'])) + $this->setReferenceId($data['reference_id']); + return $this; } @@ -1095,6 +1126,7 @@ public function jsonSerialize() { "created_at" => $this->getCreatedAt(), "registered_at" => $this->getRegisteredAt(), "date_of_birth" => $this->getDateOfBirth(), + "reference_id" => $this->getReferenceId(), ); } @@ -1190,9 +1222,11 @@ public function findToken($tokenId, $options = array()) // Handling for field token $body = $response->getBody(); - $body = $body['token']; - $token = new Token($this->client); - $returnValues['token'] = $token->fillWithData($body); + if (isset($body['token'])) { + $body = $body['token']; + $token = new Token($this->client); + $returnValues['token'] = $token->fillWithData($body); + } return array_values($returnValues)[0]; @@ -1324,6 +1358,7 @@ public function create($options = array()) "sex" => $this->getSex(), "metadata" => $this->getMetadata(), "id" => $this->getId(), + "reference_id" => $this->getReferenceId(), "registered_at" => $this->getRegisteredAt(), "phone_number" => $this->getPhoneNumber() ); @@ -1334,8 +1369,10 @@ public function create($options = array()) // Handling for field customer $body = $response->getBody(); - $body = $body['customer']; - $returnValues['create'] = $this->fillWithData($body); + if (isset($body['customer'])) { + $body = $body['customer']; + $returnValues['create'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } @@ -1363,8 +1400,10 @@ public function find($customerId, $options = array()) // Handling for field customer $body = $response->getBody(); - $body = $body['customer']; - $returnValues['find'] = $this->fillWithData($body); + if (isset($body['customer'])) { + $body = $body['customer']; + $returnValues['find'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } @@ -1411,8 +1450,10 @@ public function save($options = array()) // Handling for field customer $body = $response->getBody(); - $body = $body['customer']; - $returnValues['save'] = $this->fillWithData($body); + if (isset($body['customer'])) { + $body = $body['customer']; + $returnValues['save'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } diff --git a/src/Discount.php b/src/Discount.php index 410e0e9..fcf88a6 100755 --- a/src/Discount.php +++ b/src/Discount.php @@ -580,8 +580,10 @@ public function create($options = array()) // Handling for field discount $body = $response->getBody(); - $body = $body['discount']; - $returnValues['create'] = $this->fillWithData($body); + if (isset($body['discount'])) { + $body = $body['discount']; + $returnValues['create'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } @@ -610,8 +612,10 @@ public function find($subscriptionId, $discountId, $options = array()) // Handling for field discount $body = $response->getBody(); - $body = $body['discount']; - $returnValues['find'] = $this->fillWithData($body); + if (isset($body['discount'])) { + $body = $body['discount']; + $returnValues['find'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } diff --git a/src/Event.php b/src/Event.php index 6cc3be1..4edfa87 100755 --- a/src/Event.php +++ b/src/Event.php @@ -372,8 +372,10 @@ public function find($eventId, $options = array()) // Handling for field event $body = $response->getBody(); - $body = $body['event']; - $returnValues['find'] = $this->fillWithData($body); + if (isset($body['event'])) { + $body = $body['event']; + $returnValues['find'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } diff --git a/src/ExportLayout.php b/src/ExportLayout.php index 658b626..4b96eaa 100755 --- a/src/ExportLayout.php +++ b/src/ExportLayout.php @@ -377,8 +377,10 @@ public function find($exportLayoutId, $options = array()) // Handling for field export_layout $body = $response->getBody(); - $body = $body['export_layout']; - $returnValues['find'] = $this->fillWithData($body); + if (isset($body['export_layout'])) { + $body = $body['export_layout']; + $returnValues['find'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } @@ -406,8 +408,10 @@ public function findDefault($exportType, $options = array()) // Handling for field export_layout $body = $response->getBody(); - $body = $body['export_layout']; - $returnValues['findDefault'] = $this->fillWithData($body); + if (isset($body['export_layout'])) { + $body = $body['export_layout']; + $returnValues['findDefault'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } @@ -437,8 +441,10 @@ public function create($options = array()) // Handling for field export_layout $body = $response->getBody(); - $body = $body['export_layout']; - $returnValues['create'] = $this->fillWithData($body); + if (isset($body['export_layout'])) { + $body = $body['export_layout']; + $returnValues['create'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } @@ -468,8 +474,10 @@ public function update($exportLayoutId, $options = array()) // Handling for field export_layout $body = $response->getBody(); - $body = $body['export_layout']; - $returnValues['update'] = $this->fillWithData($body); + if (isset($body['export_layout'])) { + $body = $body['export_layout']; + $returnValues['update'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } diff --git a/src/ExportLayoutConfigurationOptions.php b/src/ExportLayoutConfigurationOptions.php index d7a75c3..c91543f 100755 --- a/src/ExportLayoutConfigurationOptions.php +++ b/src/ExportLayoutConfigurationOptions.php @@ -183,8 +183,10 @@ public function fetch($exportType, $options = array()) // Handling for field export_layout_configuration_options $body = $response->getBody(); - $body = $body['export_layout_configuration_options']; - $returnValues['fetch'] = $this->fillWithData($body); + if (isset($body['export_layout_configuration_options'])) { + $body = $body['export_layout_configuration_options']; + $returnValues['fetch'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } diff --git a/src/GatewayConfiguration.php b/src/GatewayConfiguration.php index e214d6d..44eb692 100755 --- a/src/GatewayConfiguration.php +++ b/src/GatewayConfiguration.php @@ -537,8 +537,10 @@ public function find($configurationId, $options = array()) // Handling for field gateway_configuration $body = $response->getBody(); - $body = $body['gateway_configuration']; - $returnValues['find'] = $this->fillWithData($body); + if (isset($body['gateway_configuration'])) { + $body = $body['gateway_configuration']; + $returnValues['find'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } @@ -572,8 +574,10 @@ public function save($options = array()) // Handling for field gateway_configuration $body = $response->getBody(); - $body = $body['gateway_configuration']; - $returnValues['save'] = $this->fillWithData($body); + if (isset($body['gateway_configuration'])) { + $body = $body['gateway_configuration']; + $returnValues['save'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } @@ -632,8 +636,10 @@ public function create($gatewayName, $options = array()) // Handling for field gateway_configuration $body = $response->getBody(); - $body = $body['gateway_configuration']; - $returnValues['create'] = $this->fillWithData($body); + if (isset($body['gateway_configuration'])) { + $body = $body['gateway_configuration']; + $returnValues['create'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } diff --git a/src/Invoice.php b/src/Invoice.php index 871daed..d73cfd1 100755 --- a/src/Invoice.php +++ b/src/Invoice.php @@ -322,6 +322,12 @@ class Invoice implements \JsonSerializable */ protected $autoCaptureAt; + /** + * Merchant reference ID, custom ID for this Invoice provided by the API caller. At most 80 characters. Allowed only 1-byte ASCII characters from range 33 (inclusive) to 126 (inclusive) - non-whitespace, non-DEL characters. + * @var string + */ + protected $referenceId; + /** * Invoice constructor * @param ProcessOut\ProcessOut $client @@ -1567,6 +1573,28 @@ public function setAutoCaptureAt($value) return $this; } + /** + * Get ReferenceId + * Merchant reference ID, custom ID for this Invoice provided by the API caller. At most 80 characters. Allowed only 1-byte ASCII characters from range 33 (inclusive) to 126 (inclusive) - non-whitespace, non-DEL characters. + * @return string + */ + public function getReferenceId() + { + return $this->referenceId; + } + + /** + * Set ReferenceId + * Merchant reference ID, custom ID for this Invoice provided by the API caller. At most 80 characters. Allowed only 1-byte ASCII characters from range 33 (inclusive) to 126 (inclusive) - non-whitespace, non-DEL characters. + * @param string $value + * @return $this + */ + public function setReferenceId($value) + { + $this->referenceId = $value; + return $this; + } + /** * Fills the current object with the new values pulled from the data @@ -1728,6 +1756,9 @@ public function fillWithData($data) if(! empty($data['auto_capture_at'])) $this->setAutoCaptureAt($data['auto_capture_at']); + if(! empty($data['reference_id'])) + $this->setReferenceId($data['reference_id']); + return $this; } @@ -1788,6 +1819,7 @@ public function jsonSerialize() { "unsupported_feature_bypass" => $this->getUnsupportedFeatureBypass(), "verification" => $this->getVerification(), "auto_capture_at" => $this->getAutoCaptureAt(), + "reference_id" => $this->getReferenceId(), ); } @@ -1816,9 +1848,11 @@ public function incrementAuthorization($amount, $options = array()) // Handling for field transaction $body = $response->getBody(); - $body = $body['transaction']; - $transaction = new Transaction($this->client); - $returnValues['transaction'] = $transaction->fillWithData($body); + if (isset($body['transaction'])) { + $body = $body['transaction']; + $transaction = new Transaction($this->client); + $returnValues['transaction'] = $transaction->fillWithData($body); + } return array_values($returnValues)[0]; @@ -1859,15 +1893,19 @@ public function authorize($source, $options = array()) // Handling for field transaction $body = $response->getBody(); - $body = $body['transaction']; - $transaction = new Transaction($this->client); - $returnValues['transaction'] = $transaction->fillWithData($body); + if (isset($body['transaction'])) { + $body = $body['transaction']; + $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); + if (isset($body['customer_action'])) { + $body = $body['customer_action']; + $customerAction = new CustomerAction($this->client); + $returnValues['customerAction'] = $customerAction->fillWithData($body); + } return (object) $returnValues; @@ -1909,15 +1947,19 @@ public function capture($source, $options = array()) // Handling for field transaction $body = $response->getBody(); - $body = $body['transaction']; - $transaction = new Transaction($this->client); - $returnValues['transaction'] = $transaction->fillWithData($body); + if (isset($body['transaction'])) { + $body = $body['transaction']; + $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); + if (isset($body['customer_action'])) { + $body = $body['customer_action']; + $customerAction = new CustomerAction($this->client); + $returnValues['customerAction'] = $customerAction->fillWithData($body); + } return (object) $returnValues; @@ -1945,9 +1987,11 @@ public function fetchCustomer($options = array()) // Handling for field customer $body = $response->getBody(); - $body = $body['customer']; - $customer = new Customer($this->client); - $returnValues['customer'] = $customer->fillWithData($body); + if (isset($body['customer'])) { + $body = $body['customer']; + $customer = new Customer($this->client); + $returnValues['customer'] = $customer->fillWithData($body); + } return array_values($returnValues)[0]; @@ -1976,9 +2020,11 @@ public function assignCustomer($customerId, $options = array()) // Handling for field customer $body = $response->getBody(); - $body = $body['customer']; - $customer = new Customer($this->client); - $returnValues['customer'] = $customer->fillWithData($body); + if (isset($body['customer'])) { + $body = $body['customer']; + $customer = new Customer($this->client); + $returnValues['customer'] = $customer->fillWithData($body); + } return array_values($returnValues)[0]; @@ -2010,9 +2056,11 @@ public function payout($gatewayConfigurationId, $source, $options = array()) // Handling for field transaction $body = $response->getBody(); - $body = $body['transaction']; - $transaction = new Transaction($this->client); - $returnValues['transaction'] = $transaction->fillWithData($body); + if (isset($body['transaction'])) { + $body = $body['transaction']; + $transaction = new Transaction($this->client); + $returnValues['transaction'] = $transaction->fillWithData($body); + } return array_values($returnValues)[0]; @@ -2042,9 +2090,11 @@ public function showNativePaymentTransaction($invoiceId, $gatewayConfigurationId // Handling for field native_apm $body = $response->getBody(); - $body = $body['native_apm']; - $nativeAPMTransactionDetails = new NativeAPMTransactionDetails($this->client); - $returnValues['nativeAPMTransactionDetails'] = $nativeAPMTransactionDetails->fillWithData($body); + if (isset($body['native_apm'])) { + $body = $body['native_apm']; + $nativeAPMTransactionDetails = new NativeAPMTransactionDetails($this->client); + $returnValues['nativeAPMTransactionDetails'] = $nativeAPMTransactionDetails->fillWithData($body); + } return array_values($returnValues)[0]; @@ -2074,15 +2124,19 @@ public function processNativePayment($invoiceId, $options = array()) // Handling for field transaction $body = $response->getBody(); - $body = $body['transaction']; - $transaction = new Transaction($this->client); - $returnValues['transaction'] = $transaction->fillWithData($body); + if (isset($body['transaction'])) { + $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); + if (isset($body['native_apm'])) { + $body = $body['native_apm']; + $nativeAPMResponse = new NativeAPMResponse($this->client); + $returnValues['nativeAPMResponse'] = $nativeAPMResponse->fillWithData($body); + } return (object) $returnValues; @@ -2112,9 +2166,11 @@ public function initiateThreeDS($source, $options = array()) // Handling for field customer_action $body = $response->getBody(); - $body = $body['customer_action']; - $customerAction = new CustomerAction($this->client); - $returnValues['customerAction'] = $customerAction->fillWithData($body); + if (isset($body['customer_action'])) { + $body = $body['customer_action']; + $customerAction = new CustomerAction($this->client); + $returnValues['customerAction'] = $customerAction->fillWithData($body); + } return array_values($returnValues)[0]; @@ -2142,9 +2198,11 @@ public function fetchTransaction($options = array()) // Handling for field transaction $body = $response->getBody(); - $body = $body['transaction']; - $transaction = new Transaction($this->client); - $returnValues['transaction'] = $transaction->fillWithData($body); + if (isset($body['transaction'])) { + $body = $body['transaction']; + $transaction = new Transaction($this->client); + $returnValues['transaction'] = $transaction->fillWithData($body); + } return array_values($returnValues)[0]; @@ -2173,9 +2231,11 @@ public function void($options = array()) // Handling for field transaction $body = $response->getBody(); - $body = $body['transaction']; - $transaction = new Transaction($this->client); - $returnValues['transaction'] = $transaction->fillWithData($body); + if (isset($body['transaction'])) { + $body = $body['transaction']; + $transaction = new Transaction($this->client); + $returnValues['transaction'] = $transaction->fillWithData($body); + } return array_values($returnValues)[0]; @@ -2236,6 +2296,7 @@ public function create($options = array()) "metadata" => $this->getMetadata(), "details" => $this->getDetails(), "submerchant" => $this->getSubmerchant(), + "reference_id" => $this->getReferenceId(), "exemption_reason_3ds2" => $this->getExemptionReason3ds2(), "sca_exemption_reason" => $this->getScaExemptionReason(), "challenge_indicator" => $this->getChallengeIndicator(), @@ -2271,8 +2332,10 @@ public function create($options = array()) // Handling for field invoice $body = $response->getBody(); - $body = $body['invoice']; - $returnValues['create'] = $this->fillWithData($body); + if (isset($body['invoice'])) { + $body = $body['invoice']; + $returnValues['create'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } @@ -2300,8 +2363,10 @@ public function find($invoiceId, $options = array()) // Handling for field invoice $body = $response->getBody(); - $body = $body['invoice']; - $returnValues['find'] = $this->fillWithData($body); + if (isset($body['invoice'])) { + $body = $body['invoice']; + $returnValues['find'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } @@ -2354,8 +2419,10 @@ public function syncWithPsp($invoiceId, $options = array()) // Handling for field invoice $body = $response->getBody(); - $body = $body['invoice']; - $returnValues['syncWithPsp'] = $this->fillWithData($body); + if (isset($body['invoice'])) { + $body = $body['invoice']; + $returnValues['syncWithPsp'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } @@ -2386,8 +2453,10 @@ public function update($invoiceId, $options = array()) // Handling for field invoice $body = $response->getBody(); - $body = $body['invoice']; - $returnValues['update'] = $this->fillWithData($body); + if (isset($body['invoice'])) { + $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 4e3c44b..78d290a 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.3.0' + 'User-Agent: ProcessOut PHP-Bindings/7.4.0' ); if (! empty($options['idempotencyKey'])) $headers[] = 'Idempotency-Key: ' . $options['idempotencyKey']; diff --git a/src/Payout.php b/src/Payout.php index d0c6e44..02ebe18 100755 --- a/src/Payout.php +++ b/src/Payout.php @@ -788,8 +788,10 @@ public function find($payoutId, $options = array()) // Handling for field payout $body = $response->getBody(); - $body = $body['payout']; - $returnValues['find'] = $this->fillWithData($body); + if (isset($body['payout'])) { + $body = $body['payout']; + $returnValues['find'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } diff --git a/src/Plan.php b/src/Plan.php index 53d346a..37ce238 100755 --- a/src/Plan.php +++ b/src/Plan.php @@ -569,8 +569,10 @@ public function create($options = array()) // Handling for field plan $body = $response->getBody(); - $body = $body['plan']; - $returnValues['create'] = $this->fillWithData($body); + if (isset($body['plan'])) { + $body = $body['plan']; + $returnValues['create'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } @@ -598,8 +600,10 @@ public function find($planId, $options = array()) // Handling for field plan $body = $response->getBody(); - $body = $body['plan']; - $returnValues['find'] = $this->fillWithData($body); + if (isset($body['plan'])) { + $body = $body['plan']; + $returnValues['find'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } @@ -630,8 +634,10 @@ public function save($options = array()) // Handling for field plan $body = $response->getBody(); - $body = $body['plan']; - $returnValues['save'] = $this->fillWithData($body); + if (isset($body['plan'])) { + $body = $body['plan']; + $returnValues['save'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } diff --git a/src/ProcessOut.php b/src/ProcessOut.php index a42cbad..bdd8ae3 100644 --- a/src/ProcessOut.php +++ b/src/ProcessOut.php @@ -136,6 +136,15 @@ public function newBalance($prefill = array()) { return new Balance($this, $prefill); } + /** + * Create a new BalancesCustomerAction instance + * @param array|null $prefill array used to prefill the object + * @return BalancesCustomerAction + */ + public function newBalancesCustomerAction($prefill = array()) { + return new BalancesCustomerAction($this, $prefill); + } + /** * Create a new Card instance * @param array|null $prefill array used to prefill the object @@ -649,15 +658,6 @@ public function newWebhookEndpoint($prefill = array()) { return new WebhookEndpoint($this, $prefill); } - /** - * Create a new CardCreateRequest instance - * @param array|null $prefill array used to prefill the object - * @return CardCreateRequest - */ - public function newCardCreateRequest($prefill = array()) { - return new CardCreateRequest($this, $prefill); - } - /** * Create a new Device instance * @param array|null $prefill array used to prefill the object @@ -694,6 +694,15 @@ public function newCardUpdateRequest($prefill = array()) { return new CardUpdateRequest($this, $prefill); } + /** + * Create a new CardCreateRequest instance + * @param array|null $prefill array used to prefill the object + * @return CardCreateRequest + */ + public function newCardCreateRequest($prefill = array()) { + return new CardCreateRequest($this, $prefill); + } + /** * Create a new ErrorCodes instance * @param array|null $prefill array used to prefill the object diff --git a/src/Product.php b/src/Product.php index 0447941..ac012c3 100755 --- a/src/Product.php +++ b/src/Product.php @@ -463,9 +463,11 @@ public function createInvoice($options = array()) // Handling for field invoice $body = $response->getBody(); - $body = $body['invoice']; - $invoice = new Invoice($this->client); - $returnValues['invoice'] = $invoice->fillWithData($body); + if (isset($body['invoice'])) { + $body = $body['invoice']; + $invoice = new Invoice($this->client); + $returnValues['invoice'] = $invoice->fillWithData($body); + } return array_values($returnValues)[0]; @@ -532,8 +534,10 @@ public function create($options = array()) // Handling for field product $body = $response->getBody(); - $body = $body['product']; - $returnValues['create'] = $this->fillWithData($body); + if (isset($body['product'])) { + $body = $body['product']; + $returnValues['create'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } @@ -561,8 +565,10 @@ public function find($productId, $options = array()) // Handling for field product $body = $response->getBody(); - $body = $body['product']; - $returnValues['find'] = $this->fillWithData($body); + if (isset($body['product'])) { + $body = $body['product']; + $returnValues['find'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } @@ -594,8 +600,10 @@ public function save($options = array()) // Handling for field product $body = $response->getBody(); - $body = $body['product']; - $returnValues['save'] = $this->fillWithData($body); + if (isset($body['product'])) { + $body = $body['product']; + $returnValues['save'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } diff --git a/src/Project.php b/src/Project.php index ee5cc31..8c3c9de 100755 --- a/src/Project.php +++ b/src/Project.php @@ -450,8 +450,10 @@ public function fetch($options = array()) // Handling for field project $body = $response->getBody(); - $body = $body['project']; - $returnValues['fetch'] = $this->fillWithData($body); + if (isset($body['project'])) { + $body = $body['project']; + $returnValues['fetch'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } @@ -478,8 +480,10 @@ public function save($options = array()) // Handling for field project $body = $response->getBody(); - $body = $body['project']; - $returnValues['save'] = $this->fillWithData($body); + if (isset($body['project'])) { + $body = $body['project']; + $returnValues['save'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } @@ -569,8 +573,10 @@ public function createSupervised($options = array()) // Handling for field project $body = $response->getBody(); - $body = $body['project']; - $returnValues['createSupervised'] = $this->fillWithData($body); + if (isset($body['project'])) { + $body = $body['project']; + $returnValues['createSupervised'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } diff --git a/src/ProjectSFTPSettingsPublic.php b/src/ProjectSFTPSettingsPublic.php index 6d51bf6..50d2d72 100755 --- a/src/ProjectSFTPSettingsPublic.php +++ b/src/ProjectSFTPSettingsPublic.php @@ -169,8 +169,10 @@ public function fetchSftpSettings($id, $options = array()) // Handling for field sftp_settings $body = $response->getBody(); - $body = $body['sftp_settings']; - $returnValues['fetchSftpSettings'] = $this->fillWithData($body); + if (isset($body['sftp_settings'])) { + $body = $body['sftp_settings']; + $returnValues['fetchSftpSettings'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } diff --git a/src/Refund.php b/src/Refund.php index 15f4e7a..617890d 100755 --- a/src/Refund.php +++ b/src/Refund.php @@ -497,8 +497,10 @@ public function find($transactionId, $refundId, $options = array()) // Handling for field refund $body = $response->getBody(); - $body = $body['refund']; - $returnValues['find'] = $this->fillWithData($body); + if (isset($body['refund'])) { + $body = $body['refund']; + $returnValues['find'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } diff --git a/src/Subscription.php b/src/Subscription.php index 47feee5..eb563bd 100755 --- a/src/Subscription.php +++ b/src/Subscription.php @@ -1291,9 +1291,11 @@ public function findAddon($addonId, $options = array()) // Handling for field addon $body = $response->getBody(); - $body = $body['addon']; - $addon = new Addon($this->client); - $returnValues['addon'] = $addon->fillWithData($body); + if (isset($body['addon'])) { + $body = $body['addon']; + $addon = new Addon($this->client); + $returnValues['addon'] = $addon->fillWithData($body); + } return array_values($returnValues)[0]; @@ -1348,9 +1350,11 @@ public function fetchCustomer($options = array()) // Handling for field customer $body = $response->getBody(); - $body = $body['customer']; - $customer = new Customer($this->client); - $returnValues['customer'] = $customer->fillWithData($body); + if (isset($body['customer'])) { + $body = $body['customer']; + $customer = new Customer($this->client); + $returnValues['customer'] = $customer->fillWithData($body); + } return array_values($returnValues)[0]; @@ -1413,9 +1417,11 @@ public function findDiscount($discountId, $options = array()) // Handling for field discount $body = $response->getBody(); - $body = $body['discount']; - $discount = new Discount($this->client); - $returnValues['discount'] = $discount->fillWithData($body); + if (isset($body['discount'])) { + $body = $body['discount']; + $discount = new Discount($this->client); + $returnValues['discount'] = $discount->fillWithData($body); + } return array_values($returnValues)[0]; @@ -1548,8 +1554,10 @@ public function create($options = array()) // Handling for field subscription $body = $response->getBody(); - $body = $body['subscription']; - $returnValues['create'] = $this->fillWithData($body); + if (isset($body['subscription'])) { + $body = $body['subscription']; + $returnValues['create'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } @@ -1577,8 +1585,10 @@ public function find($subscriptionId, $options = array()) // Handling for field subscription $body = $response->getBody(); - $body = $body['subscription']; - $returnValues['find'] = $this->fillWithData($body); + if (isset($body['subscription'])) { + $body = $body['subscription']; + $returnValues['find'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } @@ -1615,8 +1625,10 @@ public function save($options = array()) // Handling for field subscription $body = $response->getBody(); - $body = $body['subscription']; - $returnValues['save'] = $this->fillWithData($body); + if (isset($body['subscription'])) { + $body = $body['subscription']; + $returnValues['save'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } @@ -1645,8 +1657,10 @@ public function cancel($options = array()) // Handling for field subscription $body = $response->getBody(); - $body = $body['subscription']; - $returnValues['cancel'] = $this->fillWithData($body); + if (isset($body['subscription'])) { + $body = $body['subscription']; + $returnValues['cancel'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } diff --git a/src/Token.php b/src/Token.php index abe6f46..c7d7f0a 100755 --- a/src/Token.php +++ b/src/Token.php @@ -873,8 +873,10 @@ public function find($customerId, $tokenId, $options = array()) // Handling for field token $body = $response->getBody(); - $body = $body['token']; - $returnValues['find'] = $this->fillWithData($body); + if (isset($body['token'])) { + $body = $body['token']; + $returnValues['find'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; } @@ -899,6 +901,7 @@ public function create($options = array()) "invoice_id" => $this->getInvoiceId(), "manual_invoice_cancellation" => $this->getManualInvoiceCancellation(), "webhook_url" => $this->getWebhookUrl(), + "gateway_configuration_id" => $this->getGatewayConfigurationId(), "source" => (!empty($options["source"])) ? $options["source"] : null, "settings" => (!empty($options["settings"])) ? $options["settings"] : null, "device" => (!empty($options["device"])) ? $options["device"] : null, @@ -916,13 +919,17 @@ public function create($options = array()) // Handling for field token $body = $response->getBody(); - $body = $body['token']; - $returnValues['create'] = $this->fillWithData($body); + if (isset($body['token'])) { + $body = $body['token']; + $returnValues['create'] = $this->fillWithData($body); + } // Handling for field customer_action $body = $response->getBody(); - $body = $body['customer_action']; - $customerAction = new CustomerAction($this->client); - $returnValues['customerAction'] = $customerAction->fillWithData($body); + if (isset($body['customer_action'])) { + $body = $body['customer_action']; + $customerAction = new CustomerAction($this->client); + $returnValues['customerAction'] = $customerAction->fillWithData($body); + } return (object) $returnValues; @@ -948,7 +955,8 @@ public function save($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, + "gateway_configuration_id" => (!empty($options["gateway_configuration_id"])) ? $options["gateway_configuration_id"] : null ); $response = $request->put($path, $data, $options); diff --git a/src/Transaction.php b/src/Transaction.php index ee9c9d4..52214c0 100755 --- a/src/Transaction.php +++ b/src/Transaction.php @@ -2345,9 +2345,11 @@ public function findRefund($refundId, $options = array()) // Handling for field refund $body = $response->getBody(); - $body = $body['refund']; - $refund = new Refund($this->client); - $returnValues['refund'] = $refund->fillWithData($body); + if (isset($body['refund'])) { + $body = $body['refund']; + $refund = new Refund($this->client); + $returnValues['refund'] = $refund->fillWithData($body); + } return array_values($returnValues)[0]; @@ -2444,8 +2446,10 @@ public function find($transactionId, $options = array()) // Handling for field transaction $body = $response->getBody(); - $body = $body['transaction']; - $returnValues['find'] = $this->fillWithData($body); + if (isset($body['transaction'])) { + $body = $body['transaction']; + $returnValues['find'] = $this->fillWithData($body); + } return array_values($returnValues)[0]; }