mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Save fees on capture
This commit is contained in:
parent
e22cb04350
commit
ba9f6074e3
3 changed files with 19 additions and 2 deletions
|
@ -37,6 +37,7 @@ class PayPalGateway extends \WC_Payment_Gateway {
|
|||
const INTENT_META_KEY = '_ppcp_paypal_intent';
|
||||
const ORDER_ID_META_KEY = '_ppcp_paypal_order_id';
|
||||
const ORDER_PAYMENT_MODE_META_KEY = '_ppcp_paypal_payment_mode';
|
||||
const FEES_META_KEY = '_ppcp_paypal_fees';
|
||||
|
||||
/**
|
||||
* The Settings Renderer.
|
||||
|
|
|
@ -63,6 +63,7 @@ trait PaymentsStatusHandlingTrait {
|
|||
switch ( $status->name() ) {
|
||||
case CaptureStatus::COMPLETED:
|
||||
$wc_order->payment_complete();
|
||||
do_action( 'woocommerce_paypal_payments_order_captured', $wc_order, $capture );
|
||||
break;
|
||||
// It is checked in the capture endpoint already, but there are other ways to capture,
|
||||
// such as when paid via saved card.
|
||||
|
|
|
@ -11,7 +11,9 @@ namespace WooCommerce\PayPalCommerce\WcGateway;
|
|||
|
||||
use Dhii\Container\ServiceProvider;
|
||||
use Dhii\Modular\Module\ModuleInterface;
|
||||
use WC_Order;
|
||||
use WooCommerce\PayPalCommerce\AdminNotices\Repository\Repository;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Capture;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Helper\DccApplies;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Repository\PayPalRequestIdRepository;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Admin\OrderTablePaymentStatusColumn;
|
||||
|
@ -71,6 +73,19 @@ class WCGatewayModule implements ModuleInterface {
|
|||
}
|
||||
);
|
||||
|
||||
add_action(
|
||||
'woocommerce_paypal_payments_order_captured',
|
||||
function ( WC_Order $wc_order, Capture $capture ) {
|
||||
$breakdown = $capture->seller_receivable_breakdown();
|
||||
if ( $breakdown ) {
|
||||
$wc_order->update_meta_data( PayPalGateway::FEES_META_KEY, $breakdown->to_array() );
|
||||
$wc_order->save_meta_data();
|
||||
}
|
||||
},
|
||||
10,
|
||||
2
|
||||
);
|
||||
|
||||
if ( $c->has( 'wcgateway.url' ) ) {
|
||||
$assets = new SettingsPageAssets(
|
||||
$c->get( 'wcgateway.url' ),
|
||||
|
@ -249,7 +264,7 @@ class WCGatewayModule implements ModuleInterface {
|
|||
static function ( $order_actions ) use ( $container ): array {
|
||||
global $theorder;
|
||||
|
||||
if ( ! is_a( $theorder, \WC_Order::class ) ) {
|
||||
if ( ! is_a( $theorder, WC_Order::class ) ) {
|
||||
return $order_actions;
|
||||
}
|
||||
|
||||
|
@ -265,7 +280,7 @@ class WCGatewayModule implements ModuleInterface {
|
|||
|
||||
add_action(
|
||||
'woocommerce_order_action_ppcp_authorize_order',
|
||||
static function ( \WC_Order $wc_order ) use ( $container ) {
|
||||
static function ( WC_Order $wc_order ) use ( $container ) {
|
||||
|
||||
/**
|
||||
* The authorized payments processor.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue