/** * 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":7225,"date":"2025-08-01T05:04:04","date_gmt":"2025-08-01T05:04:04","guid":{"rendered":"https:\/\/hostamy.com\/?p=7225"},"modified":"2025-08-01T05:04:04","modified_gmt":"2025-08-01T05:04:04","slug":"7225-2","status":"publish","type":"post","link":"https:\/\/hostamy.com\/en_gb\/7225-2\/","title":{"rendered":""},"content":{"rendered":"
The most rewarding casino bonuses do not necessarily require wagering. The best casino bonuses do not have wagering requirements. These bonuses are an excellent opportunity for you to recoup some of your losses. Certain bonuses can be used to play more than slot machines, while others are restricted to video poker or table games. While some casino bonuses require that you wager a certain amount but they’re still a great way to make the most of them.\n<\/p>\n
It is essential to know the specific requirements for each bonus before claiming it. For instance, deposit 12bet website<\/a> matches are the most lucrative bonuses offered by any kind of online casino in the US. These bonuses typically have strict wagering requirements. Some of the biggest bonuses available are restricted to players from certain nations and may be subject to strict compliance with certain rules. Therefore, it’s essential to read the details of a casino bonus before you decide to use it.\n<\/p>\n While it can be difficult to determine the conditions and terms of each bonus, it’s worth it for the potential rewards. The more appealing a bonus casino provides the more likely it is to attract you. The best casino bonuses won’t make you feel pressured into making a decision. They are usually more generous than the ones offered by rivals and last for some time. You may lose the bonus if you claim it the wrong way.\n<\/p>\n When you are looking for the best casino bonuses, there are some things you should look out for. In addition to free spins, also look for bonuses to reload your account. These bonuses are usually offered to existing customers at regular intervals and are generally more generous than the ones that are offered by other casinos. You may be able to earn cashbacks when you refer new players to certain casinos that offer a referral program. There are likely to be reload bonuses for existing accounts if you are a regular player. In any situation, you’ll earn lots of money for free, and if you’re a loyal customer you’ll get even more cash!\n<\/p>\n There are many different types of casino bonuses. You must pick the one that best suits your preferences and the type of game you like. Some of the best casino bonuses have a large deposit requirement, whereas others are more suitable for slot machine players. The best casino bonus that meets your needs is determined by your preferences. It is essential to read rulet online igrice<\/a> the terms and conditions of every bonus, and then choose the best gambling sites online within your area. You should never limit yourself to one type of bonus.\n<\/p>\n Once you’ve found the perfect casino for you then it’s time to start playing. Bonuses that don’t require you to deposit funds are the best. You can also choose a no-deposit option to receive the same amount of cash. These bonuses aren’t offered at all online casinos, however they’re a great choice for those who love to play and win at slot machines.\n<\/p>\n The best casino bonuses do not require you to make a deposit. Welcome bonuses don’t require the deposit of. These bonuses are a great way boost your account balance. These bonuses can vary based on the casino, however they are usually 100% match bonuses. You can also select an offer that is not deposit-based. A no-deposit bonus is one that does not require a deposit. You’ll get the same amount of free cash as if you deposit.\n<\/p>\n There are several options for a no-deposit bonus at casinos. You can opt for 100 100% deposit match bonus which matches your deposit up to an amount. Bonuses that don’t require deposit will receive more money to play with than those who don’t. These bonuses aren’t cash-free, but they can be a great way to start your journey online.<\/p>","protected":false},"excerpt":{"rendered":" How to Find the Best Casino Bonuses The most rewarding casino bonuses do not necessarily require wagering. The best casino bonuses do not have wagering requirements. These bonuses are an excellent opportunity for you to recoup some of your losses. Certain bonuses can be used to play more than slot machines, while others are restricted […]<\/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-7225","post","type-post","status-publish","format-standard","hentry","category-uncategorized","pmpro-has-access"],"yoast_head":"\n