/** * The API for operations with orders. * * @package WooCommerce\PayPalCommerce\Api * * @phpcs:disable Squiz.Commenting.FunctionCommentThrowTag */ declare (strict_types=1); namespace WooCommerce\PayPalCommerce\Api; use Exception; use InvalidArgumentException; use RuntimeException; use WC_Order; use WooCommerce\PayPalCommerce\ApiClient\Endpoint\OrderEndpoint; use WooCommerce\PayPalCommerce\ApiClient\Entity\Order; use WooCommerce\PayPalCommerce\PPCP; use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway; use WooCommerce\PayPalCommerce\WcGateway\Helper\RefundFeesUpdater; use WooCommerce\PayPalCommerce\WcGateway\Processor\AuthorizedPaymentsProcessor; use WooCommerce\PayPalCommerce\WcGateway\Processor\OrderProcessor; use WooCommerce\PayPalCommerce\WcGateway\Processor\RefundProcessor; /** * Returns the PayPal order. * * @param string|WC_Order $paypal_id_or_wc_order The ID of PayPal order or a WC order (with the ID in meta). * @throws InvalidArgumentException When the argument cannot be used for retrieving the order. * @throws Exception When the operation fails. */ function ppcp_get_paypal_order($paypal_id_or_wc_order): Order { if ($paypal_id_or_wc_order instanceof WC_Order) { $paypal_id_or_wc_order = $paypal_id_or_wc_order->get_meta(PayPalGateway::ORDER_ID_META_KEY); if (!$paypal_id_or_wc_order) { throw new InvalidArgumentException('PayPal order ID not found in meta.'); } } if (!is_string($paypal_id_or_wc_order)) { throw new InvalidArgumentException('Invalid PayPal order ID, string expected.'); } $order_endpoint = PPCP::container()->get('api.endpoint.order'); assert($order_endpoint instanceof OrderEndpoint); return $order_endpoint->order($paypal_id_or_wc_order); } /** * Creates a PayPal order for the given WC order. * * @param WC_Order $wc_order The WC order. * @throws Exception When the operation fails. */ function ppcp_create_paypal_order_for_wc_order(WC_Order $wc_order): Order { $order_processor = PPCP::container()->get('wcgateway.order-processor'); assert($order_processor instanceof OrderProcessor); return $order_processor->create_order($wc_order); } /** * Captures the PayPal order. * * @param WC_Order $wc_order The WC order. * @throws InvalidArgumentException When the order cannot be captured. * @throws Exception When the operation fails. */ function ppcp_capture_order(WC_Order $wc_order): void { $intent = strtoupper((string) $wc_order->get_meta(PayPalGateway::INTENT_META_KEY)); if ($intent !== 'AUTHORIZE') { throw new InvalidArgumentException('Only orders with "authorize" intent can be captured.'); } $captured = wc_string_to_bool($wc_order->get_meta(AuthorizedPaymentsProcessor::CAPTURED_META_KEY)); if ($captured) { throw new InvalidArgumentException('The order is already captured.'); } $authorized_payment_processor = PPCP::container()->get('wcgateway.processor.authorized-payments'); assert($authorized_payment_processor instanceof AuthorizedPaymentsProcessor); if (!$authorized_payment_processor->capture_authorized_payment($wc_order)) { throw new RuntimeException('Capture failed.'); } } /** * Reauthorizes the PayPal order. * * @param WC_Order $wc_order The WC order. * @throws InvalidArgumentException When the order cannot be captured. * @throws Exception When the operation fails. */ function ppcp_reauthorize_order(WC_Order $wc_order): void { $intent = strtoupper((string) $wc_order->get_meta(PayPalGateway::INTENT_META_KEY)); if ($intent !== 'AUTHORIZE') { throw new InvalidArgumentException('Only orders with "authorize" intent can be reauthorized.'); } $captured = wc_string_to_bool($wc_order->get_meta(AuthorizedPaymentsProcessor::CAPTURED_META_KEY)); if ($captured) { throw new InvalidArgumentException('The order is already captured.'); } $authorized_payment_processor = PPCP::container()->get('wcgateway.processor.authorized-payments'); assert($authorized_payment_processor instanceof AuthorizedPaymentsProcessor); if ($authorized_payment_processor->reauthorize_payment($wc_order) !== AuthorizedPaymentsProcessor::SUCCESSFUL) { throw new RuntimeException($authorized_payment_processor->reauthorization_failure_reason() ?: 'Reauthorization failed.'); } } /** * Refunds the PayPal order. * Note that you can use wc_refund_payment() to trigger the refund in WC and PayPal. * * @param WC_Order $wc_order The WC order. * @param float $amount The refund amount. * @param string $reason The reason for the refund. * @return string The PayPal refund ID. * @throws InvalidArgumentException When the order cannot be refunded. * @throws Exception When the operation fails. */ function ppcp_refund_order(WC_Order $wc_order, float $amount, string $reason = ''): string { $order = ppcp_get_paypal_order($wc_order); $refund_processor = PPCP::container()->get('wcgateway.processor.refunds'); assert($refund_processor instanceof RefundProcessor); return $refund_processor->refund($order, $wc_order, $amount, $reason); } /** * Voids the authorization. * * @param WC_Order $wc_order The WC order. * @throws InvalidArgumentException When the order cannot be voided. * @throws Exception When the operation fails. */ function ppcp_void_order(WC_Order $wc_order): void { $order = ppcp_get_paypal_order($wc_order); $refund_processor = PPCP::container()->get('wcgateway.processor.refunds'); assert($refund_processor instanceof RefundProcessor); $refund_processor->void($order); } /** * Updates the PayPal refund fees totals on an order. * * @param WC_Order $wc_order The WC order. */ function ppcp_update_order_refund_fees(WC_Order $wc_order): void { $updater = PPCP::container()->get('wcgateway.helper.refund-fees-updater'); assert($updater instanceof RefundFeesUpdater); $updater->update($wc_order); } {"id":7211,"date":"2025-07-31T08:08:18","date_gmt":"2025-07-31T08:08:18","guid":{"rendered":"https:\/\/hostamy.com\/?p=7211"},"modified":"2025-07-31T08:08:18","modified_gmt":"2025-07-31T08:08:18","slug":"7211-2","status":"publish","type":"post","link":"https:\/\/hostamy.com\/en_gb\/7211-2\/","title":{"rendered":""},"content":{"rendered":"
You can make an informed choice regarding which casino to play at by reading the top online casino reviews. By reviewing a variety of sites, you’ll get an idea of how well they rank. You’ll also get a quick overview of the games they have and if the site is secure and safe. The Casinomeister team carefully selects new websites and sites that have been in operation for a while but have recently expanded their offerings.\n<\/p>\n
The Best Online Casino Reviews will tell you everything you need to know about casinos, their games, and its payment options. There’s plenty of information on casinos online, and the top ones will provide an overview of the most important aspects. You can also search for more information according to your location and criteria. Whatever your location there are online casino reviews available to assist you in choosing the best casino to play at.\n<\/p>\n
The Best Online Casino Reviews will also provide information on the games available. Find out what the games are like and how simple they are to play. You can also find out if the casino offers bonuses ice casino com br<\/a> and how you can deposit and withdraw your funds. Casinos online provide a variety of chances to win real money. There are many types of online casino games, therefore it is crucial to study as many as you can.\n<\/p>\n It’s a great way of avoiding being scammed by unscrupulous companies. This type of site will not only provide useful information, but will also be completely free to test. It’s up to you to decide. But, whatever you choose, you’ll have the best online casino experience for your money by reading the best reviews that you can get. You’ll be happy that you did.\n<\/p>\n Reviews of online casinos that are highly regarded will examine the bonuses and promotions offered. You’ll learn about the terms and conditions for promotions and bonuses that casinos offer. You can decide on a casino by the bonus it provides, the games it offers, and the payment options. You’ll have access to all the information you require and start playing right away. The Best Online Casino Reviews will also give details on the games and interface.\n<\/p>\n It is also crucial to consider the Best Online Casino Reviews when looking at a casino’s reputation. They provide an objective evaluation of the casino\u2019s overall performance. Before making a decision you can read casino reviews. However, the most effective online casino review is more than just an overview of the facts. The review should show the overall quality of the casino. When selecting a new casino online look at its reviews and ratings.\n<\/p>\n Online casino reviews that are highly regarded provide comprehensive information on the games and the casino. The reviews will give information on the casino’s functions as well as its interface and details. A review of an online casino will give you the best online gambling experience. These features are essential when you’re trying to find an online casino that is new. Otherwise you’ll be left with a website that has a poor score and no rewards.\n<\/p>\n Online casino reviews will also provide you with an extensive overview of any promotions or bonuses provided by a casino. This is especially important when you’re playing with lots of players. If you’re experiencing issues with the casino, it’s essential to gather as much information as you can on the company. The most reliable reviews of online casinos will include all of this information and more. There are other aspects to be considered in reviews.\n<\/p>\n Another important aspect to consider when selecting an online casino is customer service. The best online casino reviews will evaluate the quality of customer support that a site offers. It is vital to the player’s overall experience how a site responds. It is important to find the top online casino reviews. A review written juegos-moviles.com<\/a> by an independent third party will verify that the casino you are playing at is legit.<\/p>","protected":false},"excerpt":{"rendered":" Best Online Casino Reviews You can make an informed choice regarding which casino to play at by reading the top online casino reviews. By reviewing a variety of sites, you’ll get an idea of how well they rank. You’ll also get a quick overview of the games they have and if the site is secure […]<\/p>","protected":false},"author":23,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"pmpro_default_level":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-7211","post","type-post","status-publish","format-standard","hentry","category-uncategorized","pmpro-has-access"],"yoast_head":"\n