mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
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:
commit
ceb95952a9
2 changed files with 1 additions and 21 deletions
|
@ -69,13 +69,8 @@ class AddressFactory {
|
||||||
* @throws RuntimeException When JSON object is malformed.
|
* @throws RuntimeException When JSON object is malformed.
|
||||||
*/
|
*/
|
||||||
public function from_paypal_response( \stdClass $data ): Address {
|
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(
|
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_1 ) ) ? $data->address_line_1 : '',
|
||||||
( isset( $data->address_line_2 ) ) ? $data->address_line_2 : '',
|
( isset( $data->address_line_2 ) ) ? $data->address_line_2 : '',
|
||||||
( isset( $data->admin_area_1 ) ) ? $data->admin_area_1 : '',
|
( isset( $data->admin_area_1 ) ) ? $data->admin_area_1 : '',
|
||||||
|
|
|
@ -127,21 +127,6 @@ class AddressFactoryTest extends TestCase
|
||||||
$this->assertEquals($expectedPostalCode, $result->postal_code());
|
$this->assertEquals($expectedPostalCode, $result->postal_code());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFromPayPalRequestThrowsError()
|
|
||||||
{
|
|
||||||
$testee = new AddressFactory();
|
|
||||||
|
|
||||||
$data = (object) [
|
|
||||||
'address_line_1' => 'shipping_address_1',
|
|
||||||
'address_line_2' => 'shipping_address_2',
|
|
||||||
'admin_area_1' => 'shipping_admin_area_1',
|
|
||||||
'admin_area_2' => 'shipping_admin_area_2',
|
|
||||||
'postal_code' => 'shipping_postcode',
|
|
||||||
];
|
|
||||||
$this->expectException(RuntimeException::class);
|
|
||||||
$testee->from_paypal_response($data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function dataFromPayPalRequest() : array
|
public function dataFromPayPalRequest() : array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue