Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use state_name in rare cases that state_id is nil, this will prevent … #13

Open
wants to merge 1 commit into
base: support-physical-card
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/hushed/documents/request/hash_converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def ship_to_hash
'Address1' => ship_address.address1,
'Address2' => ship_address.address2,
'City' => ship_address.city,
'State' => ship_address.state.name,
'State' => state(ship_address),
'PostalCode' => ship_address.zipcode,
'Country' => ship_address.country.name
}
Expand All @@ -32,7 +32,7 @@ def bill_to_hash
'Address1' => bill_address.address1,
'Address2' => bill_address.address2,
'City' => bill_address.city,
'State' => bill_address.state.name,
'State' => state(bill_address),
'PostalCode' => bill_address.zipcode,
'Country' => bill_address.country.name
}
Expand All @@ -42,6 +42,10 @@ def bill_to_hash
def normalize_sku(sku)
sku.chomp("-SET")
end

def state(address)
address.state ? address.state.name : address.state_name
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe I did this very change in another shipping implementation that utilizes XML! Eerily familiar. Anyway, looks 👍

end
end
end
end
Expand Down