Skip to content

Commit

Permalink
Releasing v3.28.0. Please check the changelog for the updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
cb-alish committed May 28, 2024
1 parent f7f8d9e commit 55bcc67
Show file tree
Hide file tree
Showing 17 changed files with 208 additions and 24 deletions.
57 changes: 57 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,60 @@
### v3.28.0 (2024-05-28)
* * *

### New Feature
* Ability to access response headers in case of API failure is added.


#### New resources:
* BusinessEntity has been added.
* BusinessEntity Transfer has been added.


#### New Enum values:
* NUVEI has been added in Gateway enum.


#### New Attributes:
* site_details_at_creation has been added to CreditNote.
* site_details_at_creation has been added to Invoice.


#### New Input parameters:
* tax_providers_fields[provider_name] has been added to Addon#CreateRequest, Addon#UpdateRequest.
* tax_providers_fields[field_id] has been added to Addon#CreateRequest, Addon#UpdateRequest.
* tax_providers_fields[field_value] has been added to Addon#CreateRequest, #UpdateRequest.

* tax_providers_fields[provider_name] has been added to Customer#CreateRequest, Customer#UpdateRequest, Customer#MoveRequest.
* tax_providers_fields[field_id] has been added to Customer#CreateRequest, Customer#UpdateRequest, Customer#MoveRequest.
* tax_providers_fields[field_value] has been added to Customer#CreateRequest, Customer#UpdateRequest, Customer#MoveRequest..

* tax_providers_fields[provider_name] has been added to Estimate#CreateSubscriptionRequest, Estimate#CreateSubItemEstimateRequest, Estimate#CreateInvoiceRequest, CreateInvoiceForItemsRequest.
* tax_providers_fields[field_id] has been added to Estimate#CreateSubscriptionRequest, Estimate#CreateSubItemEstimateRequest, Estimate#CreateInvoiceRequest, CreateInvoiceForItemsRequest.
* tax_providers_fields[field_value] has been added to Estimate#CreateSubscriptionRequest, Estimate#CreateSubItemEstimateRequest, Estimate#CreateInvoiceRequest, CreateInvoiceForItemsRequest.

* tax_providers_fields[provider_name] has been added to Invoice#CreateRequest, Invoice#CreateForChargeItemsAndChargesRequest, Invoice#ChargeRequest.
* tax_providers_fields[field_id] has been added to Invoice#CreateRequest, Invoice#CreateForChargeItemsAndChargesRequest, Invoice#ChargeRequest.
* tax_providers_fields[field_value] has been added to Invoice#CreateRequest, Invoice#CreateForChargeItemsAndChargesRequest, Invoice#ChargeRequest.

* tax_providers_fields[provider_name] has been added to ItemPrice#CreateRequest, ItemPrice#UpdateRequest.
* tax_providers_fields[field_id] has been added to ItemPrice#CreateRequest, ItemPrice#UpdateRequest.
* tax_providers_fields[field_value] has been added to ItemPrice#CreateRequest, ItemPrice#UpdateRequest.

* tax_providers_fields[provider_name] has been added to Plan#CreateRequest, Plan#UpdateRequest.
* tax_providers_fields[field_id] has been added to Plan#CreateRequest, Plan#UpdateRequest.
* tax_providers_fields[field_value] has been added to Plan#CreateRequest, Plan#UpdateRequest.

* tax_providers_fields[provider_name] has been added to Quote#EditOneTimeQuoteRequest, Quote#CreateForOnetimeChargesRequest, Quote#CreateForChargeItemsAndChargesRequest, Quote#EditForChargeItemsAndChargesRequest.
* tax_providers_fields[field_id] has been added to Quote#EditOneTimeQuoteRequest, Quote#CreateForOnetimeChargesRequest, Quote#CreateForChargeItemsAndChargesRequest, Quote#EditForChargeItemsAndChargesRequest.
* tax_providers_fields[field_value] has been added to Quote#EditOneTimeQuoteRequest, Quote#CreateForOnetimeChargesRequest, Quote#CreateForChargeItemsAndChargesRequest, Quote#EditForChargeItemsAndChargesRequest.

* tax_providers_fields[provider_name] has been added to UnbilledCharge#CreateUnbilledChargeRequest, UnbilledCharge#CreateRequest.
* tax_providers_fields[field_id] has been added to UnbilledCharge#CreateUnbilledChargeRequest, UnbilledCharge#CreateRequest.
* tax_providers_fields[field_value] has been added to UnbilledCharge#CreateUnbilledChargeRequest, UnbilledCharge#CreateRequest.

* line_items[entity_type] has been added to CreditNote#CreateRequest.
* line_items[entity_id] has been added to CreditNote#CreateRequest.

### v3.27.2(2024-05-28)
***

Expand Down
9 changes: 7 additions & 2 deletions lib/ChargeBee/Exceptions/APIError.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class APIError extends Exception
private $type;
private $apiErrorCode;
private $param;

public function __construct($httpStatusCode, $jsonObject)
private $headers;
public function __construct($httpStatusCode, $jsonObject, $responseHeaders)
{
parent::__construct($jsonObject['message']);

Expand All @@ -21,6 +21,7 @@ public function __construct($httpStatusCode, $jsonObject)
$this->apiErrorCode = $jsonObject['api_error_code'];
$this->param = isset($jsonObject['param']) ? $jsonObject['param'] : null;
$this->httpStatusCode = $httpStatusCode;
$this->headers = $responseHeaders;
}

public function getHttpStatusCode()
Expand Down Expand Up @@ -66,4 +67,8 @@ public function getJsonObject()
{
return $this->jsonObject;
}
public function getHeaders()
{
return $this->headers;
}
}
4 changes: 2 additions & 2 deletions lib/ChargeBee/Exceptions/InvalidRequestException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

class InvalidRequestException extends APIError
{
public function __construct($httpStatusCode, $jsonObject)
public function __construct($httpStatusCode, $jsonObject, $responseHeaders)
{
parent::__construct($httpStatusCode, $jsonObject);
parent::__construct($httpStatusCode, $jsonObject, $responseHeaders);
}
}
4 changes: 2 additions & 2 deletions lib/ChargeBee/Exceptions/OperationFailedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

class OperationFailedException extends APIError
{
public function __construct($httpStatusCode, $jsonObject)
public function __construct($httpStatusCode, $jsonObject, $responseHeaders)
{
parent::__construct($httpStatusCode, $jsonObject);
parent::__construct($httpStatusCode, $jsonObject, $responseHeaders);
}
}
4 changes: 2 additions & 2 deletions lib/ChargeBee/Exceptions/PaymentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

class PaymentException extends APIError
{
public function __construct($httpStatusCode, $jsonObject)
public function __construct($httpStatusCode, $jsonObject, $responseHeaders)
{
parent::__construct($httpStatusCode, $jsonObject);
parent::__construct($httpStatusCode, $jsonObject, $responseHeaders);
}
}
2 changes: 1 addition & 1 deletion lib/ChargeBee/HttpClient/GuzzleFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ public function createRequest($meth, $headers, $env, $url, $params)

return new \GuzzleHttp\Psr7\Request($meth, $uri, $httpHeaders, $body);
}
}
}
2 changes: 1 addition & 1 deletion lib/ChargeBee/HttpClient/HttpClientFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ public function createClient();
* @return RequestInterface
*/
public function createRequest($meth, $headers, $env, $url, $params);
}
}
39 changes: 39 additions & 0 deletions lib/ChargeBee/Models/BusinessEntity.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace ChargeBee\ChargeBee\Models;

use ChargeBee\ChargeBee\Model;
use ChargeBee\ChargeBee\Request;
use ChargeBee\ChargeBee\Util;

class BusinessEntity extends Model
{

protected $allowed = [
'id',
'name',
'status',
'deleted',
'createdAt',
'resourceVersion',
'updatedAt',
];



# OPERATIONS
#-----------

public static function createTransfers($params, $env = null, $headers = array())
{
return Request::send(Request::POST, Util::encodeURIPath("business_entities","transfers"), $params, $env, $headers);
}

public static function getTransfers($params = array(), $env = null, $headers = array())
{
return Request::send(Request::GET, Util::encodeURIPath("business_entities","transfers"), $params, $env, $headers);
}

}

?>
30 changes: 30 additions & 0 deletions lib/ChargeBee/Models/BusinessEntityTransfer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace ChargeBee\ChargeBee\Models;

use ChargeBee\ChargeBee\Model;
use ChargeBee\ChargeBee\Request;
use ChargeBee\ChargeBee\Util;

class BusinessEntityTransfer extends Model
{

protected $allowed = [
'id',
'resourceType',
'resourceId',
'activeResourceId',
'destinationBusinessEntityId',
'sourceBusinessEntityId',
'reasonCode',
'createdAt',
];



# OPERATIONS
#-----------

}

?>
1 change: 1 addition & 0 deletions lib/ChargeBee/Models/CreditNote.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class CreditNote extends Model
'businessEntityId',
'shippingAddress',
'billingAddress',
'siteDetailsAtCreation',
];


Expand Down
16 changes: 16 additions & 0 deletions lib/ChargeBee/Models/CreditNoteSiteDetailsAtCreation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace ChargeBee\ChargeBee\Models;

use ChargeBee\ChargeBee\Model;

class CreditNoteSiteDetailsAtCreation extends Model
{
protected $allowed = [
'timezone',
'organizationAddress',
];

}

?>
1 change: 1 addition & 0 deletions lib/ChargeBee/Models/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class Invoice extends Model
'vatNumberPrefix',
'channel',
'businessEntityId',
'siteDetailsAtCreation',
];


Expand Down
16 changes: 16 additions & 0 deletions lib/ChargeBee/Models/InvoiceSiteDetailsAtCreation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace ChargeBee\ChargeBee\Models;

use ChargeBee\ChargeBee\Model;

class InvoiceSiteDetailsAtCreation extends Model
{
protected $allowed = [
'timezone',
'organizationAddress',
];

}

?>
16 changes: 8 additions & 8 deletions lib/ChargeBee/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private static function doRequest($meth, $url, $env, $params = array(), $headers
throw new IOException($message, $errno);
}

$respJson = self::processResponse((string)$clientResponse->getBody(), $clientResponse->getStatusCode());
$respJson = self::processResponse((string)$clientResponse->getBody(), $clientResponse->getStatusCode(), $clientResponse->getHeaders());
return new Response($respJson, $clientResponse->getHeaders());
}

Expand All @@ -80,7 +80,7 @@ private static function doRequest($meth, $url, $env, $params = array(), $headers
* @throws OperationFailedException
* @throws PaymentException
*/
public static function processResponse($response, $httpCode)
public static function processResponse($response, $httpCode, $headers)
{
$respJson = json_decode($response, true);
if (!$respJson) {
Expand All @@ -92,7 +92,7 @@ public static function processResponse($response, $httpCode)
throw new Exception("Sorry, something went wrong when trying to process the request. If this problem persists, contact us at [email protected]. \n type: internal_error, \n http_status_code: 500, \n error_code: internal_error ");
}
if ($httpCode < 200 || $httpCode > 299) {
self::handleAPIRespError($httpCode, $respJson, $response);
self::handleAPIRespError($httpCode, $respJson, $response, $headers);
}
return $respJson;
}
Expand All @@ -107,7 +107,7 @@ public static function processResponse($response, $httpCode)
* @throws OperationFailedException
* @throws PaymentException
*/
public static function handleAPIRespError($httpCode, $respJson, $response)
public static function handleAPIRespError($httpCode, $respJson, $response, $headers)
{
if (!isset($respJson['api_error_code'])) {
throw new Exception("No api_error_code attribute in content. Probably not a ChargeBee's error response. The content is \n " . $response);
Expand All @@ -117,13 +117,13 @@ public static function handleAPIRespError($httpCode, $respJson, $response)
$type = $respJson['type'];
}
if ($type == "payment") {
throw new PaymentException($httpCode, $respJson);
throw new PaymentException($httpCode, $respJson, $headers);
} elseif ($type == "operation_failed") {
throw new OperationFailedException($httpCode, $respJson);
throw new OperationFailedException($httpCode, $respJson, $headers);
} elseif ($type == "invalid_request") {
throw new InvalidRequestException($httpCode, $respJson);
throw new InvalidRequestException($httpCode, $respJson, $headers);
} else {
throw new APIError($httpCode, $respJson);
throw new APIError($httpCode, $respJson, $headers);
}
}

Expand Down
24 changes: 20 additions & 4 deletions lib/ChargeBee/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ public function contact()
return $contact;
}

public function businessEntityTransfer()
{
$business_entity_transfer = $this->_get('business_entity_transfer', Models\BusinessEntityTransfer::class);
return $business_entity_transfer;
}

public function token()
{
$token = $this->_get('token', Models\Token::class);
Expand Down Expand Up @@ -173,7 +179,8 @@ public function invoice()
'shipping_address' => Models\InvoiceShippingAddress::class,
'statement_descriptor' => Models\InvoiceStatementDescriptor::class,
'billing_address' => Models\InvoiceBillingAddress::class,
'einvoice' => Models\InvoiceEinvoice::class
'einvoice' => Models\InvoiceEinvoice::class,
'site_details_at_creation' => Models\InvoiceSiteDetailsAtCreation::class
));
return $invoice;
}
Expand Down Expand Up @@ -204,7 +211,8 @@ public function creditNote()
'linked_refunds' => Models\CreditNoteLinkedRefund::class,
'allocations' => Models\CreditNoteAllocation::class,
'shipping_address' => Models\CreditNoteShippingAddress::class,
'billing_address' => Models\CreditNoteBillingAddress::class
'billing_address' => Models\CreditNoteBillingAddress::class,
'site_details_at_creation' => Models\CreditNoteSiteDetailsAtCreation::class
));
return $credit_note;
}
Expand Down Expand Up @@ -647,6 +655,12 @@ public function entitlementOverride()
return $entitlement_override;
}

public function businessEntity()
{
$business_entity = $this->_get('business_entity', Models\BusinessEntity::class);
return $business_entity;
}

public function purchase()
{
$purchase = $this->_get('purchase', Models\Purchase::class);
Expand Down Expand Up @@ -737,7 +751,8 @@ public function invoices()
'shipping_address' => Models\InvoiceShippingAddress::class,
'statement_descriptor' => Models\InvoiceStatementDescriptor::class,
'billing_address' => Models\InvoiceBillingAddress::class,
'einvoice' => Models\InvoiceEinvoice::class
'einvoice' => Models\InvoiceEinvoice::class,
'site_details_at_creation' => Models\InvoiceSiteDetailsAtCreation::class
));
return $invoices;
}
Expand Down Expand Up @@ -766,7 +781,8 @@ public function creditNotes()
'linked_refunds' => Models\CreditNoteLinkedRefund::class,
'allocations' => Models\CreditNoteAllocation::class,
'shipping_address' => Models\CreditNoteShippingAddress::class,
'billing_address' => Models\CreditNoteBillingAddress::class
'billing_address' => Models\CreditNoteBillingAddress::class,
'site_details_at_creation' => Models\CreditNoteSiteDetailsAtCreation::class
));
return $credit_notes;
}
Expand Down
3 changes: 1 addition & 2 deletions lib/ChargeBee/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

final class Version
{

const VERSION = '3.27.2';
const VERSION = '3.28.0';
}

?>
Loading

0 comments on commit 55bcc67

Please sign in to comment.