@@ -570,16 +570,16 @@ def test_charge_with_vertex_transaction_type(self):
570570 type = 'charge' ,
571571 vertex_transaction_type = 'sale'
572572 )
573-
573+
574574 with self .mock_request ('adjustment/charged-with-vertex-transaction-type.xml' ):
575575 account .charge (charge )
576-
576+
577577 # Verify the charge was created with vertex_transaction_type
578578 self .assertEqual (charge .vertex_transaction_type , 'sale' )
579579
580580 def test_purchase_with_invoice_override_vertex_transaction_type (self ):
581581 """Test that invoice-level vertex_transaction_type overrides adjustment-level values.
582-
582+
583583 This demonstrates the override behavior where an invoice can have its own
584584 vertex_transaction_type that takes precedence over the individual adjustment values.
585585 """
@@ -596,16 +596,16 @@ def test_purchase_with_invoice_override_vertex_transaction_type(self):
596596 ],
597597 vertex_transaction_type = 'rental' # Invoice-level value (should override)
598598 )
599-
599+
600600 with self .mock_request ('purchase/invoiced-with-invoice-override-vertex-type.xml' ):
601601 invoice_collection = purchase .invoice ()
602-
602+
603603 invoice = invoice_collection .charge_invoice
604604 adjustments = invoice .line_items
605-
605+
606606 # Verify the invoice has the invoice-level vertex_transaction_type
607607 self .assertEqual (invoice .vertex_transaction_type , 'rental' )
608-
608+
609609 # The adjustment still has its own value (API preserves both)
610610 # but the invoice-level value is what gets used for tax calculation
611611 self .assertEqual (adjustments [0 ].vertex_transaction_type , 'sale' )
@@ -3454,6 +3454,62 @@ def test_gift_cards_purchase(self):
34543454 self .assertTrue (gift_card .delivery is not None )
34553455 self .assertTrue (gift_card .canceled_at is None )
34563456
3457+ def test_gift_cards_purchase_with_tax_service_opt_out_true (self ):
3458+ gift_card = self ._build_gift_card ()
3459+ gift_card .tax_service_opt_out = True
3460+
3461+ self .assertFalse ('_url' in gift_card .attributes )
3462+
3463+ with self .mock_request ('gift_cards/created-with-tax-service-opt-out-true.xml' ):
3464+ gift_card .save ()
3465+
3466+ self .assertTrue (gift_card ._url is not None )
3467+ self .assertTrue (gift_card .delivery is not None )
3468+ self .assertTrue (gift_card .canceled_at is None )
3469+
3470+ def test_gift_cards_purchase_with_tax_service_opt_out_false (self ):
3471+ gift_card = self ._build_gift_card ()
3472+ gift_card .tax_service_opt_out = False
3473+
3474+ self .assertFalse ('_url' in gift_card .attributes )
3475+
3476+ with self .mock_request ('gift_cards/created-with-tax-service-opt-out-false.xml' ):
3477+ gift_card .save ()
3478+
3479+ self .assertTrue (gift_card ._url is not None )
3480+ self .assertTrue (gift_card .delivery is not None )
3481+ self .assertTrue (gift_card .canceled_at is None )
3482+
3483+ def test_gift_cards_purchase_with_tax_service_opt_out_invalid (self ):
3484+ gift_card = self ._build_gift_card ()
3485+ gift_card .tax_service_opt_out = 'invalid'
3486+
3487+ self .assertFalse ('_url' in gift_card .attributes )
3488+
3489+ with self .mock_request ('gift_cards/created-with-tax-service-opt-out-invalid.xml' ):
3490+ try :
3491+ gift_card .save ()
3492+ except ValidationError as exc :
3493+ error = exc
3494+ else :
3495+ self .fail ('Creating a gift card with invalid tax_service_opt_out did not raise a ValidationError' )
3496+ self .assertEqual (error .symbol , 'tax_service_opt_out' )
3497+ self .assertIn ('Allowed values: true, false' , error .message )
3498+
3499+ def test_gift_cards_purchase_with_tax_service_opt_out_legacy_site (self ):
3500+ gift_card = self ._build_gift_card ()
3501+ gift_card .tax_service_opt_out = True
3502+
3503+ with self .mock_request ('gift_cards/created-with-tax-service-opt-out-legacy-site.xml' ):
3504+ try :
3505+ gift_card .save ()
3506+ except ValidationError as exc :
3507+ error = exc
3508+ else :
3509+ self .fail ('Creating a gift card with tax_service_opt_out on legacy site did not raise a ValidationError' )
3510+ self .assertEqual (error .symbol , 'tax_service_opt_out' )
3511+ self .assertIn ('Not supported for legacy invoices' , error .message )
3512+
34573513 def test_gift_cards_preview (self ):
34583514 gift_card = self ._build_gift_card ()
34593515
0 commit comments