Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Register an EndShipper before buying EasyPost labels
Damian Legawiec101b3799cb0b
diff --git a/spree/core/config/locales/en.yml b/spree/core/config/locales/en.ymlindex d3c28e3897..eae690690b 100644--- a/spree/core/config/locales/en.yml+++ b/spree/core/config/locales/en.yml@@ -963,12 +963,12 @@ en:cannot_fulfill: This fulfillment cannot be fulfilled in its current statuscannot_mark_delivered: Only a fulfilled shipment can be marked deliveredcannot_purchase_label: Labels can only be bought before the fulfillment ships- label_purchase_failed: The label could not be purchased — check the carrier connection and try againcannot_resume: This fulfillment cannot be resumed in its current statusinsufficient_quantity: Requested quantity (%{requested}) for item %{item} exceeds its unfulfilled quantity (%{available})invalid_cost: cost must be a non-negative numberinvalid_quantity: Quantity for item %{item} must be a positive integerinvalid_status: status must be 'shipped' when provided+ label_purchase_failed: The label could not be purchased — check the carrier connection and try againno_items_to_fulfill: Order has no unfulfilled itemsnot_in_fulfillment: Requested quantity (%{requested}) for item %{item} exceeds the %{available} held by this fulfillmentorder_canceled: Fulfillments cannot be created on a canceled orderdiff --git a/spree/providers/easypost/app/models/spree_easypost/fulfillment_provider.rb b/spree/providers/easypost/app/models/spree_easypost/fulfillment_provider.rbindex 708887802d..18ac496172 100644--- a/spree/providers/easypost/app/models/spree_easypost/fulfillment_provider.rb+++ b/spree/providers/easypost/app/models/spree_easypost/fulfillment_provider.rb@@ -79,7 +79,7 @@ module SpreeEasyPostrate_id = quoted['easypost_rate_id']return if shipment_id.blank? || rate_id.blank?- integration.client.shipment.buy(shipment_id, rate: { id: rate_id })+ buy(integration, fulfillment, shipment_id, rate_id)rescue EasyPost::Errors::EasyPostErrornilend@@ -101,7 +101,31 @@ module SpreeEasyPostendreturn if rate.nil?- integration.client.shipment.buy(shipment.id, rate: { id: rate.id })+ buy(integration, fulfillment, shipment.id, rate.id)+ end++ # Labels bought on EasyPost's own carrier accounts (USPS) require an+ # EndShipper — the legally responsible shipping party. Created fresh per+ # purchase so it always matches the current warehouse address; label buys+ # are rare enough that caching one would only buy staleness. When the+ # mandatory contact fields cannot be assembled the purchase proceeds+ # without one, and carriers that insist reject with their own message.+ def buy(integration, fulfillment, shipment_id, rate_id)+ buy_params = { rate: { id: rate_id } }+ end_shipper_id = end_shipper_id(integration, fulfillment)+ buy_params[:end_shipper_id] = end_shipper_id if end_shipper_id.present?++ integration.client.shipment.buy(shipment_id, **buy_params)+ end++ def end_shipper_id(integration, fulfillment)+ params = SpreeEasyPost.end_shipper_params(fulfillment.stock_location, fulfillment.order&.store)+ return if params.nil?++ integration.client.end_shipper.create(**params).id+ rescue EasyPost::Errors::EasyPostError => e+ report(e, fulfillment)+ nilenddef requote_parcel(fulfillment)diff --git a/spree/providers/easypost/lib/spree_easypost.rb b/spree/providers/easypost/lib/spree_easypost.rbindex 01b8c0ec96..da7df4da28 100644--- a/spree/providers/easypost/lib/spree_easypost.rb+++ b/spree/providers/easypost/lib/spree_easypost.rb@@ -95,4 +95,27 @@ module SpreeEasyPostsource.try(:name)end++ # EndShipper payload — the party legally responsible for the shipment,+ # required when buying labels on EasyPost's own carrier accounts (USPS+ # refuses the purchase without one). Unlike a plain address, EasyPost+ # makes every field mandatory here including phone and email, so the+ # store's contact details fill in what the stock location does not carry.+ #+ # @param stock_location [Spree::StockLocation, nil]+ # @param store [Spree::Store, nil]+ # @return [Hash, nil] nil when the mandatory fields cannot be assembled+ def self.end_shipper_params(stock_location, store)+ return if stock_location.nil?++ params = address_params(stock_location)+ params[:phone] = stock_location.phone.presence || store&.contact_phone.presence+ params[:email] = store&.mail_from_address.presence || store&.customer_support_email.presence++ mandatory = params.values_at(:street1, :city, :state, :zip, :country, :phone, :email)+ mandatory << (params[:name].presence || params[:company].presence)+ return if mandatory.any?(&:blank?)++ params.compact_blank+ endenddiff --git a/spree/providers/easypost/spec/models/spree_easypost/fulfillment_provider_spec.rb b/spree/providers/easypost/spec/models/spree_easypost/fulfillment_provider_spec.rbindex 94083df4e2..cea9d313c3 100644--- a/spree/providers/easypost/spec/models/spree_easypost/fulfillment_provider_spec.rb+++ b/spree/providers/easypost/spec/models/spree_easypost/fulfillment_provider_spec.rb@@ -70,13 +70,20 @@ RSpec.describe SpreeEasyPost::FulfillmentProvider do)endlet(:shipment_service) { double }- let(:client) { instance_double(EasyPost::Client, shipment: shipment_service) }+ let(:end_shipper_service) { double }+ let(:client) do+ instance_double(EasyPost::Client, shipment: shipment_service, end_shipper: end_shipper_service)+ end- before { allow_any_instance_of(SpreeEasyPost::Integration).to receive(:client).and_return(client) }+ before do+ allow_any_instance_of(SpreeEasyPost::Integration).to receive(:client).and_return(client)+ allow(end_shipper_service).to receive(:create).and_return(double(id: 'es_test1'))+ endit 'buys the rate quoted at checkout and hands back tracking' doallow(shipment_service).to receive(:buy).- with('shp_recorded1', rate: { id: 'rate_recorded1' }).and_return(purchased_shipment)+ with('shp_recorded1', rate: { id: 'rate_recorded1' }, end_shipper_id: 'es_test1').+ and_return(purchased_shipment)result = provider.create_fulfillment(fulfillment)@@ -97,7 +104,7 @@ RSpec.describe SpreeEasyPost::FulfillmentProvider dobefore doallow(shipment_service).to receive(:buy).- with('shp_recorded1', rate: { id: 'rate_recorded1' }).+ with('shp_recorded1', rate: { id: 'rate_recorded1' }, end_shipper_id: 'es_test1').and_raise(EasyPost::Errors::EasyPostError.new('rate expired'))allow(shipment_service).to receive(:create).and_return(fresh_shipment)# The selected rate carries the carrier service the customer chose —@@ -107,7 +114,8 @@ RSpec.describe SpreeEasyPost::FulfillmentProvider doit 'requotes and buys the matching service' doallow(shipment_service).to receive(:buy).- with('shp_fresh', rate: { id: 'rate_fresh' }).and_return(purchased_shipment)+ with('shp_fresh', rate: { id: 'rate_fresh' }, end_shipper_id: 'es_test1').+ and_return(purchased_shipment)result = provider.create_fulfillment(fulfillment)@@ -121,6 +129,48 @@ RSpec.describe SpreeEasyPost::FulfillmentProvider doendend+ # Labels on EasyPost's own carrier accounts refuse to buy without an+ # EndShipper, and EasyPost mandates contact fields a stock location+ # does not carry — the store's details fill the gap.+ it 'registers an end shipper from the warehouse with store contact fallbacks' do+ allow(shipment_service).to receive(:buy).and_return(purchased_shipment)++ provider.create_fulfillment(fulfillment)++ expect(end_shipper_service).to have_received(:create).with(+ hash_including(+ name: fulfillment.stock_location.name,+ phone: fulfillment.stock_location.phone,+ email: store.mail_from_address+ )+ )+ end++ it 'buys without an end shipper when the contact details cannot be assembled' do+ fulfillment.stock_location.update_columns(phone: nil)+ store.update_columns(contact_phone: nil)+ allow(shipment_service).to receive(:buy).+ with('shp_recorded1', rate: { id: 'rate_recorded1' }).and_return(purchased_shipment)++ result = provider.create_fulfillment(fulfillment)++ expect(result[:tracking_number]).to be_present+ expect(end_shipper_service).not_to have_received(:create)+ end++ # An end-shipper hiccup must not lose the label — the buy proceeds bare+ # and only carriers that insist on one reject it, with their message.+ it 'degrades to a bare buy when the end shipper cannot be registered' do+ allow(end_shipper_service).to receive(:create).+ and_raise(EasyPost::Errors::EasyPostError.new('nope'))+ allow(Rails.error).to receive(:report)+ allow(shipment_service).to receive(:buy).+ with('shp_recorded1', rate: { id: 'rate_recorded1' }).and_return(purchased_shipment)++ expect(provider.create_fulfillment(fulfillment)[:tracking_number]).to be_present+ expect(Rails.error).to have_received(:report)+ end+# Runs inside the ship transition — a purchase failure must degrade to# "no label yet", never break the fulfillment.it 'reports and returns empty on an API failure' do@@ -171,9 +221,8 @@ RSpec.describe SpreeEasyPost::FulfillmentProvider do# calls against EasyPost's wire format. Ids come from the recorded rate# quote so a re-record against any account stays self-consistent.describe 'API contract (VCR)' do- # Priority specifically: USPS GroundAdvantage requires an EasyPost- # end-shipper record that test accounts do not have by default, so- # buying it fails for reasons unrelated to this gem.+ # USPS purchases demand an EndShipper; the provider registers one from+ # the warehouse before buying, so any recorded USPS service works.let(:recorded_rate) dorates = recorded_ratesrates.find { |rate| rate['service'] == 'Priority' } || rates.firstdiff --git a/spree/providers/easypost/spec/vcr/buy_shipment.yml b/spree/providers/easypost/spec/vcr/buy_shipment.ymlindex 0621eccda3..74f4b99908 100644--- a/spree/providers/easypost/spec/vcr/buy_shipment.yml+++ b/spree/providers/easypost/spec/vcr/buy_shipment.yml@@ -2,24 +2,154 @@http_interactions:- request:method: post- uri: https://api.easypost.com/v2/shipments/shp_recorded1/buy+ uri: https://api.easypost.com/v2/end_shippersbody:encoding: UTF-8- string: '{"rate":{"id":"rate_recorded1"}}'+ string: '{"address":{"name":"Misti Gusikowski","street1":"1600 Pennsylvania+ Ave NW","city":"Washington","state":"NY","zip":"20500","country":"US","phone":"(202)+ 456-1111","email":"[email protected]"}}'headers:+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ User-Agent:+ - EasyPost/v2 RubyClient/7.7.0 Ruby/4.0.1-p0 OS/Darwin OSVersion/23 OSArch/arm64+ Host:+ - api.easypost.com+ Content-Type:+ - application/jsonAuthorization:- "<FILTERED>"+ response:+ status:+ code: 201+ message: Created+ headers:+ X-Frame-Options:+ - SAMEORIGIN+ X-Xss-Protection:+ - 1; mode=block+ X-Content-Type-Options:+ - nosniff+ X-Download-Options:+ - noopen+ X-Permitted-Cross-Domain-Policies:+ - none+ Referrer-Policy:+ - strict-origin-when-cross-origin+ Easypost-Api-Version:+ - '2015-01-01'+ Vary:+ - EasyPost-Api-Version+ X-Ep-Request-Uuid:+ - d7dd9a7c6a7c0c9fff099078029abef6+ Cache-Control:+ - private, no-cache, no-store+ Pragma:+ - no-cache+ Expires:+ - '0'+ Content-Type:+ - application/json; charset=utf-8+ X-Runtime:+ - '0.078979'+ Transfer-Encoding:+ - chunked+ X-Node:+ - bigweb65nuq+ X-Version-Label:+ - easypost-202608112128-93a53ffd35-main+ X-Backend:+ - easypost+ X-Proxied:+ - extlb2nuq 1318c68dc0+ - intlb4nuq d4a20a271b+ Strict-Transport-Security:+ - max-age=31536000; includeSubDomains; preload+ body:+ encoding: ASCII-8BIT+ string: '{"id":"es_95a49f4842ae4c54a9dafe885e1972b2","object":"EndShipper","mode":"test","created_at":"2026-08-12T06:03:11Z","updated_at":"2026-08-12T06:03:11Z","name":"MISTI+ GUSIKOWSKI","company":null,"street1":"1600 PENNSYLVANIA AVE NW","street2":"","city":"WASHINGTON","state":"DC","zip":"20500-0005","country":"US","phone":"(202)+ 456-1111","email":"[email protected]"}'+ recorded_at: Wed, 12 Aug 2026 06:03:11 GMT+- request:+ method: post+ uri: https://api.easypost.com/v2/shipments/shp_cee0847ebff344afa39c7d106cc0c61f/buy+ body:+ encoding: UTF-8+ string: '{"rate":{"id":"rate_4f5c3b0240b34dbab6e5d5405ca26e39"},"end_shipper_id":"es_95a49f4842ae4c54a9dafe885e1972b2"}'+ headers:+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ User-Agent:+ - EasyPost/v2 RubyClient/7.7.0 Ruby/4.0.1-p0 OS/Darwin OSVersion/23 OSArch/arm64+ Host:+ - api.easypost.comContent-Type:- application/json+ Authorization:+ - "<FILTERED>"response:status:code: 200message: OKheaders:+ X-Frame-Options:+ - SAMEORIGIN+ X-Xss-Protection:+ - 1; mode=block+ X-Content-Type-Options:+ - nosniff+ X-Download-Options:+ - noopen+ X-Permitted-Cross-Domain-Policies:+ - none+ Referrer-Policy:+ - strict-origin-when-cross-origin+ Easypost-Api-Version:+ - '2015-01-01'+ Vary:+ - EasyPost-Api-Version+ X-Ep-Request-Uuid:+ - d7dd9a816a7c0c9fff09907b029ac018+ Cache-Control:+ - private, no-cache, no-store+ Pragma:+ - no-cache+ Expires:+ - '0'Content-Type:- application/json; charset=utf-8+ X-Runtime:+ - '0.983074'+ Transfer-Encoding:+ - chunked+ X-Node:+ - bigweb40nuq+ X-Version-Label:+ - easypost-202608112128-93a53ffd35-main+ X-Backend:+ - easypost+ X-Proxied:+ - extlb2nuq 1318c68dc0+ - intlb5nuq d4a20a271b+ Strict-Transport-Security:+ - max-age=31536000; includeSubDomains; preloadbody:- encoding: UTF-8- string: '{"id":"shp_recorded1","object":"Shipment","mode":"test","status":"purchased","tracking_code":"9405500207552012345678","created_at":"2026-08-06T12:00:00Z","updated_at":"2026-08-06T12:05:00Z","selected_rate":{"id":"rate_recorded1","object":"Rate","carrier":"USPS","service":"Priority","rate":"7.33","currency":"USD"},"postage_label":{"id":"pl_recorded1","object":"PostageLabel","label_url":"https://easypost-files.s3.amazonaws.com/files/postage_label/recorded1.png","label_file_type":"image/png"},"tracker":{"id":"trk_recorded1","object":"Tracker","tracking_code":"9405500207552012345678","public_url":"https://track.easypost.com/djE7recorded1","status":"pre_transit"},"rates":[]}'- recorded_at: Thu, 06 Aug 2026 20:05:00 GMT-recorded_with: VCR 6.3.1+ encoding: ASCII-8BIT+ string: '{"id":"shp_cee0847ebff344afa39c7d106cc0c61f","created_at":"2026-08-12T06:03:08Z","is_return":false,"messages":[{"carrier":"DhlEcs","carrier_account_id":"ca_50b23cff99b0466cb2353f60ad06784f","type":"rate_error","message":"shipment.options.merchant_id+ is required"},{"carrier":"USAExportPBA","carrier_account_id":"ca_7e87ab81fe1543e4a77ec08ad656f3e9","type":"rate_error","message":"shipment:+ [''shipment.from_address.country: This carrier only support shipments from+ US origins to international destinations.'']"},{"carrier":"CanadaPost","carrier_account_id":"ca_93986cf850124be29b73034d165ff3a1","type":"rate_error","message":"[''Unable+ to get rates for shipments originating outside of Canada.'']"}],"mode":"test","options":{"currency":"USD","payment":{"type":"SENDER"},"date_advance":0},"reference":null,"status":"unknown","tracking_code":"9405500208303121182853","updated_at":"2026-08-12T06:03:12Z","batch_id":null,"batch_status":null,"batch_message":null,"customs_info":null,"from_address":{"id":"adr_7daf1806961311f19d94002248041e50","object":"Address","created_at":"2026-08-12T06:03:08Z","updated_at":"2026-08-12T06:03:08Z","name":"Eryn+ Hermann","company":null,"street1":"1600 Pennsylvania Ave NW","street2":null,"city":"Washington","state":"NY","zip":"20500","country":"US","phone":"2024561111","email":null,"mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":{}},"insurance":"50.00","order_id":null,"parcel":{"id":"prcl_acf0a535cc644786b2cecbfea4972ef2","object":"Parcel","weight":0.1,"length":null,"width":null,"height":null,"predefined_package":null,"mode":"test","created_at":"2026-08-12T06:03:08Z","updated_at":"2026-08-12T06:03:08Z"},"postage_label":{"object":"PostageLabel","id":"pl_69113b2eea454fd7adb7a347e9c02a4e","created_at":"2026-08-12T06:03:12Z","updated_at":"2026-08-12T06:03:12Z","date_advance":0,"integrated_form":"none","label_date":"2026-08-12T06:03:12Z","label_resolution":300,"label_size":"4x6","label_type":"default","label_file_type":"image/png","label_url":"https://easypost-files.s3.us-west-2.amazonaws.com/files/postage_label/20260812/e8e75bce9899194c0f8828753f933f4423.png","label_pdf_url":null,"label_zpl_url":null,"label_epl2_url":null,"label_file":null},"rates":[{"id":"rate_56d4f605ab11469fb552c34d65e59995","object":"Rate","created_at":"2026-08-12T06:03:09Z","updated_at":"2026-08-12T06:03:09Z","mode":"test","service":"Express","carrier":"USPS","rate":"31.86","currency":"USD","retail_rate":"36.00","retail_currency":"USD","list_rate":"31.86","list_currency":"USD","billing_type":"easypost","delivery_days":1,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":1,"shipment_id":"shp_cee0847ebff344afa39c7d106cc0c61f","carrier_account_id":"ca_f1a0e5c2799243bba037f8169b0c41de"},{"id":"rate_4f5c3b0240b34dbab6e5d5405ca26e39","object":"Rate","created_at":"2026-08-12T06:03:09Z","updated_at":"2026-08-12T06:03:09Z","mode":"test","service":"Priority","carrier":"USPS","rate":"8.60","currency":"USD","retail_rate":"11.65","retail_currency":"USD","list_rate":"9.71","list_currency":"USD","billing_type":"easypost","delivery_days":2,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":2,"shipment_id":"shp_cee0847ebff344afa39c7d106cc0c61f","carrier_account_id":"ca_f1a0e5c2799243bba037f8169b0c41de"},{"id":"rate_3fd3f1f9457b49b595b3c86038c9ba40","object":"Rate","created_at":"2026-08-12T06:03:09Z","updated_at":"2026-08-12T06:03:09Z","mode":"test","service":"GroundAdvantage","carrier":"USPS","rate":"5.28","currency":"USD","retail_rate":"8.15","retail_currency":"USD","list_rate":"7.30","list_currency":"USD","billing_type":"easypost","delivery_days":2,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":2,"shipment_id":"shp_cee0847ebff344afa39c7d106cc0c61f","carrier_account_id":"ca_f1a0e5c2799243bba037f8169b0c41de"},{"id":"rate_2f2b5a24a41c4cb7b5b12306538f0aef","object":"Rate","created_at":"2026-08-12T06:03:09Z","updated_at":"2026-08-12T06:03:09Z","mode":"test","service":"SMART_POST","carrier":"FedExDefault","rate":"10.31","currency":"USD","retail_rate":null,"retail_currency":null,"list_rate":"19.96","list_currency":"USD","billing_type":"easypost","delivery_days":2,"delivery_date":"2026-08-14T23:59:00Z","delivery_date_guaranteed":true,"est_delivery_days":2,"shipment_id":"shp_cee0847ebff344afa39c7d106cc0c61f","carrier_account_id":"ca_1787f888698d448bad8103e361f82d4a"}],"refund_status":null,"scan_form":null,"selected_rate":{"id":"rate_4f5c3b0240b34dbab6e5d5405ca26e39","object":"Rate","created_at":"2026-08-12T06:03:12Z","updated_at":"2026-08-12T06:03:12Z","mode":"test","service":"Priority","carrier":"USPS","rate":"8.60","currency":"USD","retail_rate":"11.65","retail_currency":"USD","list_rate":"9.71","list_currency":"USD","billing_type":"easypost","delivery_days":2,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":2,"shipment_id":"shp_cee0847ebff344afa39c7d106cc0c61f","carrier_account_id":"ca_f1a0e5c2799243bba037f8169b0c41de"},"tracker":{"id":"trk_4fc05a35edd64cbd899a2be3d9f764b2","object":"Tracker","mode":"test","tracking_code":"9405500208303121182853","status":"unknown","status_detail":"unknown","created_at":"2026-08-12T06:03:12Z","updated_at":"2026-08-12T06:03:12Z","signed_by":null,"weight":null,"est_delivery_date":null,"shipment_id":"shp_cee0847ebff344afa39c7d106cc0c61f","carrier":"USPS","tracking_details":[],"fees":[],"carrier_detail":null,"delivery_evidence":[],"public_url":"https://track.easypost.com/djE6dHJrXzRmYzA1YTM1ZWRkNjRjYmQ4OTlhMmJlM2Q5Zjc2NGIy"},"to_address":{"id":"adr_7daf17b6961311f19d93002248041e50","object":"Address","created_at":"2026-08-12T06:03:08Z","updated_at":"2026-08-12T06:03:08Z","name":"John+ Doe","company":"Company","street1":"15 Lovely Street","street2":"Northwest","city":"New+ York","state":"NY","zip":"10118","country":"US","phone":"5555550199","email":null,"mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":{}},"usps_zone":3,"return_address":{"id":"adr_7daf1806961311f19d94002248041e50","object":"Address","created_at":"2026-08-12T06:03:08Z","updated_at":"2026-08-12T06:03:08Z","name":"Eryn+ Hermann","company":null,"street1":"1600 Pennsylvania Ave NW","street2":null,"city":"Washington","state":"NY","zip":"20500","country":"US","phone":"2024561111","email":null,"mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":{}},"buyer_address":{"id":"adr_7daf17b6961311f19d93002248041e50","object":"Address","created_at":"2026-08-12T06:03:08Z","updated_at":"2026-08-12T06:03:08Z","name":"John+ Doe","company":"Company","street1":"15 Lovely Street","street2":"Northwest","city":"New+ York","state":"NY","zip":"10118","country":"US","phone":"5555550199","email":null,"mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":{}},"forms":[],"fees":[{"object":"Fee","type":"LabelFee","amount":"0.00000","charged":true,"refunded":false},{"object":"Fee","type":"PostageFee","amount":"8.60000","charged":true,"refunded":false},{"object":"Fee","type":"InsuranceFee","amount":"1.00000","charged":true,"refunded":false}],"object":"Shipment"}'+ recorded_at: Wed, 12 Aug 2026 06:03:12 GMT+recorded_with: VCR 6.4.0diff --git a/spree/providers/easypost/spec/vcr/create_shipment_rates.yml b/spree/providers/easypost/spec/vcr/create_shipment_rates.ymlindex 16d4a4e731..0e8babea4f 100644--- a/spree/providers/easypost/spec/vcr/create_shipment_rates.yml+++ b/spree/providers/easypost/spec/vcr/create_shipment_rates.yml@@ -5,21 +5,83 @@ http_interactions:uri: https://api.easypost.com/v2/shipmentsbody:encoding: UTF-8- string: '{"shipment":{}}'+ string: '{"shipment":{"from_address":{"name":"Eryn Hermann","street1":"1600+ Pennsylvania Ave NW","city":"Washington","state":"NY","zip":"20500","country":"US","phone":"(202)+ 456-1111"},"to_address":{"name":"John Doe","company":"Company","street1":"15+ Lovely Street","street2":"Northwest","city":"New York","state":"NY","zip":"10118","country":"US","phone":"555-555-0199"},"parcel":{"weight":0.1}}}'headers:- Authorization:- - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ User-Agent:+ - EasyPost/v2 RubyClient/7.7.0 Ruby/4.0.1-p0 OS/Darwin OSVersion/23 OSArch/arm64+ Host:+ - api.easypost.comContent-Type:- application/json+ Authorization:+ - "<FILTERED>"response:status:code: 201message: Createdheaders:+ X-Frame-Options:+ - SAMEORIGIN+ X-Xss-Protection:+ - 1; mode=block+ X-Content-Type-Options:+ - nosniff+ X-Download-Options:+ - noopen+ X-Permitted-Cross-Domain-Policies:+ - none+ Referrer-Policy:+ - strict-origin-when-cross-origin+ Easypost-Api-Version:+ - '2015-01-01'+ Vary:+ - EasyPost-Api-Version+ X-Ep-Request-Uuid:+ - d7dd9a826a7c0c9cff099059029ab9eb+ Cache-Control:+ - private, no-cache, no-store+ Pragma:+ - no-cache+ Expires:+ - '0'+ Location:+ - "/api/v2/shipments/shp_cee0847ebff344afa39c7d106cc0c61f"Content-Type:- application/json; charset=utf-8+ X-Runtime:+ - '0.963787'+ Transfer-Encoding:+ - chunked+ X-Node:+ - bigweb58nuq+ X-Version-Label:+ - easypost-202608112128-93a53ffd35-main+ X-Backend:+ - easypost+ X-Proxied:+ - extlb2nuq 1318c68dc0+ - intlb6nuq d4a20a271b+ Strict-Transport-Security:+ - max-age=31536000; includeSubDomains; preloadbody:- encoding: UTF-8- string: '{"id":"shp_recorded1","object":"Shipment","mode":"test","status":"unknown","created_at":"2026-08-06T12:00:00Z","updated_at":"2026-08-06T12:00:00Z","rates":[{"id":"rate_recorded1","object":"Rate","mode":"test","service":"Priority","carrier":"USPS","rate":"7.33","currency":"USD","retail_rate":"10.20","delivery_days":2,"delivery_date":"2026-08-08T00:00:00Z","delivery_date_guaranteed":false,"shipment_id":"shp_recorded1","carrier_account_id":"ca_recorded1"},{"id":"rate_recorded2","object":"Rate","mode":"test","service":"Ground","carrier":"UPS","rate":"8.99","currency":"USD","retail_rate":"12.50","delivery_days":3,"delivery_date":null,"delivery_date_guaranteed":false,"shipment_id":"shp_recorded1","carrier_account_id":"ca_recorded2"}]}'- recorded_at: Thu, 06 Aug 2026 20:00:00 GMT-recorded_with: VCR 6.3.1+ encoding: ASCII-8BIT+ string: '{"id":"shp_cee0847ebff344afa39c7d106cc0c61f","created_at":"2026-08-12T06:03:08Z","is_return":false,"messages":[{"carrier":"DhlEcs","carrier_account_id":"ca_50b23cff99b0466cb2353f60ad06784f","type":"rate_error","message":"shipment.options.merchant_id+ is required"},{"carrier":"USAExportPBA","carrier_account_id":"ca_7e87ab81fe1543e4a77ec08ad656f3e9","type":"rate_error","message":"shipment:+ [''shipment.from_address.country: This carrier only support shipments from+ US origins to international destinations.'']"},{"carrier":"CanadaPost","carrier_account_id":"ca_93986cf850124be29b73034d165ff3a1","type":"rate_error","message":"[''Unable+ to get rates for shipments originating outside of Canada.'']"}],"mode":"test","options":{"currency":"USD","payment":{"type":"SENDER"},"date_advance":0},"reference":null,"status":"unknown","tracking_code":null,"updated_at":"2026-08-12T06:03:09Z","batch_id":null,"batch_status":null,"batch_message":null,"customs_info":null,"from_address":{"id":"adr_7daf1806961311f19d94002248041e50","object":"Address","created_at":"2026-08-12T06:03:08Z","updated_at":"2026-08-12T06:03:08Z","name":"Eryn+ Hermann","company":null,"street1":"1600 Pennsylvania Ave NW","street2":null,"city":"Washington","state":"NY","zip":"20500","country":"US","phone":"2024561111","email":null,"mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":{}},"insurance":null,"order_id":null,"parcel":{"id":"prcl_acf0a535cc644786b2cecbfea4972ef2","object":"Parcel","weight":0.1,"length":null,"width":null,"height":null,"predefined_package":null,"mode":"test","created_at":"2026-08-12T06:03:08Z","updated_at":"2026-08-12T06:03:08Z"},"postage_label":null,"rates":[{"id":"rate_56d4f605ab11469fb552c34d65e59995","object":"Rate","created_at":"2026-08-12T06:03:09Z","updated_at":"2026-08-12T06:03:09Z","mode":"test","service":"Express","carrier":"USPS","rate":"31.86","currency":"USD","retail_rate":"36.00","retail_currency":"USD","list_rate":"31.86","list_currency":"USD","billing_type":"easypost","delivery_days":1,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":1,"shipment_id":"shp_cee0847ebff344afa39c7d106cc0c61f","carrier_account_id":"ca_f1a0e5c2799243bba037f8169b0c41de"},{"id":"rate_4f5c3b0240b34dbab6e5d5405ca26e39","object":"Rate","created_at":"2026-08-12T06:03:09Z","updated_at":"2026-08-12T06:03:09Z","mode":"test","service":"Priority","carrier":"USPS","rate":"8.60","currency":"USD","retail_rate":"11.65","retail_currency":"USD","list_rate":"9.71","list_currency":"USD","billing_type":"easypost","delivery_days":2,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":2,"shipment_id":"shp_cee0847ebff344afa39c7d106cc0c61f","carrier_account_id":"ca_f1a0e5c2799243bba037f8169b0c41de"},{"id":"rate_3fd3f1f9457b49b595b3c86038c9ba40","object":"Rate","created_at":"2026-08-12T06:03:09Z","updated_at":"2026-08-12T06:03:09Z","mode":"test","service":"GroundAdvantage","carrier":"USPS","rate":"5.28","currency":"USD","retail_rate":"8.15","retail_currency":"USD","list_rate":"7.30","list_currency":"USD","billing_type":"easypost","delivery_days":2,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":2,"shipment_id":"shp_cee0847ebff344afa39c7d106cc0c61f","carrier_account_id":"ca_f1a0e5c2799243bba037f8169b0c41de"},{"id":"rate_2f2b5a24a41c4cb7b5b12306538f0aef","object":"Rate","created_at":"2026-08-12T06:03:09Z","updated_at":"2026-08-12T06:03:09Z","mode":"test","service":"SMART_POST","carrier":"FedExDefault","rate":"10.31","currency":"USD","retail_rate":null,"retail_currency":null,"list_rate":"19.96","list_currency":"USD","billing_type":"easypost","delivery_days":2,"delivery_date":"2026-08-14T23:59:00Z","delivery_date_guaranteed":true,"est_delivery_days":2,"shipment_id":"shp_cee0847ebff344afa39c7d106cc0c61f","carrier_account_id":"ca_1787f888698d448bad8103e361f82d4a"}],"refund_status":null,"scan_form":null,"selected_rate":null,"tracker":null,"to_address":{"id":"adr_7daf17b6961311f19d93002248041e50","object":"Address","created_at":"2026-08-12T06:03:08Z","updated_at":"2026-08-12T06:03:08Z","name":"John+ Doe","company":"Company","street1":"15 Lovely Street","street2":"Northwest","city":"New+ York","state":"NY","zip":"10118","country":"US","phone":"5555550199","email":null,"mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":{}},"usps_zone":3,"return_address":{"id":"adr_7daf1806961311f19d94002248041e50","object":"Address","created_at":"2026-08-12T06:03:08Z","updated_at":"2026-08-12T06:03:08Z","name":"Eryn+ Hermann","company":null,"street1":"1600 Pennsylvania Ave NW","street2":null,"city":"Washington","state":"NY","zip":"20500","country":"US","phone":"2024561111","email":null,"mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":{}},"buyer_address":{"id":"adr_7daf17b6961311f19d93002248041e50","object":"Address","created_at":"2026-08-12T06:03:08Z","updated_at":"2026-08-12T06:03:08Z","name":"John+ Doe","company":"Company","street1":"15 Lovely Street","street2":"Northwest","city":"New+ York","state":"NY","zip":"10118","country":"US","phone":"5555550199","email":null,"mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":{}},"forms":[],"fees":[],"object":"Shipment"}'+ recorded_at: Wed, 12 Aug 2026 06:03:09 GMT+recorded_with: VCR 6.4.0diff --git a/spree/providers/easypost/spec/vcr/refund_shipment.yml b/spree/providers/easypost/spec/vcr/refund_shipment.ymlindex 6b97e68024..b44249196a 100644--- a/spree/providers/easypost/spec/vcr/refund_shipment.yml+++ b/spree/providers/easypost/spec/vcr/refund_shipment.yml@@ -2,24 +2,86 @@http_interactions:- request:method: post- uri: https://api.easypost.com/v2/shipments/shp_recorded1/refund+ uri: https://api.easypost.com/v2/shipments/shp_cee0847ebff344afa39c7d106cc0c61f/refundbody:encoding: UTF-8- string: '{}'+ string: "{}"headers:- Authorization:- - "<FILTERED>"+ Accept-Encoding:+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3+ Accept:+ - "*/*"+ User-Agent:+ - EasyPost/v2 RubyClient/7.7.0 Ruby/4.0.1-p0 OS/Darwin OSVersion/23 OSArch/arm64+ Host:+ - api.easypost.comContent-Type:- application/json+ Authorization:+ - "<FILTERED>"response:status:code: 200message: OKheaders:+ X-Frame-Options:+ - SAMEORIGIN+ X-Xss-Protection:+ - 1; mode=block+ X-Content-Type-Options:+ - nosniff+ X-Download-Options:+ - noopen+ X-Permitted-Cross-Domain-Policies:+ - none+ Referrer-Policy:+ - strict-origin-when-cross-origin+ Easypost-Api-Version:+ - '2015-01-01'+ Vary:+ - EasyPost-Api-Version+ X-Ep-Request-Uuid:+ - d7dd9a7c6a7c0ccdff099472029b1f54+ Cache-Control:+ - private, no-cache, no-store+ Pragma:+ - no-cache+ Expires:+ - '0'Content-Type:- application/json; charset=utf-8+ X-Runtime:+ - '0.218185'+ Transfer-Encoding:+ - chunked+ X-Node:+ - bigweb57nuq+ X-Version-Label:+ - easypost-202608112128-93a53ffd35-main+ X-Backend:+ - easypost+ X-Proxied:+ - extlb2nuq 1318c68dc0+ - intlb4nuq d4a20a271b+ Strict-Transport-Security:+ - max-age=31536000; includeSubDomains; preloadbody:- encoding: UTF-8- string: '{"id":"shp_recorded1","object":"Shipment","mode":"test","status":"purchased","refund_status":"submitted","rates":[]}'- recorded_at: Thu, 06 Aug 2026 20:06:00 GMT-recorded_with: VCR 6.3.1+ encoding: ASCII-8BIT+ string: '{"id":"shp_cee0847ebff344afa39c7d106cc0c61f","created_at":"2026-08-12T06:03:08Z","is_return":false,"messages":[{"carrier":"DhlEcs","carrier_account_id":"ca_50b23cff99b0466cb2353f60ad06784f","type":"rate_error","message":"shipment.options.merchant_id+ is required"},{"carrier":"USAExportPBA","carrier_account_id":"ca_7e87ab81fe1543e4a77ec08ad656f3e9","type":"rate_error","message":"shipment:+ [''shipment.from_address.country: This carrier only support shipments from+ US origins to international destinations.'']"},{"carrier":"CanadaPost","carrier_account_id":"ca_93986cf850124be29b73034d165ff3a1","type":"rate_error","message":"[''Unable+ to get rates for shipments originating outside of Canada.'']"}],"mode":"test","options":{"currency":"USD","payment":{"type":"SENDER"},"date_advance":0},"reference":null,"status":"unknown","tracking_code":"9405500208303121182853","updated_at":"2026-08-12T06:03:57Z","batch_id":null,"batch_status":null,"batch_message":null,"customs_info":null,"from_address":{"id":"adr_7daf1806961311f19d94002248041e50","object":"Address","created_at":"2026-08-12T06:03:08Z","updated_at":"2026-08-12T06:03:08Z","name":"Eryn+ Hermann","company":null,"street1":"1600 Pennsylvania Ave NW","street2":null,"city":"Washington","state":"NY","zip":"20500","country":"US","phone":"2024561111","email":null,"mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":{}},"insurance":"50.00","order_id":null,"parcel":{"id":"prcl_acf0a535cc644786b2cecbfea4972ef2","object":"Parcel","weight":0.1,"length":null,"width":null,"height":null,"predefined_package":null,"mode":"test","created_at":"2026-08-12T06:03:08Z","updated_at":"2026-08-12T06:03:08Z"},"postage_label":{"object":"PostageLabel","id":"pl_69113b2eea454fd7adb7a347e9c02a4e","created_at":"2026-08-12T06:03:12Z","updated_at":"2026-08-12T06:03:12Z","date_advance":0,"integrated_form":"none","label_date":"2026-08-12T06:03:12Z","label_resolution":300,"label_size":"4x6","label_type":"default","label_file_type":"image/png","label_url":"https://easypost-files.s3.us-west-2.amazonaws.com/files/postage_label/20260812/e8e75bce9899194c0f8828753f933f4423.png","label_pdf_url":null,"label_zpl_url":null,"label_epl2_url":null,"label_file":null},"rates":[{"id":"rate_56d4f605ab11469fb552c34d65e59995","object":"Rate","created_at":"2026-08-12T06:03:09Z","updated_at":"2026-08-12T06:03:09Z","mode":"test","service":"Express","carrier":"USPS","rate":"31.86","currency":"USD","retail_rate":"36.00","retail_currency":"USD","list_rate":"31.86","list_currency":"USD","billing_type":"easypost","delivery_days":1,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":1,"shipment_id":"shp_cee0847ebff344afa39c7d106cc0c61f","carrier_account_id":"ca_f1a0e5c2799243bba037f8169b0c41de"},{"id":"rate_4f5c3b0240b34dbab6e5d5405ca26e39","object":"Rate","created_at":"2026-08-12T06:03:09Z","updated_at":"2026-08-12T06:03:09Z","mode":"test","service":"Priority","carrier":"USPS","rate":"8.60","currency":"USD","retail_rate":"11.65","retail_currency":"USD","list_rate":"9.71","list_currency":"USD","billing_type":"easypost","delivery_days":2,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":2,"shipment_id":"shp_cee0847ebff344afa39c7d106cc0c61f","carrier_account_id":"ca_f1a0e5c2799243bba037f8169b0c41de"},{"id":"rate_3fd3f1f9457b49b595b3c86038c9ba40","object":"Rate","created_at":"2026-08-12T06:03:09Z","updated_at":"2026-08-12T06:03:09Z","mode":"test","service":"GroundAdvantage","carrier":"USPS","rate":"5.28","currency":"USD","retail_rate":"8.15","retail_currency":"USD","list_rate":"7.30","list_currency":"USD","billing_type":"easypost","delivery_days":2,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":2,"shipment_id":"shp_cee0847ebff344afa39c7d106cc0c61f","carrier_account_id":"ca_f1a0e5c2799243bba037f8169b0c41de"},{"id":"rate_2f2b5a24a41c4cb7b5b12306538f0aef","object":"Rate","created_at":"2026-08-12T06:03:09Z","updated_at":"2026-08-12T06:03:09Z","mode":"test","service":"SMART_POST","carrier":"FedExDefault","rate":"10.31","currency":"USD","retail_rate":null,"retail_currency":null,"list_rate":"19.96","list_currency":"USD","billing_type":"easypost","delivery_days":2,"delivery_date":"2026-08-14T23:59:00Z","delivery_date_guaranteed":true,"est_delivery_days":2,"shipment_id":"shp_cee0847ebff344afa39c7d106cc0c61f","carrier_account_id":"ca_1787f888698d448bad8103e361f82d4a"}],"refund_status":"submitted","scan_form":null,"selected_rate":{"id":"rate_4f5c3b0240b34dbab6e5d5405ca26e39","object":"Rate","created_at":"2026-08-12T06:03:12Z","updated_at":"2026-08-12T06:03:12Z","mode":"test","service":"Priority","carrier":"USPS","rate":"8.60","currency":"USD","retail_rate":"11.65","retail_currency":"USD","list_rate":"9.71","list_currency":"USD","billing_type":"easypost","delivery_days":2,"delivery_date":null,"delivery_date_guaranteed":false,"est_delivery_days":2,"shipment_id":"shp_cee0847ebff344afa39c7d106cc0c61f","carrier_account_id":"ca_f1a0e5c2799243bba037f8169b0c41de"},"tracker":{"id":"trk_4fc05a35edd64cbd899a2be3d9f764b2","object":"Tracker","mode":"test","tracking_code":"9405500208303121182853","status":"pre_transit","status_detail":"status_update","created_at":"2026-08-12T06:03:12Z","updated_at":"2026-08-12T06:03:12Z","signed_by":null,"weight":null,"est_delivery_date":"2026-08-12T06:03:12Z","shipment_id":"shp_cee0847ebff344afa39c7d106cc0c61f","carrier":"USPS","tracking_details":[{"object":"TrackingDetail","message":"Pre-Shipment+ Info Sent to USPS","description":"","status":"pre_transit","status_detail":"status_update","datetime":"2026-07-12T06:03:12Z","source":"USPS","carrier_code":"","tracking_location":{"object":"TrackingLocation","city":null,"state":null,"country":null,"zip":null},"est_delivery_date":null,"datetime_local":"2026-07-12T06:03:12+00:00","geocode_confidence":"LOW"},{"object":"TrackingDetail","message":"Shipping+ Label Created","description":"","status":"pre_transit","status_detail":"status_update","datetime":"2026-07-12T18:40:12Z","source":"USPS","carrier_code":"","tracking_location":{"object":"TrackingLocation","city":"HOUSTON","state":"TX","country":null,"zip":"77063"},"est_delivery_date":null,"datetime_local":"2026-07-12T18:40:12+00:00","geocode_confidence":"LOW"}],"fees":[],"carrier_detail":{"object":"CarrierDetail","service":"First-Class+ Package Service","container_type":null,"est_delivery_date_local":null,"est_delivery_time_local":null,"origin_location":"HOUSTON+ TX, 77001","origin_tracking_location":{"object":"TrackingLocation","city":"HOUSTON","state":"TX","country":null,"zip":"77063"},"destination_location":"CHARLESTON+ SC, 29401","destination_tracking_location":null,"guaranteed_delivery_date":null,"alternate_identifier":null,"initial_delivery_attempt":null},"delivery_evidence":[],"public_url":"https://track.easypost.com/djE6dHJrXzRmYzA1YTM1ZWRkNjRjYmQ4OTlhMmJlM2Q5Zjc2NGIy"},"to_address":{"id":"adr_7daf17b6961311f19d93002248041e50","object":"Address","created_at":"2026-08-12T06:03:08Z","updated_at":"2026-08-12T06:03:08Z","name":"John+ Doe","company":"Company","street1":"15 Lovely Street","street2":"Northwest","city":"New+ York","state":"NY","zip":"10118","country":"US","phone":"5555550199","email":null,"mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":{}},"usps_zone":3,"return_address":{"id":"adr_7daf1806961311f19d94002248041e50","object":"Address","created_at":"2026-08-12T06:03:08Z","updated_at":"2026-08-12T06:03:08Z","name":"Eryn+ Hermann","company":null,"street1":"1600 Pennsylvania Ave NW","street2":null,"city":"Washington","state":"NY","zip":"20500","country":"US","phone":"2024561111","email":null,"mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":{}},"buyer_address":{"id":"adr_7daf17b6961311f19d93002248041e50","object":"Address","created_at":"2026-08-12T06:03:08Z","updated_at":"2026-08-12T06:03:08Z","name":"John+ Doe","company":"Company","street1":"15 Lovely Street","street2":"Northwest","city":"New+ York","state":"NY","zip":"10118","country":"US","phone":"5555550199","email":null,"mode":"test","carrier_facility":null,"residential":null,"federal_tax_id":null,"state_tax_id":null,"verifications":{}},"forms":[],"fees":[{"object":"Fee","type":"LabelFee","amount":"0.00000","charged":true,"refunded":false},{"object":"Fee","type":"PostageFee","amount":"8.60000","charged":true,"refunded":false},{"object":"Fee","type":"InsuranceFee","amount":"1.00000","charged":true,"refunded":false}],"object":"Shipment"}'+ recorded_at: Wed, 12 Aug 2026 06:03:57 GMT+recorded_with: VCR 6.4.0