Remove unneeded translations

This commit is contained in:
Alex P. 2025-07-15 20:07:26 +03:00
parent 65d958254d
commit fc9ca6fe60
No known key found for this signature in database
GPG key ID: 68E4DCB139B18520
23 changed files with 43 additions and 120 deletions

View file

@ -444,9 +444,7 @@ class OrderEndpoint {
}
$response = $this->request( $url, $args );
if ( is_wp_error( $response ) ) {
$error = new RuntimeException(
__( 'Could not retrieve order.', 'woocommerce-paypal-payments' )
);
$error = new RuntimeException( 'Could not retrieve order.' );
$this->logger->warning( $error->getMessage() );
throw $error;
@ -456,7 +454,7 @@ class OrderEndpoint {
if ( 404 === $status_code || empty( $response['body'] ) ) {
$error = new RuntimeException(
__( 'Could not retrieve order.', 'woocommerce-paypal-payments' ),
'Could not retrieve order.',
404
);
$this->logger->warning(

View file

@ -113,9 +113,7 @@ class WebhookEndpoint {
$response = $this->request( $url, $args );
if ( is_wp_error( $response ) ) {
throw new RuntimeException(
__( 'Not able to create a webhook.', 'woocommerce-paypal-payments' )
);
throw new RuntimeException( 'Not able to create a webhook.' );
}
$json = json_decode( $response['body'] );
@ -151,9 +149,7 @@ class WebhookEndpoint {
$response = $this->request( $url, $args );
if ( is_wp_error( $response ) ) {
throw new RuntimeException(
__( 'Not able to load webhooks list.', 'woocommerce-paypal-payments' )
);
throw new RuntimeException( 'Not able to load webhooks list.' );
}
$json = json_decode( $response['body'] );
@ -195,9 +191,7 @@ class WebhookEndpoint {
$response = $this->request( $url, $args );
if ( $response instanceof WP_Error ) {
throw new RuntimeException(
__( 'Not able to delete the webhook.', 'woocommerce-paypal-payments' )
);
throw new RuntimeException( 'Not able to delete the webhook.' );
}
$status_code = (int) wp_remote_retrieve_response_code( $response );
@ -250,9 +244,7 @@ class WebhookEndpoint {
$response = $this->request( $url, $args );
if ( is_wp_error( $response ) ) {
throw new RuntimeException(
__( 'Not able to simulate webhook.', 'woocommerce-paypal-payments' )
);
throw new RuntimeException( 'Not able to simulate webhook.' );
}
$json = json_decode( $response['body'] );
$status_code = (int) wp_remote_retrieve_response_code( $response );
@ -312,9 +304,7 @@ class WebhookEndpoint {
);
$response = $this->request( $url, $args );
if ( is_wp_error( $response ) ) {
$error = new RuntimeException(
__( 'Not able to verify webhook event.', 'woocommerce-paypal-payments' )
);
$error = new RuntimeException( 'Not able to verify webhook event.' );
$this->logger->log(
'warning',
$error->getMessage(),
@ -340,9 +330,7 @@ class WebhookEndpoint {
public function verify_current_request_for_webhook( Webhook $webhook ): bool {
if ( ! $webhook->id() ) {
$error = new RuntimeException(
__( 'Not a valid webhook to verify.', 'woocommerce-paypal-payments' )
);
$error = new RuntimeException( 'Not a valid webhook to verify.' );
$this->logger->log( 'warning', $error->getMessage(), array( 'webhook' => $webhook ) );
throw $error;
}
@ -369,11 +357,7 @@ class WebhookEndpoint {
$error = new RuntimeException(
sprintf(
// translators: %s is the headers key.
__(
'Not a valid webhook event. Header %s is missing',
'woocommerce-paypal-payments'
),
$key
)
);

View file

@ -62,8 +62,7 @@ class AuthorizationStatus {
if ( ! in_array( $status, self::VALID_STATUS, true ) ) {
throw new RuntimeException(
sprintf(
// translators: %s is the current status.
__( '%s is not a valid status', 'woocommerce-paypal-payments' ),
'%s is not a valid status',
$status
)
);

View file

@ -51,8 +51,7 @@ class OrderStatus {
if ( ! in_array( $status, self::VALID_STATUS, true ) ) {
throw new RuntimeException(
sprintf(
// translators: %s is the current status.
__( '%s is not a valid status', 'woocommerce-paypal-payments' ),
'%s is not a valid status',
$status
)
);

View file

@ -51,8 +51,7 @@ class PayerTaxInfo {
if ( ! in_array( $type, self::VALID_TYPES, true ) ) {
throw new RuntimeException(
sprintf(
// translators: %s is the current type.
__( '%s is not a valid tax type.', 'woocommerce-paypal-payments' ),
'%s is not a valid tax type.',
$type
)
);

View file

@ -50,9 +50,7 @@ class PaymentToken {
*/
public function __construct( string $id, stdClass $source, string $type = self::TYPE_PAYMENT_METHOD_TOKEN ) {
if ( ! in_array( $type, self::get_valid_types(), true ) ) {
throw new RuntimeException(
__( 'Not a valid payment source type.', 'woocommerce-paypal-payments' )
);
throw new RuntimeException( 'Not a valid payment source type.' );
}
$this->id = $id;
$this->type = $type;

View file

@ -245,8 +245,7 @@ class AmountFactory {
if ( ! isset( $item->value ) || ! is_numeric( $item->value ) ) {
throw new RuntimeException(
sprintf(
// translators: %s is the current breakdown key.
__( 'No value given for breakdown %s', 'woocommerce-paypal-payments' ),
'No value given for breakdown %s',
$key
)
);
@ -254,8 +253,7 @@ class AmountFactory {
if ( ! isset( $item->currency_code ) ) {
throw new RuntimeException(
sprintf(
// translators: %s is the current breakdown key.
__( 'No currency given for breakdown %s', 'woocommerce-paypal-payments' ),
'No currency given for breakdown %s',
$key
)
);

View file

@ -45,15 +45,11 @@ class AuthorizationFactory {
*/
public function from_paypal_response( \stdClass $data ): Authorization {
if ( ! isset( $data->id ) ) {
throw new RuntimeException(
__( 'Does not contain an id.', 'woocommerce-paypal-payments' )
);
throw new RuntimeException( 'Does not contain an id.' );
}
if ( ! isset( $data->status ) ) {
throw new RuntimeException(
__( 'Does not contain status.', 'woocommerce-paypal-payments' )
);
throw new RuntimeException( 'Does not contain status.' );
}
$reason = $data->status_details->reason ?? null;

View file

@ -78,7 +78,7 @@ class CaptureFactory {
$amount = $this->amount_factory->from_paypal_response( $data->amount );
if ( null === $amount ) {
throw new RuntimeException( __( 'Invalid capture amount data.', 'woocommerce-paypal-payments' ) );
throw new RuntimeException( 'Invalid capture amount data.' );
}
return new Capture(

View file

@ -179,19 +179,13 @@ class ItemFactory {
*/
public function from_paypal_response( \stdClass $data ): Item {
if ( ! isset( $data->name ) ) {
throw new RuntimeException(
__( 'No name for item given', 'woocommerce-paypal-payments' )
);
throw new RuntimeException( 'No name for item given' );
}
if ( ! isset( $data->quantity ) || ! is_numeric( $data->quantity ) ) {
throw new RuntimeException(
__( 'No quantity for item given', 'woocommerce-paypal-payments' )
);
throw new RuntimeException( 'No quantity for item given' );
}
if ( ! isset( $data->unit_amount->value ) || ! isset( $data->unit_amount->currency_code ) ) {
throw new RuntimeException(
__( 'No money values for item given', 'woocommerce-paypal-payments' )
);
throw new RuntimeException( 'No money values for item given' );
}
$unit_amount = new Money( (float) $data->unit_amount->value, $data->unit_amount->currency_code );

View file

@ -114,9 +114,7 @@ class OrderFactory {
*/
private function validate_order_id( \stdClass $order_data ): void {
if ( ! isset( $order_data->id ) ) {
throw new RuntimeException(
__( 'Order does not contain an id.', 'woocommerce-paypal-payments' )
);
throw new RuntimeException( 'Order does not contain an id.' );
}
}

View file

@ -27,9 +27,7 @@ class PaymentTokenFactory {
*/
public function from_paypal_response( $data ): PaymentToken {
if ( ! isset( $data->id ) ) {
throw new RuntimeException(
__( 'No id for payment token given', 'woocommerce-paypal-payments' )
);
throw new RuntimeException( 'No id for payment token given' );
}
return new PaymentToken(

View file

@ -57,24 +57,16 @@ class PlanFactory {
*/
public function from_paypal_response( stdClass $data ): Plan {
if ( ! isset( $data->id ) ) {
throw new RuntimeException(
__( 'No id for given plan', 'woocommerce-paypal-payments' )
);
throw new RuntimeException( 'No id for given plan' );
}
if ( ! isset( $data->name ) ) {
throw new RuntimeException(
__( 'No name for plan given', 'woocommerce-paypal-payments' )
);
throw new RuntimeException( 'No name for plan given' );
}
if ( ! isset( $data->product_id ) ) {
throw new RuntimeException(
__( 'No product id for given plan', 'woocommerce-paypal-payments' )
);
throw new RuntimeException( 'No product id for given plan' );
}
if ( ! isset( $data->billing_cycles ) ) {
throw new RuntimeException(
__( 'No billing cycles for given plan', 'woocommerce-paypal-payments' )
);
throw new RuntimeException( 'No billing cycles for given plan' );
}
$billing_cycles = array();

View file

@ -28,14 +28,10 @@ class ProductFactory {
*/
public function from_paypal_response( stdClass $data ): Product {
if ( ! isset( $data->id ) ) {
throw new RuntimeException(
__( 'No id for product given', 'woocommerce-paypal-payments' )
);
throw new RuntimeException( 'No id for product given' );
}
if ( ! isset( $data->name ) ) {
throw new RuntimeException(
__( 'No name for product given', 'woocommerce-paypal-payments' )
);
throw new RuntimeException( 'No name for product given' );
}
return new Product(

View file

@ -224,9 +224,7 @@ class PurchaseUnitFactory {
*/
public function from_paypal_response( \stdClass $data ): ?PurchaseUnit {
if ( ! isset( $data->reference_id ) || ! is_string( $data->reference_id ) ) {
throw new RuntimeException(
__( 'No reference ID given.', 'woocommerce-paypal-payments' )
);
throw new RuntimeException( 'No reference ID given.' );
}
$amount_data = $data->amount ?? null;

View file

@ -77,7 +77,7 @@ class RefundFactory {
$amount = $this->amount_factory->from_paypal_response( $data->amount );
if ( null === $amount ) {
throw new RuntimeException( __( 'Invalid refund amount data.', 'woocommerce-paypal-payments' ) );
throw new RuntimeException( 'Invalid refund amount data.' );
}
return new Refund(

View file

@ -36,9 +36,7 @@ class ReturnUrlFactory {
}
}
throw new RuntimeException(
__( 'Product URL is required but not provided in the request data.', 'woocommerce-paypal-payments' )
);
throw new RuntimeException( 'Product URL is required but not provided in the request data.' );
case 'pay-now':
if ( ! empty( $request_data['order_id'] ) ) {
$order = wc_get_order( $request_data['order_id'] );
@ -47,9 +45,7 @@ class ReturnUrlFactory {
}
}
throw new RuntimeException(
__( 'The order ID is invalid.', 'woocommerce-paypal-payments' )
);
throw new RuntimeException( 'The order ID is invalid.' );
default:
return wc_get_checkout_url();
}

View file

@ -97,14 +97,10 @@ class ShippingFactory {
*/
public function from_paypal_response( \stdClass $data ): Shipping {
if ( ! isset( $data->name->full_name ) ) {
throw new RuntimeException(
__( 'No name was given for shipping.', 'woocommerce-paypal-payments' )
);
throw new RuntimeException( 'No name was given for shipping.' );
}
if ( ! isset( $data->address ) ) {
throw new RuntimeException(
__( 'No address was given for shipping.', 'woocommerce-paypal-payments' )
);
throw new RuntimeException( 'No address was given for shipping.' );
}
$contact_phone = null;
$contact_email = null;

View file

@ -40,14 +40,10 @@ class WebhookEventFactory {
*/
public function from_paypal_response( $data ): WebhookEvent {
if ( ! isset( $data->id ) ) {
throw new RuntimeException(
__( 'ID for webhook event not found.', 'woocommerce-paypal-payments' )
);
throw new RuntimeException( 'ID for webhook event not found.' );
}
if ( ! isset( $data->event_type ) ) {
throw new RuntimeException(
__( 'Event type for webhook event not found.', 'woocommerce-paypal-payments' )
);
throw new RuntimeException( 'Event type for webhook event not found.' );
}
$create_time = ( isset( $data->create_time ) ) ?

View file

@ -59,19 +59,13 @@ class WebhookFactory {
*/
public function from_paypal_response( $data ): Webhook {
if ( ! isset( $data->id ) ) {
throw new RuntimeException(
__( 'No id for webhook given.', 'woocommerce-paypal-payments' )
);
throw new RuntimeException( 'No id for webhook given.' );
}
if ( ! isset( $data->url ) ) {
throw new RuntimeException(
__( 'No URL for webhook given.', 'woocommerce-paypal-payments' )
);
throw new RuntimeException( 'No URL for webhook given.' );
}
if ( ! isset( $data->event_types ) ) {
throw new RuntimeException(
__( 'No event types for webhook given.', 'woocommerce-paypal-payments' )
);
throw new RuntimeException( 'No event types for webhook given.' );
}
return new Webhook(

View file

@ -173,9 +173,7 @@ class ApproveOrderEndpoint implements EndpointInterface {
try {
$data = $this->request_data->read_request( self::nonce() );
if ( ! isset( $data['order_id'] ) ) {
throw new RuntimeException(
__( 'No order id given', 'woocommerce-paypal-payments' )
);
throw new RuntimeException( 'No order id given' );
}
$order = $this->api_endpoint->order( $data['order_id'] );

View file

@ -111,9 +111,7 @@ class ApproveSubscriptionEndpoint implements EndpointInterface {
public function handle_request(): bool {
$data = $this->request_data->read_request( $this->nonce() );
if ( ! isset( $data['order_id'] ) ) {
throw new RuntimeException(
__( 'No order id given', 'woocommerce-paypal-payments' )
);
throw new RuntimeException( 'No order id given' );
}
$order = $this->order_endpoint->order( $data['order_id'] );

View file

@ -47,9 +47,7 @@ class RequestData {
|| ! wp_verify_nonce( $json['nonce'], $nonce )
) {
remove_filter( 'nonce_user_logged_out', array( $this, 'nonce_fix' ), 100 );
throw new RuntimeException(
__( 'Could not validate nonce.', 'woocommerce-paypal-payments' )
);
throw new RuntimeException( 'Could not validate nonce.' );
}
$this->dequeue_nonce_fix();