From affdfe916c5d0b7d157dc56abe44bd84e7f50207 Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Thu, 1 Oct 2026 10:09:56 -0600 Subject: [PATCH 1/4] feat: add surcharge model and rate surcharges field --- CHANGELOG.md | 1 + lib/EasyPost/Rate.php | 1 + lib/EasyPost/Surcharge.php | 14 ++++++++++++++ lib/EasyPost/Util/InternalUtil.php | 2 ++ lib/easypost.php | 1 + test/EasyPost/EasyPostObjectTest.php | 24 ++++++++++++++++++++++++ 6 files changed, 43 insertions(+) create mode 100644 lib/EasyPost/Surcharge.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e981b8e..64e91b9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Next Release +- Adds `surcharges` to `Rate` with a `Surcharge` model including `category`, `amount`, and `currency` - Removes the deprecated, unusable `addCreditCard` function - Stripe has disabled the ability to pass plain credit card details over the wire and now requires using [Stripe.js/Elements/Checkout](https://support.stripe.com/questions/card-tokenization-restrictions-using-publishable-keys). Follow the [Decentralized (EasyPost-Manage Billing) Guide](https://docs.easypost.com/guides/get-started-with-forge/easypost-managed-billing-guide#referralcustomer-billing-management) for more details on the new flow to use. - Makes `referralCustomer.retrieveEasypostStripeApiKey` public to help facilitate adding credit cards using Stripe.js diff --git a/lib/EasyPost/Rate.php b/lib/EasyPost/Rate.php index b717e5d2..930d4c31 100644 --- a/lib/EasyPost/Rate.php +++ b/lib/EasyPost/Rate.php @@ -20,6 +20,7 @@ * @property int $delivery_days * @property string $delivery_date * @property bool $delivery_date_guaranteed + * @property Surcharge[] $surcharges * @property string $created_at * @property string $updated_at */ diff --git a/lib/EasyPost/Surcharge.php b/lib/EasyPost/Surcharge.php new file mode 100644 index 00000000..422830ae --- /dev/null +++ b/lib/EasyPost/Surcharge.php @@ -0,0 +1,14 @@ + Shipment::class, 'ShipmentInvoiceReport' => Report::class, 'ShipmentReport' => Report::class, + 'Surcharge' => Surcharge::class, 'TaxIdentifier' => TaxIdentifier::class, 'Tracker' => Tracker::class, 'TrackerReport' => Report::class, diff --git a/lib/easypost.php b/lib/easypost.php index 90d15d52..3e902c73 100644 --- a/lib/easypost.php +++ b/lib/easypost.php @@ -82,6 +82,7 @@ require_once(dirname(__FILE__) . '/EasyPost/Report.php'); require_once(dirname(__FILE__) . '/EasyPost/ScanForm.php'); require_once(dirname(__FILE__) . '/EasyPost/Shipment.php'); +require_once(dirname(__FILE__) . '/EasyPost/Surcharge.php'); require_once(dirname(__FILE__) . '/EasyPost/TaxIdentifier.php'); require_once(dirname(__FILE__) . '/EasyPost/Tracker.php'); require_once(dirname(__FILE__) . '/EasyPost/TrackingDetail.php'); diff --git a/test/EasyPost/EasyPostObjectTest.php b/test/EasyPost/EasyPostObjectTest.php index 2db4fdb2..1361ec41 100644 --- a/test/EasyPost/EasyPostObjectTest.php +++ b/test/EasyPost/EasyPostObjectTest.php @@ -3,6 +3,7 @@ namespace EasyPost\Test; use EasyPost\EasyPostClient; +use EasyPost\Surcharge; use EasyPost\Util\InternalUtil; use PHPUnit\Framework\TestCase; @@ -63,4 +64,27 @@ public function testPrintObject(): void "phone": "5555555555" }'); } + + /** + * Test that Rate surcharges hydrate to Surcharge model objects. + */ + public function testRateSurchargesHydrate(): void + { + $rate = InternalUtil::convertToEasyPostObject(self::$client, [ + 'id' => 'rate_123', + 'object' => 'Rate', + 'surcharges' => [ + [ + 'object' => 'Surcharge', + 'category' => 'residential_delivery', + 'amount' => '1.23', + 'currency' => 'USD', + ], + ], + ]); + + $this->assertCount(1, $rate->surcharges); + $this->assertInstanceOf(Surcharge::class, $rate->surcharges[0]); + $this->assertSame('residential_delivery', $rate->surcharges[0]->category); + } } From 356e1c390d79c23429ca5e8ae4571e5d47ee86e3 Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Thu, 1 Oct 2026 10:11:12 -0600 Subject: [PATCH 2/4] fix: align surcharge keys and remove added test --- lib/EasyPost/Surcharge.php | 3 +++ test/EasyPost/EasyPostObjectTest.php | 24 ------------------------ 2 files changed, 3 insertions(+), 24 deletions(-) diff --git a/lib/EasyPost/Surcharge.php b/lib/EasyPost/Surcharge.php index 422830ae..93e85a73 100644 --- a/lib/EasyPost/Surcharge.php +++ b/lib/EasyPost/Surcharge.php @@ -5,8 +5,11 @@ /** * @package EasyPost * @property string $object + * @property string $type * @property string $category * @property string $amount + * @property string $list_amount + * @property string $retail_amount * @property string $currency */ class Surcharge extends EasyPostObject diff --git a/test/EasyPost/EasyPostObjectTest.php b/test/EasyPost/EasyPostObjectTest.php index 1361ec41..2db4fdb2 100644 --- a/test/EasyPost/EasyPostObjectTest.php +++ b/test/EasyPost/EasyPostObjectTest.php @@ -3,7 +3,6 @@ namespace EasyPost\Test; use EasyPost\EasyPostClient; -use EasyPost\Surcharge; use EasyPost\Util\InternalUtil; use PHPUnit\Framework\TestCase; @@ -64,27 +63,4 @@ public function testPrintObject(): void "phone": "5555555555" }'); } - - /** - * Test that Rate surcharges hydrate to Surcharge model objects. - */ - public function testRateSurchargesHydrate(): void - { - $rate = InternalUtil::convertToEasyPostObject(self::$client, [ - 'id' => 'rate_123', - 'object' => 'Rate', - 'surcharges' => [ - [ - 'object' => 'Surcharge', - 'category' => 'residential_delivery', - 'amount' => '1.23', - 'currency' => 'USD', - ], - ], - ]); - - $this->assertCount(1, $rate->surcharges); - $this->assertInstanceOf(Surcharge::class, $rate->surcharges[0]); - $this->assertSame('residential_delivery', $rate->surcharges[0]->category); - } } From 585165485d0f6e917adc4fae97454bed1c87f066 Mon Sep 17 00:00:00 2001 From: Justin Hammond Date: Thu, 1 Oct 2026 10:13:31 -0600 Subject: [PATCH 3/4] Update CHANGELOG for surcharges and function removal Updated the changelog to reflect the addition of surcharges to Rate and the removal of the deprecated addCreditCard function. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64e91b9e..991824ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Next Release -- Adds `surcharges` to `Rate` with a `Surcharge` model including `category`, `amount`, and `currency` +- Adds `surcharges` to `Rate` and a `Surcharge` model - Removes the deprecated, unusable `addCreditCard` function - Stripe has disabled the ability to pass plain credit card details over the wire and now requires using [Stripe.js/Elements/Checkout](https://support.stripe.com/questions/card-tokenization-restrictions-using-publishable-keys). Follow the [Decentralized (EasyPost-Manage Billing) Guide](https://docs.easypost.com/guides/get-started-with-forge/easypost-managed-billing-guide#referralcustomer-billing-management) for more details on the new flow to use. - Makes `referralCustomer.retrieveEasypostStripeApiKey` public to help facilitate adding credit cards using Stripe.js From 706d8383bc24836f8ccd976bee47473715264033 Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Thu, 1 Oct 2026 10:20:03 -0600 Subject: [PATCH 4/4] fix: lint --- lib/EasyPost/Surcharge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/EasyPost/Surcharge.php b/lib/EasyPost/Surcharge.php index 93e85a73..05ea1292 100644 --- a/lib/EasyPost/Surcharge.php +++ b/lib/EasyPost/Surcharge.php @@ -14,4 +14,4 @@ */ class Surcharge extends EasyPostObject { -} \ No newline at end of file +}