Merge pull request #672 from woocommerce/PCP-681-refund-failed-no-country-given-f

When creating `Address` do not throw but set empty string when no country code is received
This commit is contained in:
Emili Castells 2022-06-14 16:08:17 +02:00 committed by GitHub
commit ceb95952a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 21 deletions

View file

@ -69,13 +69,8 @@ class AddressFactory {
* @throws RuntimeException When JSON object is malformed.
*/
public function from_paypal_response( \stdClass $data ): Address {
if ( ! isset( $data->country_code ) ) {
throw new RuntimeException(
__( 'No country given for address.', 'woocommerce-paypal-payments' )
);
}
return new Address(
$data->country_code,
( isset( $data->country_code ) ) ? $data->country_code : '',
( isset( $data->address_line_1 ) ) ? $data->address_line_1 : '',
( isset( $data->address_line_2 ) ) ? $data->address_line_2 : '',
( isset( $data->admin_area_1 ) ) ? $data->admin_area_1 : '',