Skip to content

Commit

Permalink
feat: add support to metadata on transaction operations
Browse files Browse the repository at this point in the history
  • Loading branch information
processout-machine committed Jul 26, 2022
1 parent dc59fae commit 4f175fb
Show file tree
Hide file tree
Showing 8 changed files with 162 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The package's installation is done using composer. Simply add these lines to you
```json
{
"require": {
"processout/processout-php": "^6.21.0"
"processout/processout-php": "^6.22.0"
}
}
```
Expand Down
24 changes: 24 additions & 0 deletions src/AlternativeMerchantCertificate.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,28 @@ public function save($options = array())
return array_values($returnValues)[0];
}

/**
* Delete a given alternative merchant certificate
* @param array $options
* @return bool
*/
public function delete($options = array())
{
$this->fillWithData($options);

$request = new Request($this->client);
$path = "/projects/applepay/alternative-merchant-certificates/" . urlencode($this->getId()) . "";

$data = array(

);

$response = $request->delete($path, $data, $options);
$returnValues = array();

$returnValues['success'] = $response->isSuccess();

return array_values($returnValues)[0];
}

}
32 changes: 32 additions & 0 deletions src/ApplePayAlternativeMerchantCertificates.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ class ApplePayAlternativeMerchantCertificates implements \JsonSerializable
*/
protected $client;

/**
* number of alternative merchant certificate
* @var decimal
*/
protected $count;

/**
* Alternative merchant certificates available
* @var list
Expand All @@ -35,6 +41,28 @@ public function __construct(ProcessOut $client, $prefill = array())
}


/**
* Get Count
* number of alternative merchant certificate
* @return string
*/
public function getCount()
{
return $this->count;
}

/**
* Set Count
* number of alternative merchant certificate
* @param string $value
* @return $this
*/
public function setCount($value)
{
$this->count = $value;
return $this;
}

/**
* Get AlternativeMerchantCertificates
* Alternative merchant certificates available
Expand Down Expand Up @@ -77,6 +105,9 @@ public function setAlternativeMerchantCertificates($value)
*/
public function fillWithData($data)
{
if(! empty($data['count']))
$this->setCount($data['count']);

if(! empty($data['alternative_merchant_certificates']))
$this->setAlternativeMerchantCertificates($data['alternative_merchant_certificates']);

Expand All @@ -89,6 +120,7 @@ public function fillWithData($data)
*/
public function jsonSerialize() {
return array(
"count" => $this->getCount(),
"alternative_merchant_certificates" => $this->getAlternativeMerchantCertificates(),
);
}
Expand Down
32 changes: 32 additions & 0 deletions src/Balance.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ class Balance implements \JsonSerializable
*/
protected $currency;

/**
* Expiry time of the voucher
* @var string
*/
protected $expiry;

/**
* Balance constructor
* @param ProcessOut\ProcessOut $client
Expand Down Expand Up @@ -85,6 +91,28 @@ public function setCurrency($value)
return $this;
}

/**
* Get Expiry
* Expiry time of the voucher
* @return string
*/
public function getExpiry()
{
return $this->expiry;
}

/**
* Set Expiry
* Expiry time of the voucher
* @param string $value
* @return $this
*/
public function setExpiry($value)
{
$this->expiry = $value;
return $this;
}


/**
* Fills the current object with the new values pulled from the data
Expand All @@ -99,6 +127,9 @@ public function fillWithData($data)
if(! empty($data['currency']))
$this->setCurrency($data['currency']);

if(! empty($data['expiry']))
$this->setExpiry($data['expiry']);

return $this;
}

Expand All @@ -110,6 +141,7 @@ public function jsonSerialize() {
return array(
"amount" => $this->getAmount(),
"currency" => $this->getCurrency(),
"expiry" => $this->getExpiry(),
);
}

Expand Down
40 changes: 38 additions & 2 deletions src/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,12 @@ class Invoice implements \JsonSerializable
*/
protected $tax;

/**
* Payment type
* @var string
*/
protected $paymentType;

/**
* Invoice constructor
* @param ProcessOut\ProcessOut $client
Expand Down Expand Up @@ -1203,6 +1209,28 @@ public function setTax($value)
return $this;
}

/**
* Get PaymentType
* Payment type
* @return string
*/
public function getPaymentType()
{
return $this->paymentType;
}

/**
* Set PaymentType
* Payment type
* @param string $value
* @return $this
*/
public function setPaymentType($value)
{
$this->paymentType = $value;
return $this;
}


/**
* Fills the current object with the new values pulled from the data
Expand Down Expand Up @@ -1328,6 +1356,9 @@ public function fillWithData($data)
if(! empty($data['tax']))
$this->setTax($data['tax']);

if(! empty($data['payment_type']))
$this->setPaymentType($data['payment_type']);

return $this;
}

Expand Down Expand Up @@ -1376,6 +1407,7 @@ public function jsonSerialize() {
"challenge_indicator" => $this->getChallengeIndicator(),
"incremental" => $this->getIncremental(),
"tax" => $this->getTax(),
"payment_type" => $this->getPaymentType(),
);
}

Expand All @@ -1394,6 +1426,7 @@ public function incrementAuthorization($amount, $options = array())
$path = "/invoices/" . urlencode($this->getId()) . "/increment_authorization";

$data = array(
"metadata" => (!empty($options["metadata"])) ? $options["metadata"] : null,
"amount" => $amount
);

Expand Down Expand Up @@ -1432,6 +1465,7 @@ public function authorize($source, $options = array())
"capture_amount" => (!empty($options["capture_amount"])) ? $options["capture_amount"] : null,
"enable_three_d_s_2" => (!empty($options["enable_three_d_s_2"])) ? $options["enable_three_d_s_2"] : null,
"auto_capture_at" => (!empty($options["auto_capture_at"])) ? $options["auto_capture_at"] : null,
"metadata" => (!empty($options["metadata"])) ? $options["metadata"] : null,
"source" => $source
);

Expand Down Expand Up @@ -1471,6 +1505,7 @@ public function capture($source, $options = array())
"capture_amount" => (!empty($options["capture_amount"])) ? $options["capture_amount"] : null,
"auto_capture_at" => (!empty($options["auto_capture_at"])) ? $options["auto_capture_at"] : null,
"enable_three_d_s_2" => (!empty($options["enable_three_d_s_2"])) ? $options["enable_three_d_s_2"] : null,
"metadata" => (!empty($options["metadata"])) ? $options["metadata"] : null,
"source" => $source
);

Expand Down Expand Up @@ -1624,7 +1659,7 @@ public function void($options = array())
$path = "/invoices/" . urlencode($this->getId()) . "/void";

$data = array(

"metadata" => (!empty($options["metadata"])) ? $options["metadata"] : null
);

$response = $request->post($path, $data, $options);
Expand Down Expand Up @@ -1712,7 +1747,8 @@ public function create($options = array())
"device" => $this->getDevice(),
"require_backend_capture" => $this->getRequireBackendCapture(),
"external_fraud_tools" => $this->getExternalFraudTools(),
"tax" => $this->getTax()
"tax" => $this->getTax(),
"payment_type" => $this->getPaymentType()
);

$response = $request->post($path, $data, $options);
Expand Down
32 changes: 32 additions & 0 deletions src/InvoiceShipping.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ class InvoiceShipping implements \JsonSerializable
*/
protected $expectsShippingAt;

/**
* Relay store name
* @var string
*/
protected $relayStoreName;

/**
* InvoiceShipping constructor
* @param ProcessOut\ProcessOut $client
Expand Down Expand Up @@ -365,6 +371,28 @@ public function setExpectsShippingAt($value)
return $this;
}

/**
* Get RelayStoreName
* Relay store name
* @return string
*/
public function getRelayStoreName()
{
return $this->relayStoreName;
}

/**
* Set RelayStoreName
* Relay store name
* @param string $value
* @return $this
*/
public function setRelayStoreName($value)
{
$this->relayStoreName = $value;
return $this;
}


/**
* Fills the current object with the new values pulled from the data
Expand Down Expand Up @@ -409,6 +437,9 @@ public function fillWithData($data)
if(! empty($data['expects_shipping_at']))
$this->setExpectsShippingAt($data['expects_shipping_at']);

if(! empty($data['relay_store_name']))
$this->setRelayStoreName($data['relay_store_name']);

return $this;
}

Expand All @@ -430,6 +461,7 @@ public function jsonSerialize() {
"zip" => $this->getZip(),
"phone_number" => $this->getPhoneNumber(),
"expects_shipping_at" => $this->getExpectsShippingAt(),
"relay_store_name" => $this->getRelayStoreName(),
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Networking/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.21.0'
'User-Agent: ProcessOut PHP-Bindings/6.22.0'
);
if (! empty($options['idempotencyKey']))
$headers[] = 'Idempotency-Key: ' . $options['idempotencyKey'];
Expand Down
4 changes: 2 additions & 2 deletions src/Refund.php
Original file line number Diff line number Diff line change
Expand Up @@ -488,10 +488,10 @@ public function create($options = array())

$data = array(
"amount" => $this->getAmount(),
"metadata" => $this->getMetadata(),
"reason" => $this->getReason(),
"information" => $this->getInformation(),
"invoice_detail_ids" => $this->getInvoiceDetailIds()
"invoice_detail_ids" => $this->getInvoiceDetailIds(),
"metadata" => (!empty($options["metadata"])) ? $options["metadata"] : null
);

$response = $request->post($path, $data, $options);
Expand Down

0 comments on commit 4f175fb

Please sign in to comment.