diff --git a/.gitignore b/.gitignore index 4c3559a..6e6062d 100644 --- a/.gitignore +++ b/.gitignore @@ -27,5 +27,3 @@ Temporary Items /vendor deploy.sh - -.github diff --git a/README.md b/README.md index 3aacba2..db00306 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.27.0" + "processout/processout-php": "^6.28.0" } } ``` diff --git a/init.php b/init.php index eb65fe1..e502237 100644 --- a/init.php +++ b/init.php @@ -24,18 +24,23 @@ include_once(dirname(__FILE__) . "/src/CardInformation.php"); include_once(dirname(__FILE__) . "/src/Coupon.php"); include_once(dirname(__FILE__) . "/src/Customer.php"); +include_once(dirname(__FILE__) . "/src/CustomerPhone.php"); include_once(dirname(__FILE__) . "/src/Token.php"); include_once(dirname(__FILE__) . "/src/Discount.php"); include_once(dirname(__FILE__) . "/src/Event.php"); include_once(dirname(__FILE__) . "/src/Gateway.php"); include_once(dirname(__FILE__) . "/src/GatewayConfiguration.php"); include_once(dirname(__FILE__) . "/src/Invoice.php"); +include_once(dirname(__FILE__) . "/src/NativeAPMRequest.php"); +include_once(dirname(__FILE__) . "/src/NativeAPMParameterValue.php"); include_once(dirname(__FILE__) . "/src/InvoiceTax.php"); include_once(dirname(__FILE__) . "/src/InvoiceExternalFraudTools.php"); include_once(dirname(__FILE__) . "/src/InvoiceRisk.php"); include_once(dirname(__FILE__) . "/src/InvoiceDevice.php"); include_once(dirname(__FILE__) . "/src/InvoiceShipping.php"); +include_once(dirname(__FILE__) . "/src/InvoiceShippingPhone.php"); include_once(dirname(__FILE__) . "/src/InvoiceBilling.php"); +include_once(dirname(__FILE__) . "/src/UnsupportedFeatureBypass.php"); include_once(dirname(__FILE__) . "/src/InvoiceDetail.php"); include_once(dirname(__FILE__) . "/src/CustomerAction.php"); include_once(dirname(__FILE__) . "/src/DunningAction.php"); @@ -44,9 +49,13 @@ include_once(dirname(__FILE__) . "/src/Plan.php"); include_once(dirname(__FILE__) . "/src/Product.php"); include_once(dirname(__FILE__) . "/src/Project.php"); +include_once(dirname(__FILE__) . "/src/ProjectSFTPSettings.php"); include_once(dirname(__FILE__) . "/src/Refund.php"); include_once(dirname(__FILE__) . "/src/Subscription.php"); include_once(dirname(__FILE__) . "/src/Transaction.php"); +include_once(dirname(__FILE__) . "/src/NativeAPMResponse.php"); +include_once(dirname(__FILE__) . "/src/NativeAPMParameterDefinition.php"); +include_once(dirname(__FILE__) . "/src/NativeAPMParameterValueDefinition.php"); include_once(dirname(__FILE__) . "/src/ThreeDS.php"); include_once(dirname(__FILE__) . "/src/PaymentDataThreeDSRequest.php"); include_once(dirname(__FILE__) . "/src/PaymentDataNetworkAuthentication.php"); @@ -54,5 +63,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/ErrorCodes.php"); +include_once(dirname(__FILE__) . "/src/CategoryErrorCodes.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/InvoicesProcessNativePaymentResponse.php"); include_once(dirname(__FILE__) . "/src/GatewayRequest.php"); diff --git a/src/Card.php b/src/Card.php index b9c0a34..11ac868 100755 --- a/src/Card.php +++ b/src/Card.php @@ -178,6 +178,18 @@ class Card implements \JsonSerializable */ protected $tokenType; + /** + * Contains true if the card was used to create a customer token or a direct transaction, false otherwise + * @var boolean + */ + protected $used; + + /** + * Contains true if the card was successfully authorized, false otherwise + * @var boolean + */ + protected $hasBeenAuthorized; + /** * Metadata related to the card, in the form of a dictionary (key-value pair) * @var dictionary @@ -823,6 +835,50 @@ public function setTokenType($value) return $this; } + /** + * Get Used + * Contains true if the card was used to create a customer token or a direct transaction, false otherwise + * @return bool + */ + public function getUsed() + { + return $this->used; + } + + /** + * Set Used + * Contains true if the card was used to create a customer token or a direct transaction, false otherwise + * @param bool $value + * @return $this + */ + public function setUsed($value) + { + $this->used = $value; + return $this; + } + + /** + * Get HasBeenAuthorized + * Contains true if the card was successfully authorized, false otherwise + * @return bool + */ + public function getHasBeenAuthorized() + { + return $this->hasBeenAuthorized; + } + + /** + * Set HasBeenAuthorized + * Contains true if the card was successfully authorized, false otherwise + * @param bool $value + * @return $this + */ + public function setHasBeenAuthorized($value) + { + $this->hasBeenAuthorized = $value; + return $this; + } + /** * Get Metadata * Metadata related to the card, in the form of a dictionary (key-value pair) @@ -1000,6 +1056,12 @@ public function fillWithData($data) if(! empty($data['token_type'])) $this->setTokenType($data['token_type']); + if(! empty($data['used'])) + $this->setUsed($data['used']); + + if(! empty($data['has_been_authorized'])) + $this->setHasBeenAuthorized($data['has_been_authorized']); + if(! empty($data['metadata'])) $this->setMetadata($data['metadata']); @@ -1048,6 +1110,8 @@ public function jsonSerialize() { "ip_address" => $this->getIpAddress(), "fingerprint" => $this->getFingerprint(), "token_type" => $this->getTokenType(), + "used" => $this->getUsed(), + "has_been_authorized" => $this->getHasBeenAuthorized(), "metadata" => $this->getMetadata(), "expires_soon" => $this->getExpiresSoon(), "sandbox" => $this->getSandbox(), diff --git a/src/CategoryErrorCodes.php b/src/CategoryErrorCodes.php new file mode 100755 index 0000000..6d58c7b --- /dev/null +++ b/src/CategoryErrorCodes.php @@ -0,0 +1,405 @@ +client = $client; + + $this->fillWithData($prefill); + } + + + /** + * Get Generic + * Generic error codes. + * @return array + */ + public function getGeneric() + { + return $this->generic; + } + + /** + * Set Generic + * Generic error codes. + * @param array $value + * @return $this + */ + public function setGeneric($value) + { + $this->generic = $value; + return $this; + } + + /** + * Get Service + * Service related error codes. + * @return array + */ + public function getService() + { + return $this->service; + } + + /** + * Set Service + * Service related error codes. + * @param array $value + * @return $this + */ + public function setService($value) + { + $this->service = $value; + return $this; + } + + /** + * Get Gateway + * Gateway related error codes. + * @return array + */ + public function getGateway() + { + return $this->gateway; + } + + /** + * Set Gateway + * Gateway related error codes. + * @param array $value + * @return $this + */ + public function setGateway($value) + { + $this->gateway = $value; + return $this; + } + + /** + * Get Card + * Card related error codes. + * @return array + */ + public function getCard() + { + return $this->card; + } + + /** + * Set Card + * Card related error codes. + * @param array $value + * @return $this + */ + public function setCard($value) + { + $this->card = $value; + return $this; + } + + /** + * Get Check + * Check related error codes. + * @return array + */ + public function getCheck() + { + return $this->check; + } + + /** + * Set Check + * Check related error codes. + * @param array $value + * @return $this + */ + public function setCheck($value) + { + $this->check = $value; + return $this; + } + + /** + * Get Shipping + * Shipping related error codes. + * @return array + */ + public function getShipping() + { + return $this->shipping; + } + + /** + * Set Shipping + * Shipping related error codes. + * @param array $value + * @return $this + */ + public function setShipping($value) + { + $this->shipping = $value; + return $this; + } + + /** + * Get Customer + * Customer related error codes. + * @return array + */ + public function getCustomer() + { + return $this->customer; + } + + /** + * Set Customer + * Customer related error codes. + * @param array $value + * @return $this + */ + public function setCustomer($value) + { + $this->customer = $value; + return $this; + } + + /** + * Get Payment + * Payment related error codes. + * @return array + */ + public function getPayment() + { + return $this->payment; + } + + /** + * Set Payment + * Payment related error codes. + * @param array $value + * @return $this + */ + public function setPayment($value) + { + $this->payment = $value; + return $this; + } + + /** + * Get Refund + * Refund related error codes. + * @return array + */ + public function getRefund() + { + return $this->refund; + } + + /** + * Set Refund + * Refund related error codes. + * @param array $value + * @return $this + */ + public function setRefund($value) + { + $this->refund = $value; + return $this; + } + + /** + * Get Wallet + * Wallet related error codes. + * @return array + */ + public function getWallet() + { + return $this->wallet; + } + + /** + * Set Wallet + * Wallet related error codes. + * @param array $value + * @return $this + */ + public function setWallet($value) + { + $this->wallet = $value; + return $this; + } + + /** + * Get Request + * Request related error codes. + * @return array + */ + public function getRequest() + { + return $this->request; + } + + /** + * Set Request + * Request related error codes. + * @param array $value + * @return $this + */ + public function setRequest($value) + { + $this->request = $value; + return $this; + } + + + /** + * Fills the current object with the new values pulled from the data + * @param array $data + * @return CategoryErrorCodes + */ + public function fillWithData($data) + { + if(! empty($data['generic'])) + $this->setGeneric($data['generic']); + + if(! empty($data['service'])) + $this->setService($data['service']); + + if(! empty($data['gateway'])) + $this->setGateway($data['gateway']); + + if(! empty($data['card'])) + $this->setCard($data['card']); + + if(! empty($data['check'])) + $this->setCheck($data['check']); + + if(! empty($data['shipping'])) + $this->setShipping($data['shipping']); + + if(! empty($data['customer'])) + $this->setCustomer($data['customer']); + + if(! empty($data['payment'])) + $this->setPayment($data['payment']); + + if(! empty($data['refund'])) + $this->setRefund($data['refund']); + + if(! empty($data['wallet'])) + $this->setWallet($data['wallet']); + + if(! empty($data['request'])) + $this->setRequest($data['request']); + + return $this; + } + + /** + * Implements the JsonSerializable interface + * @return object + */ + public function jsonSerialize() { + return array( + "generic" => $this->getGeneric(), + "service" => $this->getService(), + "gateway" => $this->getGateway(), + "card" => $this->getCard(), + "check" => $this->getCheck(), + "shipping" => $this->getShipping(), + "customer" => $this->getCustomer(), + "payment" => $this->getPayment(), + "refund" => $this->getRefund(), + "wallet" => $this->getWallet(), + "request" => $this->getRequest(), + ); + } + + +} diff --git a/src/Customer.php b/src/Customer.php index 4696a61..226f03b 100755 --- a/src/Customer.php +++ b/src/Customer.php @@ -137,11 +137,17 @@ class Customer implements \JsonSerializable protected $ipAddress; /** - * Phone number of the customer + * Customer full phone number, consisting of a combined dialing code and phone number * @var string */ protected $phoneNumber; + /** + * Customer phone number + * @var object + */ + protected $phone; + /** * Legal document number * @var string @@ -695,7 +701,7 @@ public function setIpAddress($value) /** * Get PhoneNumber - * Phone number of the customer + * Customer full phone number, consisting of a combined dialing code and phone number * @return string */ public function getPhoneNumber() @@ -705,7 +711,7 @@ public function getPhoneNumber() /** * Set PhoneNumber - * Phone number of the customer + * Customer full phone number, consisting of a combined dialing code and phone number * @param string $value * @return $this */ @@ -715,6 +721,35 @@ public function setPhoneNumber($value) return $this; } + /** + * Get Phone + * Customer phone number + * @return object + */ + public function getPhone() + { + return $this->phone; + } + + /** + * Set Phone + * Customer phone number + * @param object $value + * @return $this + */ + public function setPhone($value) + { + if (is_object($value)) + $this->phone = $value; + else + { + $obj = new CustomerPhone($this->client); + $obj->fillWithData($value); + $this->phone = $obj; + } + return $this; + } + /** * Get LegalDocument * Legal document number @@ -962,6 +997,9 @@ public function fillWithData($data) if(! empty($data['phone_number'])) $this->setPhoneNumber($data['phone_number']); + if(! empty($data['phone'])) + $this->setPhone($data['phone']); + if(! empty($data['legal_document'])) $this->setLegalDocument($data['legal_document']); @@ -1016,6 +1054,7 @@ public function jsonSerialize() { "country_code" => $this->getCountryCode(), "ip_address" => $this->getIpAddress(), "phone_number" => $this->getPhoneNumber(), + "phone" => $this->getPhone(), "legal_document" => $this->getLegalDocument(), "sex" => $this->getSex(), "is_business" => $this->getIsBusiness(), @@ -1245,14 +1284,15 @@ public function create($options = array()) "zip" => $this->getZip(), "country_code" => $this->getCountryCode(), "ip_address" => $this->getIpAddress(), - "phone_number" => $this->getPhoneNumber(), + "phone" => $this->getPhone(), "legal_document" => $this->getLegalDocument(), "date_of_birth" => $this->getDateOfBirth(), "is_business" => $this->getIsBusiness(), "sex" => $this->getSex(), "metadata" => $this->getMetadata(), "id" => $this->getId(), - "registered_at" => $this->getRegisteredAt() + "registered_at" => $this->getRegisteredAt(), + "phone_number" => $this->getPhoneNumber() ); $response = $request->post($path, $data, $options); @@ -1321,13 +1361,14 @@ public function save($options = array()) "zip" => $this->getZip(), "country_code" => $this->getCountryCode(), "ip_address" => $this->getIpAddress(), - "phone_number" => $this->getPhoneNumber(), + "phone" => $this->getPhone(), "legal_document" => $this->getLegalDocument(), "date_of_birth" => $this->getDateOfBirth(), "is_business" => $this->getIsBusiness(), "sex" => $this->getSex(), "metadata" => $this->getMetadata(), - "registered_at" => $this->getRegisteredAt() + "registered_at" => $this->getRegisteredAt(), + "phone_number" => $this->getPhoneNumber() ); $response = $request->put($path, $data, $options); diff --git a/src/CustomerPhone.php b/src/CustomerPhone.php new file mode 100755 index 0000000..3e98b49 --- /dev/null +++ b/src/CustomerPhone.php @@ -0,0 +1,117 @@ +client = $client; + + $this->fillWithData($prefill); + } + + + /** + * Get Number + * Phone number of the customer + * @return string + */ + public function getNumber() + { + return $this->number; + } + + /** + * Set Number + * Phone number of the customer + * @param string $value + * @return $this + */ + public function setNumber($value) + { + $this->number = $value; + return $this; + } + + /** + * Get DialingCode + * Phone number dialing code of the customer + * @return string + */ + public function getDialingCode() + { + return $this->dialingCode; + } + + /** + * Set DialingCode + * Phone number dialing code of the customer + * @param string $value + * @return $this + */ + public function setDialingCode($value) + { + $this->dialingCode = $value; + return $this; + } + + + /** + * Fills the current object with the new values pulled from the data + * @param array $data + * @return CustomerPhone + */ + public function fillWithData($data) + { + if(! empty($data['number'])) + $this->setNumber($data['number']); + + if(! empty($data['dialing_code'])) + $this->setDialingCode($data['dialing_code']); + + return $this; + } + + /** + * Implements the JsonSerializable interface + * @return object + */ + public function jsonSerialize() { + return array( + "number" => $this->getNumber(), + "dialing_code" => $this->getDialingCode(), + ); + } + + +} diff --git a/src/ErrorCodes.php b/src/ErrorCodes.php new file mode 100755 index 0000000..9912593 --- /dev/null +++ b/src/ErrorCodes.php @@ -0,0 +1,119 @@ +client = $client; + + $this->fillWithData($prefill); + } + + + /** + * Get Gateway + * Error codes from gateways by category. + * @return object + */ + public function getGateway() + { + return $this->gateway; + } + + /** + * Set Gateway + * Error codes from gateways by category. + * @param object $value + * @return $this + */ + public function setGateway($value) + { + if (is_object($value)) + $this->gateway = $value; + else + { + $obj = new CategoryErrorCodes($this->client); + $obj->fillWithData($value); + $this->gateway = $obj; + } + return $this; + } + + + /** + * Fills the current object with the new values pulled from the data + * @param array $data + * @return ErrorCodes + */ + public function fillWithData($data) + { + if(! empty($data['gateway'])) + $this->setGateway($data['gateway']); + + return $this; + } + + /** + * Implements the JsonSerializable interface + * @return object + */ + public function jsonSerialize() { + return array( + "gateway" => $this->getGateway(), + ); + } + + + /** + * Get all error codes. + * @param array $options + * @return $this + */ + public function all($options = array()) + { + $this->fillWithData($options); + + $request = new Request($this->client); + $path = "/error-codes"; + + $data = array( + + ); + + $response = $request->get($path, $data, $options); + $returnValues = array(); + + + // Handling for field + $body = $response->getBody(); + $returnValues['all'] = $this->fillWithData($body); + + return array_values($returnValues)[0]; + } + +} diff --git a/src/GatewayConfiguration.php b/src/GatewayConfiguration.php index 7e8ba69..e214d6d 100755 --- a/src/GatewayConfiguration.php +++ b/src/GatewayConfiguration.php @@ -88,6 +88,12 @@ class GatewayConfiguration implements \JsonSerializable */ protected $processingRegion; + /** + * Metadata related to the gateway configuration, in the form of a dictionary (key-value pair) + * @var dictionary + */ + protected $metadata; + /** * GatewayConfiguration constructor * @param ProcessOut\ProcessOut $client @@ -379,6 +385,28 @@ public function setProcessingRegion($value) return $this; } + /** + * Get Metadata + * Metadata related to the gateway configuration, in the form of a dictionary (key-value pair) + * @return array + */ + public function getMetadata() + { + return $this->metadata; + } + + /** + * Set Metadata + * Metadata related to the gateway configuration, in the form of a dictionary (key-value pair) + * @param array $value + * @return $this + */ + public function setMetadata($value) + { + $this->metadata = $value; + return $this; + } + /** * Fills the current object with the new values pulled from the data @@ -423,6 +451,9 @@ public function fillWithData($data) if(! empty($data['processing_region'])) $this->setProcessingRegion($data['processing_region']); + if(! empty($data['metadata'])) + $this->setMetadata($data['metadata']); + return $this; } @@ -444,6 +475,7 @@ public function jsonSerialize() { "created_at" => $this->getCreatedAt(), "enabled_at" => $this->getEnabledAt(), "processing_region" => $this->getProcessingRegion(), + "metadata" => $this->getMetadata(), ); } @@ -529,6 +561,7 @@ public function save($options = array()) "enabled" => $this->getEnabled(), "default_currency" => $this->getDefaultCurrency(), "processing_region" => $this->getProcessingRegion(), + "metadata" => $this->getMetadata(), "settings" => (!empty($options["settings"])) ? $options["settings"] : null, "sub_accounts_enabled" => (!empty($options["sub_accounts_enabled"])) ? $options["sub_accounts_enabled"] : null ); @@ -588,6 +621,7 @@ public function create($gatewayName, $options = array()) "enabled" => $this->getEnabled(), "default_currency" => $this->getDefaultCurrency(), "processing_region" => $this->getProcessingRegion(), + "metadata" => $this->getMetadata(), "settings" => (!empty($options["settings"])) ? $options["settings"] : null, "sub_accounts_enabled" => (!empty($options["sub_accounts_enabled"])) ? $options["sub_accounts_enabled"] : null ); diff --git a/src/Invoice.php b/src/Invoice.php index 64c4bda..1afb697 100755 --- a/src/Invoice.php +++ b/src/Invoice.php @@ -256,6 +256,12 @@ class Invoice implements \JsonSerializable */ protected $paymentType; + /** + * Native APM data + * @var object + */ + protected $nativeApm; + /** * Initiation type of invoice * @var string @@ -274,6 +280,12 @@ class Invoice implements \JsonSerializable */ protected $billing; + /** + * Flags to bypass unsupported features + * @var object + */ + protected $unsupportedFeatureBypass; + /** * Invoice constructor * @param ProcessOut\ProcessOut $client @@ -1249,6 +1261,35 @@ public function setPaymentType($value) return $this; } + /** + * Get NativeApm + * Native APM data + * @return object + */ + public function getNativeApm() + { + return $this->nativeApm; + } + + /** + * Set NativeApm + * Native APM data + * @param object $value + * @return $this + */ + public function setNativeApm($value) + { + if (is_object($value)) + $this->nativeApm = $value; + else + { + $obj = new NativeAPMRequest($this->client); + $obj->fillWithData($value); + $this->nativeApm = $obj; + } + return $this; + } + /** * Get InitiationType * Initiation type of invoice @@ -1322,6 +1363,35 @@ public function setBilling($value) return $this; } + /** + * Get UnsupportedFeatureBypass + * Flags to bypass unsupported features + * @return object + */ + public function getUnsupportedFeatureBypass() + { + return $this->unsupportedFeatureBypass; + } + + /** + * Set UnsupportedFeatureBypass + * Flags to bypass unsupported features + * @param object $value + * @return $this + */ + public function setUnsupportedFeatureBypass($value) + { + if (is_object($value)) + $this->unsupportedFeatureBypass = $value; + else + { + $obj = new UnsupportedFeatureBypass($this->client); + $obj->fillWithData($value); + $this->unsupportedFeatureBypass = $obj; + } + return $this; + } + /** * Fills the current object with the new values pulled from the data @@ -1450,6 +1520,9 @@ public function fillWithData($data) if(! empty($data['payment_type'])) $this->setPaymentType($data['payment_type']); + if(! empty($data['native_apm'])) + $this->setNativeApm($data['native_apm']); + if(! empty($data['initiation_type'])) $this->setInitiationType($data['initiation_type']); @@ -1459,6 +1532,9 @@ public function fillWithData($data) if(! empty($data['billing'])) $this->setBilling($data['billing']); + if(! empty($data['unsupported_feature_bypass'])) + $this->setUnsupportedFeatureBypass($data['unsupported_feature_bypass']); + return $this; } @@ -1508,9 +1584,11 @@ public function jsonSerialize() { "incremental" => $this->getIncremental(), "tax" => $this->getTax(), "payment_type" => $this->getPaymentType(), + "native_apm" => $this->getNativeApm(), "initiation_type" => $this->getInitiationType(), "payment_intent" => $this->getPaymentIntent(), "billing" => $this->getBilling(), + "unsupported_feature_bypass" => $this->getUnsupportedFeatureBypass(), ); } @@ -1691,6 +1769,103 @@ public function assignCustomer($customerId, $options = array()) return array_values($returnValues)[0]; } + /** + * Process the payout invoice using the given source (customer or token) + * @param string $gatewayConfigurationId + * @param string $source + * @param array $options + * @return Transaction + */ + public function payout($gatewayConfigurationId, $source, $options = array()) + { + $this->fillWithData($options); + + $request = new Request($this->client); + $path = "/invoices/" . urlencode($this->getId()) . "/payout"; + + $data = array( + "force_gateway_configuration_id" => (!empty($options["force_gateway_configuration_id"])) ? $options["force_gateway_configuration_id"] : null, + "gateway_configuration_id" => $gatewayConfigurationId, + "source" => $source + ); + + $response = $request->post($path, $data, $options); + $returnValues = array(); + + + // Handling for field transaction + $body = $response->getBody(); + $body = $body['transaction']; + $transaction = new Transaction($this->client); + $returnValues['transaction'] = $transaction->fillWithData($body); + + + return array_values($returnValues)[0]; + } + + /** + * Fetches the Native APM payment + * @param string $invoiceId + * @param string $gatewayConfigurationId + * @param array $options + * @return NativeAPMTransactionDetails + */ + public function showNativePaymentTransaction($invoiceId, $gatewayConfigurationId, $options = array()) + { + $this->fillWithData($options); + + $request = new Request($this->client); + $path = "/invoices/" . urlencode($invoiceId) . "/native-payment/" . urlencode($gatewayConfigurationId) . ""; + + $data = array( + + ); + + $response = $request->get($path, $data, $options); + $returnValues = array(); + + + // Handling for field native_apm + $body = $response->getBody(); + $body = $body['native_apm']; + $nativeAPMTransactionDetails = new NativeAPMTransactionDetails($this->client); + $returnValues['nativeAPMTransactionDetails'] = $nativeAPMTransactionDetails->fillWithData($body); + + + return array_values($returnValues)[0]; + } + + /** + * Process the Native APM payment flow + * @param string $invoiceId + * @param array $options + * @return InvoicesProcessNativePaymentResponse + */ + public function processNativePayment($invoiceId, $options = array()) + { + $this->fillWithData($options); + + $request = new Request($this->client); + $path = "/invoices/" . urlencode($invoiceId) . "/native-payment"; + + $data = array( + "gateway_configuration_id" => (!empty($options["gateway_configuration_id"])) ? $options["gateway_configuration_id"] : null, + "native_apm" => (!empty($options["native_apm"])) ? $options["native_apm"] : null + ); + + $response = $request->post($path, $data, $options); + $returnValues = array(); + + + // Handling for field + $body = $response->getBody(); + $invoicesProcessNativePaymentResponse = new InvoicesProcessNativePaymentResponse($this->client); + $returnValues['invoicesProcessNativePaymentResponse'] = $invoicesProcessNativePaymentResponse->fillWithData($body); + + + return array_values($returnValues)[0]; + } + /** * Initiate a 3-D Secure authentication * @param string $source @@ -1859,7 +2034,8 @@ public function create($options = array()) "external_fraud_tools" => $this->getExternalFraudTools(), "tax" => $this->getTax(), "payment_type" => $this->getPaymentType(), - "billing" => $this->getBilling() + "billing" => $this->getBilling(), + "unsupported_feature_bypass" => $this->getUnsupportedFeatureBypass() ); $response = $request->post($path, $data, $options); diff --git a/src/InvoiceExternalFraudTools.php b/src/InvoiceExternalFraudTools.php index 839f869..04559e1 100755 --- a/src/InvoiceExternalFraudTools.php +++ b/src/InvoiceExternalFraudTools.php @@ -22,6 +22,12 @@ class InvoiceExternalFraudTools implements \JsonSerializable */ protected $forter; + /** + * Ravelin + * @var string + */ + protected $ravelin; + /** * Signifyd * @var string @@ -63,6 +69,28 @@ public function setForter($value) return $this; } + /** + * Get Ravelin + * Ravelin + * @return string + */ + public function getRavelin() + { + return $this->ravelin; + } + + /** + * Set Ravelin + * Ravelin + * @param string $value + * @return $this + */ + public function setRavelin($value) + { + $this->ravelin = $value; + return $this; + } + /** * Get Signifyd * Signifyd @@ -96,6 +124,9 @@ public function fillWithData($data) if(! empty($data['forter'])) $this->setForter($data['forter']); + if(! empty($data['ravelin'])) + $this->setRavelin($data['ravelin']); + if(! empty($data['signifyd'])) $this->setSignifyd($data['signifyd']); @@ -109,6 +140,7 @@ public function fillWithData($data) public function jsonSerialize() { return array( "forter" => $this->getForter(), + "ravelin" => $this->getRavelin(), "signifyd" => $this->getSignifyd(), ); } diff --git a/src/InvoiceShipping.php b/src/InvoiceShipping.php index 5b24649..54a4347 100755 --- a/src/InvoiceShipping.php +++ b/src/InvoiceShipping.php @@ -77,11 +77,17 @@ class InvoiceShipping implements \JsonSerializable protected $zip; /** - * Phone number for the shipment + * Shipment full phone number, consisting of a combined dialing code and phone number * @var string */ protected $phoneNumber; + /** + * Phone number for the shipment + * @var object + */ + protected $phone; + /** * Date at which the shipment is expected to be sent * @var string @@ -329,7 +335,7 @@ public function setZip($value) /** * Get PhoneNumber - * Phone number for the shipment + * Shipment full phone number, consisting of a combined dialing code and phone number * @return string */ public function getPhoneNumber() @@ -339,7 +345,7 @@ public function getPhoneNumber() /** * Set PhoneNumber - * Phone number for the shipment + * Shipment full phone number, consisting of a combined dialing code and phone number * @param string $value * @return $this */ @@ -349,6 +355,35 @@ public function setPhoneNumber($value) return $this; } + /** + * Get Phone + * Phone number for the shipment + * @return object + */ + public function getPhone() + { + return $this->phone; + } + + /** + * Set Phone + * Phone number for the shipment + * @param object $value + * @return $this + */ + public function setPhone($value) + { + if (is_object($value)) + $this->phone = $value; + else + { + $obj = new InvoiceShippingPhone($this->client); + $obj->fillWithData($value); + $this->phone = $obj; + } + return $this; + } + /** * Get ExpectsShippingAt * Date at which the shipment is expected to be sent @@ -434,6 +469,9 @@ public function fillWithData($data) if(! empty($data['phone_number'])) $this->setPhoneNumber($data['phone_number']); + if(! empty($data['phone'])) + $this->setPhone($data['phone']); + if(! empty($data['expects_shipping_at'])) $this->setExpectsShippingAt($data['expects_shipping_at']); @@ -460,6 +498,7 @@ public function jsonSerialize() { "country_code" => $this->getCountryCode(), "zip" => $this->getZip(), "phone_number" => $this->getPhoneNumber(), + "phone" => $this->getPhone(), "expects_shipping_at" => $this->getExpectsShippingAt(), "relay_store_name" => $this->getRelayStoreName(), ); diff --git a/src/InvoiceShippingPhone.php b/src/InvoiceShippingPhone.php new file mode 100755 index 0000000..7358f95 --- /dev/null +++ b/src/InvoiceShippingPhone.php @@ -0,0 +1,117 @@ +client = $client; + + $this->fillWithData($prefill); + } + + + /** + * Get Number + * Phone number for the shipment + * @return string + */ + public function getNumber() + { + return $this->number; + } + + /** + * Set Number + * Phone number for the shipment + * @param string $value + * @return $this + */ + public function setNumber($value) + { + $this->number = $value; + return $this; + } + + /** + * Get DialingCode + * Phone number dialing code for the shipment + * @return string + */ + public function getDialingCode() + { + return $this->dialingCode; + } + + /** + * Set DialingCode + * Phone number dialing code for the shipment + * @param string $value + * @return $this + */ + public function setDialingCode($value) + { + $this->dialingCode = $value; + return $this; + } + + + /** + * Fills the current object with the new values pulled from the data + * @param array $data + * @return InvoiceShippingPhone + */ + public function fillWithData($data) + { + if(! empty($data['number'])) + $this->setNumber($data['number']); + + if(! empty($data['dialing_code'])) + $this->setDialingCode($data['dialing_code']); + + return $this; + } + + /** + * Implements the JsonSerializable interface + * @return object + */ + public function jsonSerialize() { + return array( + "number" => $this->getNumber(), + "dialing_code" => $this->getDialingCode(), + ); + } + + +} diff --git a/src/InvoicesProcessNativePaymentResponse.php b/src/InvoicesProcessNativePaymentResponse.php new file mode 100755 index 0000000..42a8287 --- /dev/null +++ b/src/InvoicesProcessNativePaymentResponse.php @@ -0,0 +1,131 @@ +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/NativeAPMParameterDefinition.php b/src/NativeAPMParameterDefinition.php new file mode 100755 index 0000000..b9561c3 --- /dev/null +++ b/src/NativeAPMParameterDefinition.php @@ -0,0 +1,257 @@ +client = $client; + + $this->fillWithData($prefill); + } + + + /** + * Get Key + * Native APM parameter value key + * @return string + */ + public function getKey() + { + return $this->key; + } + + /** + * Set Key + * Native APM parameter value key + * @param string $value + * @return $this + */ + public function setKey($value) + { + $this->key = $value; + return $this; + } + + /** + * Get Type + * NativeAPM parameter value type + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * Set Type + * NativeAPM parameter value type + * @param string $value + * @return $this + */ + public function setType($value) + { + $this->type = $value; + return $this; + } + + /** + * Get Required + * NativeAPM parameter value requirement + * @return bool + */ + public function getRequired() + { + return $this->required; + } + + /** + * Set Required + * NativeAPM parameter value requirement + * @param bool $value + * @return $this + */ + public function setRequired($value) + { + $this->required = $value; + return $this; + } + + /** + * Get Length + * NativeAPM parameter value length + * @return int + */ + public function getLength() + { + return $this->length; + } + + /** + * Set Length + * NativeAPM parameter value length + * @param int $value + * @return $this + */ + public function setLength($value) + { + $this->length = $value; + return $this; + } + + /** + * Get DisplayName + * Native APM parameter display name + * @return string + */ + public function getDisplayName() + { + return $this->displayName; + } + + /** + * Set DisplayName + * Native APM parameter display name + * @param string $value + * @return $this + */ + public function setDisplayName($value) + { + $this->displayName = $value; + return $this; + } + + /** + * Get AvailableValues + * Native APM parameter available input values + * @return array + */ + public function getAvailableValues() + { + return $this->availableValues; + } + + /** + * Set AvailableValues + * Native APM parameter available input values + * @param array $value + * @return $this + */ + public function setAvailableValues($value) + { + if (count($value) > 0 && is_object($value[0])) + $this->availableValues = $value; + else + { + $a = array(); + foreach ($value as $v) + { + $obj = new NativeAPMParameterValueDefinition($this->client); + $obj->fillWithData($v); + $a[] = $obj; + } + $this->availableValues = $a; + } + return $this; + } + + + /** + * Fills the current object with the new values pulled from the data + * @param array $data + * @return NativeAPMParameterDefinition + */ + public function fillWithData($data) + { + if(! empty($data['key'])) + $this->setKey($data['key']); + + if(! empty($data['type'])) + $this->setType($data['type']); + + if(! empty($data['required'])) + $this->setRequired($data['required']); + + if(! empty($data['length'])) + $this->setLength($data['length']); + + if(! empty($data['display_name'])) + $this->setDisplayName($data['display_name']); + + if(! empty($data['available_values'])) + $this->setAvailableValues($data['available_values']); + + return $this; + } + + /** + * Implements the JsonSerializable interface + * @return object + */ + public function jsonSerialize() { + return array( + "key" => $this->getKey(), + "type" => $this->getType(), + "required" => $this->getRequired(), + "length" => $this->getLength(), + "display_name" => $this->getDisplayName(), + "available_values" => $this->getAvailableValues(), + ); + } + + +} diff --git a/src/NativeAPMParameterValue.php b/src/NativeAPMParameterValue.php new file mode 100755 index 0000000..bbecca1 --- /dev/null +++ b/src/NativeAPMParameterValue.php @@ -0,0 +1,117 @@ +client = $client; + + $this->fillWithData($prefill); + } + + + /** + * Get Key + * Native APM parameter value key + * @return string + */ + public function getKey() + { + return $this->key; + } + + /** + * Set Key + * Native APM parameter value key + * @param string $value + * @return $this + */ + public function setKey($value) + { + $this->key = $value; + return $this; + } + + /** + * Get Value + * Native APM parameter value value + * @return string + */ + public function getValue() + { + return $this->value; + } + + /** + * Set Value + * Native APM parameter value value + * @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 NativeAPMParameterValue + */ + public function fillWithData($data) + { + if(! empty($data['key'])) + $this->setKey($data['key']); + + if(! empty($data['value'])) + $this->setValue($data['value']); + + return $this; + } + + /** + * Implements the JsonSerializable interface + * @return object + */ + public function jsonSerialize() { + return array( + "key" => $this->getKey(), + "value" => $this->getValue(), + ); + } + + +} diff --git a/src/NativeAPMParameterValueDefinition.php b/src/NativeAPMParameterValueDefinition.php new file mode 100755 index 0000000..f40de66 --- /dev/null +++ b/src/NativeAPMParameterValueDefinition.php @@ -0,0 +1,149 @@ +client = $client; + + $this->fillWithData($prefill); + } + + + /** + * Get Value + * Native APM parameter value + * @return string + */ + public function getValue() + { + return $this->value; + } + + /** + * Set Value + * Native APM parameter value + * @param string $value + * @return $this + */ + public function setValue($value) + { + $this->value = $value; + return $this; + } + + /** + * Get Default + * Native APM parameter default value flag + * @return bool + */ + public function getDefault() + { + return $this->default; + } + + /** + * Set Default + * Native APM parameter default value flag + * @param bool $value + * @return $this + */ + public function setDefault($value) + { + $this->default = $value; + return $this; + } + + /** + * Get DisplayName + * Native APM parameter value display name + * @return string + */ + public function getDisplayName() + { + return $this->displayName; + } + + /** + * Set DisplayName + * Native APM parameter value display name + * @param string $value + * @return $this + */ + public function setDisplayName($value) + { + $this->displayName = $value; + return $this; + } + + + /** + * Fills the current object with the new values pulled from the data + * @param array $data + * @return NativeAPMParameterValueDefinition + */ + public function fillWithData($data) + { + if(! empty($data['value'])) + $this->setValue($data['value']); + + if(! empty($data['default'])) + $this->setDefault($data['default']); + + if(! empty($data['display_name'])) + $this->setDisplayName($data['display_name']); + + return $this; + } + + /** + * Implements the JsonSerializable interface + * @return object + */ + public function jsonSerialize() { + return array( + "value" => $this->getValue(), + "default" => $this->getDefault(), + "display_name" => $this->getDisplayName(), + ); + } + + +} diff --git a/src/NativeAPMRequest.php b/src/NativeAPMRequest.php new file mode 100755 index 0000000..f0c27f4 --- /dev/null +++ b/src/NativeAPMRequest.php @@ -0,0 +1,97 @@ +client = $client; + + $this->fillWithData($prefill); + } + + + /** + * Get ParameterValues + * Native APM parameter values + * @return array + */ + public function getParameterValues() + { + return $this->parameterValues; + } + + /** + * Set ParameterValues + * Native APM parameter values + * @param array $value + * @return $this + */ + public function setParameterValues($value) + { + if (count($value) > 0 && is_object($value[0])) + $this->parameterValues = $value; + else + { + $a = array(); + foreach ($value as $v) + { + $obj = new NativeAPMParameterValue($this->client); + $obj->fillWithData($v); + $a[] = $obj; + } + $this->parameterValues = $a; + } + return $this; + } + + + /** + * Fills the current object with the new values pulled from the data + * @param array $data + * @return NativeAPMRequest + */ + public function fillWithData($data) + { + if(! empty($data['parameter_values'])) + $this->setParameterValues($data['parameter_values']); + + return $this; + } + + /** + * Implements the JsonSerializable interface + * @return object + */ + public function jsonSerialize() { + return array( + "parameter_values" => $this->getParameterValues(), + ); + } + + +} diff --git a/src/NativeAPMResponse.php b/src/NativeAPMResponse.php new file mode 100755 index 0000000..e68e5c6 --- /dev/null +++ b/src/NativeAPMResponse.php @@ -0,0 +1,173 @@ +client = $client; + + $this->fillWithData($prefill); + } + + + /** + * Get State + * Native APM response state + * @return string + */ + public function getState() + { + return $this->state; + } + + /** + * Set State + * Native APM response state + * @param string $value + * @return $this + */ + public function setState($value) + { + $this->state = $value; + return $this; + } + + /** + * Get ParameterDefinitions + * Native APM parameter values description + * @return array + */ + public function getParameterDefinitions() + { + return $this->parameterDefinitions; + } + + /** + * Set ParameterDefinitions + * Native APM parameter values description + * @param array $value + * @return $this + */ + public function setParameterDefinitions($value) + { + if (count($value) > 0 && is_object($value[0])) + $this->parameterDefinitions = $value; + else + { + $a = array(); + foreach ($value as $v) + { + $obj = new NativeAPMParameterDefinition($this->client); + $obj->fillWithData($v); + $a[] = $obj; + } + $this->parameterDefinitions = $a; + } + return $this; + } + + /** + * Get ParameterValues + * Native APM parameter values + * @return array + */ + public function getParameterValues() + { + return $this->parameterValues; + } + + /** + * Set ParameterValues + * Native APM parameter values + * @param array $value + * @return $this + */ + public function setParameterValues($value) + { + if (count($value) > 0 && is_object($value[0])) + $this->parameterValues = $value; + else + { + $a = array(); + foreach ($value as $v) + { + $obj = new NativeAPMParameterValue($this->client); + $obj->fillWithData($v); + $a[] = $obj; + } + $this->parameterValues = $a; + } + return $this; + } + + + /** + * Fills the current object with the new values pulled from the data + * @param array $data + * @return NativeAPMResponse + */ + public function fillWithData($data) + { + if(! empty($data['state'])) + $this->setState($data['state']); + + if(! empty($data['parameter_definitions'])) + $this->setParameterDefinitions($data['parameter_definitions']); + + if(! empty($data['parameter_values'])) + $this->setParameterValues($data['parameter_values']); + + return $this; + } + + /** + * Implements the JsonSerializable interface + * @return object + */ + public function jsonSerialize() { + return array( + "state" => $this->getState(), + "parameter_definitions" => $this->getParameterDefinitions(), + "parameter_values" => $this->getParameterValues(), + ); + } + + +} diff --git a/src/NativeAPMTransactionDetails.php b/src/NativeAPMTransactionDetails.php new file mode 100755 index 0000000..c5aa544 --- /dev/null +++ b/src/NativeAPMTransactionDetails.php @@ -0,0 +1,207 @@ +client = $client; + + $this->fillWithData($prefill); + } + + + /** + * Get Gateway + * Native APM Gateway details + * @return object + */ + public function getGateway() + { + return $this->gateway; + } + + /** + * Set Gateway + * Native APM Gateway details + * @param object $value + * @return $this + */ + public function setGateway($value) + { + if (is_object($value)) + $this->gateway = $value; + else + { + $obj = new NativeAPMTransactionDetailsGateway($this->client); + $obj->fillWithData($value); + $this->gateway = $obj; + } + return $this; + } + + /** + * Get Invoice + * Native APM Invoice details + * @return object + */ + public function getInvoice() + { + return $this->invoice; + } + + /** + * Set Invoice + * Native APM Invoice details + * @param object $value + * @return $this + */ + public function setInvoice($value) + { + if (is_object($value)) + $this->invoice = $value; + else + { + $obj = new NativeAPMTransactionDetailsInvoice($this->client); + $obj->fillWithData($value); + $this->invoice = $obj; + } + return $this; + } + + /** + * Get Parameters + * Native APM Parameter details + * @return array + */ + public function getParameters() + { + return $this->parameters; + } + + /** + * Set Parameters + * Native APM Parameter details + * @param array $value + * @return $this + */ + public function setParameters($value) + { + if (count($value) > 0 && is_object($value[0])) + $this->parameters = $value; + else + { + $a = array(); + foreach ($value as $v) + { + $obj = new NativeAPMParameterDefinition($this->client); + $obj->fillWithData($v); + $a[] = $obj; + } + $this->parameters = $a; + } + return $this; + } + + /** + * Get State + * Native APM Transaction State + * @return string + */ + public function getState() + { + return $this->state; + } + + /** + * Set State + * Native APM Transaction State + * @param string $value + * @return $this + */ + public function setState($value) + { + $this->state = $value; + return $this; + } + + + /** + * Fills the current object with the new values pulled from the data + * @param array $data + * @return NativeAPMTransactionDetails + */ + public function fillWithData($data) + { + if(! empty($data['gateway'])) + $this->setGateway($data['gateway']); + + if(! empty($data['invoice'])) + $this->setInvoice($data['invoice']); + + if(! empty($data['parameters'])) + $this->setParameters($data['parameters']); + + if(! empty($data['state'])) + $this->setState($data['state']); + + return $this; + } + + /** + * Implements the JsonSerializable interface + * @return object + */ + public function jsonSerialize() { + return array( + "gateway" => $this->getGateway(), + "invoice" => $this->getInvoice(), + "parameters" => $this->getParameters(), + "state" => $this->getState(), + ); + } + + +} diff --git a/src/NativeAPMTransactionDetailsGateway.php b/src/NativeAPMTransactionDetailsGateway.php new file mode 100755 index 0000000..d6019ee --- /dev/null +++ b/src/NativeAPMTransactionDetailsGateway.php @@ -0,0 +1,117 @@ +client = $client; + + $this->fillWithData($prefill); + } + + + /** + * Get DisplayName + * Native APM Gateway display name + * @return string + */ + public function getDisplayName() + { + return $this->displayName; + } + + /** + * Set DisplayName + * Native APM Gateway display name + * @param string $value + * @return $this + */ + public function setDisplayName($value) + { + $this->displayName = $value; + return $this; + } + + /** + * Get LogoUrl + * Native APM Gateway logo url + * @return string + */ + public function getLogoUrl() + { + return $this->logoUrl; + } + + /** + * Set LogoUrl + * Native APM Gateway logo url + * @param string $value + * @return $this + */ + public function setLogoUrl($value) + { + $this->logoUrl = $value; + return $this; + } + + + /** + * Fills the current object with the new values pulled from the data + * @param array $data + * @return NativeAPMTransactionDetailsGateway + */ + public function fillWithData($data) + { + if(! empty($data['display_name'])) + $this->setDisplayName($data['display_name']); + + if(! empty($data['logo_url'])) + $this->setLogoUrl($data['logo_url']); + + return $this; + } + + /** + * Implements the JsonSerializable interface + * @return object + */ + public function jsonSerialize() { + return array( + "display_name" => $this->getDisplayName(), + "logo_url" => $this->getLogoUrl(), + ); + } + + +} diff --git a/src/NativeAPMTransactionDetailsInvoice.php b/src/NativeAPMTransactionDetailsInvoice.php new file mode 100755 index 0000000..dc5fc3c --- /dev/null +++ b/src/NativeAPMTransactionDetailsInvoice.php @@ -0,0 +1,117 @@ +client = $client; + + $this->fillWithData($prefill); + } + + + /** + * Get Amount + * Native APM Invoice amount + * @return string + */ + public function getAmount() + { + return $this->amount; + } + + /** + * Set Amount + * Native APM Invoice amount + * @param string $value + * @return $this + */ + public function setAmount($value) + { + $this->amount = $value; + return $this; + } + + /** + * Get CurrencyCode + * Native APM Invoice currency code + * @return string + */ + public function getCurrencyCode() + { + return $this->currencyCode; + } + + /** + * Set CurrencyCode + * Native APM Invoice currency code + * @param string $value + * @return $this + */ + public function setCurrencyCode($value) + { + $this->currencyCode = $value; + return $this; + } + + + /** + * Fills the current object with the new values pulled from the data + * @param array $data + * @return NativeAPMTransactionDetailsInvoice + */ + public function fillWithData($data) + { + if(! empty($data['amount'])) + $this->setAmount($data['amount']); + + if(! empty($data['currency_code'])) + $this->setCurrencyCode($data['currency_code']); + + return $this; + } + + /** + * Implements the JsonSerializable interface + * @return object + */ + public function jsonSerialize() { + return array( + "amount" => $this->getAmount(), + "currency_code" => $this->getCurrencyCode(), + ); + } + + +} diff --git a/src/Networking/Request.php b/src/Networking/Request.php index 4dc75fa..42b8f9d 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.27.0' + 'User-Agent: ProcessOut PHP-Bindings/6.28.0' ); if (! empty($options['idempotencyKey'])) $headers[] = 'Idempotency-Key: ' . $options['idempotencyKey']; diff --git a/src/ProcessOut.php b/src/ProcessOut.php index b68cc3d..140132c 100644 --- a/src/ProcessOut.php +++ b/src/ProcessOut.php @@ -181,6 +181,15 @@ public function newCustomer($prefill = array()) { return new Customer($this, $prefill); } + /** + * Create a new CustomerPhone instance + * @param array|null $prefill array used to prefill the object + * @return CustomerPhone + */ + public function newCustomerPhone($prefill = array()) { + return new CustomerPhone($this, $prefill); + } + /** * Create a new Token instance * @param array|null $prefill array used to prefill the object @@ -235,6 +244,24 @@ public function newInvoice($prefill = array()) { return new Invoice($this, $prefill); } + /** + * Create a new NativeAPMRequest instance + * @param array|null $prefill array used to prefill the object + * @return NativeAPMRequest + */ + public function newNativeAPMRequest($prefill = array()) { + return new NativeAPMRequest($this, $prefill); + } + + /** + * Create a new NativeAPMParameterValue instance + * @param array|null $prefill array used to prefill the object + * @return NativeAPMParameterValue + */ + public function newNativeAPMParameterValue($prefill = array()) { + return new NativeAPMParameterValue($this, $prefill); + } + /** * Create a new InvoiceTax instance * @param array|null $prefill array used to prefill the object @@ -280,6 +307,15 @@ public function newInvoiceShipping($prefill = array()) { return new InvoiceShipping($this, $prefill); } + /** + * Create a new InvoiceShippingPhone instance + * @param array|null $prefill array used to prefill the object + * @return InvoiceShippingPhone + */ + public function newInvoiceShippingPhone($prefill = array()) { + return new InvoiceShippingPhone($this, $prefill); + } + /** * Create a new InvoiceBilling instance * @param array|null $prefill array used to prefill the object @@ -289,6 +325,15 @@ public function newInvoiceBilling($prefill = array()) { return new InvoiceBilling($this, $prefill); } + /** + * Create a new UnsupportedFeatureBypass instance + * @param array|null $prefill array used to prefill the object + * @return UnsupportedFeatureBypass + */ + public function newUnsupportedFeatureBypass($prefill = array()) { + return new UnsupportedFeatureBypass($this, $prefill); + } + /** * Create a new InvoiceDetail instance * @param array|null $prefill array used to prefill the object @@ -361,6 +406,15 @@ public function newProject($prefill = array()) { return new Project($this, $prefill); } + /** + * Create a new ProjectSFTPSettings instance + * @param array|null $prefill array used to prefill the object + * @return ProjectSFTPSettings + */ + public function newProjectSFTPSettings($prefill = array()) { + return new ProjectSFTPSettings($this, $prefill); + } + /** * Create a new Refund instance * @param array|null $prefill array used to prefill the object @@ -388,6 +442,33 @@ public function newTransaction($prefill = array()) { return new Transaction($this, $prefill); } + /** + * Create a new NativeAPMResponse instance + * @param array|null $prefill array used to prefill the object + * @return NativeAPMResponse + */ + public function newNativeAPMResponse($prefill = array()) { + return new NativeAPMResponse($this, $prefill); + } + + /** + * Create a new NativeAPMParameterDefinition instance + * @param array|null $prefill array used to prefill the object + * @return NativeAPMParameterDefinition + */ + public function newNativeAPMParameterDefinition($prefill = array()) { + return new NativeAPMParameterDefinition($this, $prefill); + } + + /** + * Create a new NativeAPMParameterValueDefinition instance + * @param array|null $prefill array used to prefill the object + * @return NativeAPMParameterValueDefinition + */ + public function newNativeAPMParameterValueDefinition($prefill = array()) { + return new NativeAPMParameterValueDefinition($this, $prefill); + } + /** * Create a new ThreeDS instance * @param array|null $prefill array used to prefill the object @@ -451,4 +532,58 @@ public function newWebhookEndpoint($prefill = array()) { return new WebhookEndpoint($this, $prefill); } + /** + * Create a new ErrorCodes instance + * @param array|null $prefill array used to prefill the object + * @return ErrorCodes + */ + public function newErrorCodes($prefill = array()) { + return new ErrorCodes($this, $prefill); + } + + /** + * Create a new CategoryErrorCodes instance + * @param array|null $prefill array used to prefill the object + * @return CategoryErrorCodes + */ + public function newCategoryErrorCodes($prefill = array()) { + return new CategoryErrorCodes($this, $prefill); + } + + /** + * Create a new NativeAPMTransactionDetailsGateway instance + * @param array|null $prefill array used to prefill the object + * @return NativeAPMTransactionDetailsGateway + */ + public function newNativeAPMTransactionDetailsGateway($prefill = array()) { + return new NativeAPMTransactionDetailsGateway($this, $prefill); + } + + /** + * Create a new NativeAPMTransactionDetailsInvoice instance + * @param array|null $prefill array used to prefill the object + * @return NativeAPMTransactionDetailsInvoice + */ + 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); + } + + /** + * 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/ProjectSFTPSettings.php b/src/ProjectSFTPSettings.php new file mode 100755 index 0000000..8c81fc5 --- /dev/null +++ b/src/ProjectSFTPSettings.php @@ -0,0 +1,234 @@ +client = $client; + + $this->fillWithData($prefill); + } + + + /** + * Get Endpoint + * SFTP server endpoint, port is required. + * @return string + */ + public function getEndpoint() + { + return $this->endpoint; + } + + /** + * Set Endpoint + * SFTP server endpoint, port is required. + * @param string $value + * @return $this + */ + public function setEndpoint($value) + { + $this->endpoint = $value; + return $this; + } + + /** + * Get Username + * SFTP server username + * @return string + */ + public function getUsername() + { + return $this->username; + } + + /** + * Set Username + * SFTP server username + * @param string $value + * @return $this + */ + public function setUsername($value) + { + $this->username = $value; + return $this; + } + + /** + * Get Password + * SFTP server password, required when no 'private_key' is passed + * @return string + */ + public function getPassword() + { + return $this->password; + } + + /** + * Set Password + * SFTP server password, required when no 'private_key' is passed + * @param string $value + * @return $this + */ + public function setPassword($value) + { + $this->password = $value; + return $this; + } + + /** + * Get PrivateKey + * SFTP server private key, required when no 'password' is passed + * @return string + */ + public function getPrivateKey() + { + return $this->privateKey; + } + + /** + * Set PrivateKey + * SFTP server private key, required when no 'password' is passed + * @param string $value + * @return $this + */ + public function setPrivateKey($value) + { + $this->privateKey = $value; + return $this; + } + + + /** + * Fills the current object with the new values pulled from the data + * @param array $data + * @return ProjectSFTPSettings + */ + public function fillWithData($data) + { + if(! empty($data['endpoint'])) + $this->setEndpoint($data['endpoint']); + + if(! empty($data['username'])) + $this->setUsername($data['username']); + + if(! empty($data['password'])) + $this->setPassword($data['password']); + + if(! empty($data['private_key'])) + $this->setPrivateKey($data['private_key']); + + return $this; + } + + /** + * Implements the JsonSerializable interface + * @return object + */ + public function jsonSerialize() { + return array( + "endpoint" => $this->getEndpoint(), + "username" => $this->getUsername(), + "password" => $this->getPassword(), + "private_key" => $this->getPrivateKey(), + ); + } + + + /** + * Save the SFTP settings for the project. + * @param string $id + * @param array $options + * @return bool + */ + public function saveSftpSettings($id, $options = array()) + { + $this->fillWithData($options); + + $request = new Request($this->client); + $path = "/projects/" . urlencode($id) . "/sftp-settings"; + + $data = array( + "endpoint" => $this->getEndpoint(), + "username" => $this->getUsername(), + "password" => $this->getPassword(), + "private_key" => $this->getPrivateKey() + ); + + $response = $request->put($path, $data, $options); + $returnValues = array(); + + $returnValues['success'] = $response->isSuccess(); + + return array_values($returnValues)[0]; + } + + /** + * Delete the SFTP settings for the project. + * @param string $id + * @param array $options + * @return bool + */ + public function deleteSftpSettings($id, $options = array()) + { + $this->fillWithData($options); + + $request = new Request($this->client); + $path = "/projects/" . urlencode($id) . "/sftp-settings"; + + $data = array( + + ); + + $response = $request->delete($path, $data, $options); + $returnValues = array(); + + $returnValues['success'] = $response->isSuccess(); + + return array_values($returnValues)[0]; + } + +} diff --git a/src/Refund.php b/src/Refund.php index 766bbae..0eebcd0 100755 --- a/src/Refund.php +++ b/src/Refund.php @@ -409,6 +409,35 @@ public function jsonSerialize() { } + /** + * Create a refund for an invoice. + * @param string $invoiceId + * @param array $options + * @return bool + */ + public function createForInvoice($invoiceId, $options = array()) + { + $this->fillWithData($options); + + $request = new Request($this->client); + $path = "/invoices/" . urlencode($invoiceId) . "/refunds"; + + $data = array( + "amount" => $this->getAmount(), + "reason" => $this->getReason(), + "information" => $this->getInformation(), + "invoice_detail_ids" => $this->getInvoiceDetailIds(), + "metadata" => (!empty($options["metadata"])) ? $options["metadata"] : null + ); + + $response = $request->post($path, $data, $options); + $returnValues = array(); + + $returnValues['success'] = $response->isSuccess(); + + return array_values($returnValues)[0]; + } + /** * Get the transaction's refunds. * @param string $transactionId diff --git a/src/Transaction.php b/src/Transaction.php index 650c75b..9b631ba 100755 --- a/src/Transaction.php +++ b/src/Transaction.php @@ -382,6 +382,18 @@ class Transaction implements \JsonSerializable */ protected $paymentType; + /** + * Native APM response data + * @var object + */ + protected $nativeApm; + + /** + * Additional data about the transaction, originating from a PSP, for example customer shipping address + * @var object + */ + protected $externalDetails; + /** * Transaction constructor * @param ProcessOut\ProcessOut $client @@ -1824,6 +1836,57 @@ public function setPaymentType($value) return $this; } + /** + * Get NativeApm + * Native APM response data + * @return object + */ + public function getNativeApm() + { + return $this->nativeApm; + } + + /** + * Set NativeApm + * Native APM response data + * @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; + } + + /** + * Get ExternalDetails + * Additional data about the transaction, originating from a PSP, for example customer shipping address + * @return object + */ + public function getExternalDetails() + { + return $this->externalDetails; + } + + /** + * Set ExternalDetails + * Additional data about the transaction, originating from a PSP, for example customer shipping address + * @param object $value + * @return $this + */ + public function setExternalDetails($value) + { + $this->externalDetails = $value; + return $this; + } + /** * Fills the current object with the new values pulled from the data @@ -2015,6 +2078,12 @@ public function fillWithData($data) if(! empty($data['payment_type'])) $this->setPaymentType($data['payment_type']); + if(! empty($data['native_apm'])) + $this->setNativeApm($data['native_apm']); + + if(! empty($data['external_details'])) + $this->setExternalDetails($data['external_details']); + return $this; } @@ -2085,6 +2154,8 @@ public function jsonSerialize() { "initial_scheme_transaction_id" => $this->getInitialSchemeTransactionId(), "scheme_id" => $this->getSchemeId(), "payment_type" => $this->getPaymentType(), + "native_apm" => $this->getNativeApm(), + "external_details" => $this->getExternalDetails(), ); } diff --git a/src/UnsupportedFeatureBypass.php b/src/UnsupportedFeatureBypass.php new file mode 100755 index 0000000..d9267ba --- /dev/null +++ b/src/UnsupportedFeatureBypass.php @@ -0,0 +1,85 @@ +client = $client; + + $this->fillWithData($prefill); + } + + + /** + * Get IncrementalAuthorization + * Indicates whether to fallback to normal authorization if incremental is not supported + * @return bool + */ + public function getIncrementalAuthorization() + { + return $this->incrementalAuthorization; + } + + /** + * Set IncrementalAuthorization + * Indicates whether to fallback to normal authorization if incremental is not supported + * @param bool $value + * @return $this + */ + public function setIncrementalAuthorization($value) + { + $this->incrementalAuthorization = $value; + return $this; + } + + + /** + * Fills the current object with the new values pulled from the data + * @param array $data + * @return UnsupportedFeatureBypass + */ + public function fillWithData($data) + { + if(! empty($data['incremental_authorization'])) + $this->setIncrementalAuthorization($data['incremental_authorization']); + + return $this; + } + + /** + * Implements the JsonSerializable interface + * @return object + */ + public function jsonSerialize() { + return array( + "incremental_authorization" => $this->getIncrementalAuthorization(), + ); + } + + +}