mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-30 05:00:51 +08:00
Add ppcp_create_paypal_order_for_wc_order
This commit is contained in:
parent
a61e9303e9
commit
b2ba72c06c
2 changed files with 66 additions and 0 deletions
|
@ -21,6 +21,7 @@ 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;
|
||||
|
||||
/**
|
||||
|
@ -47,6 +48,19 @@ function ppcp_get_paypal_order( $paypal_id_or_wc_order ): Order {
|
|||
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.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue