fees_api()->get_fees(); WC()->session->set( 'ppcp_fees', $fees ); } ); add_filter( 'ppcp_create_order_request_body_data', function( array $data ) use ( $c ) { foreach ( ( $data['purchase_units'] ?? array() ) as $purchase_unit_index => $purchase_unit ) { foreach ( ( $purchase_unit['items'] ?? array() ) as $item_index => $item ) { $data['purchase_units'][ $purchase_unit_index ]['items'][ $item_index ]['name'] = apply_filters( 'woocommerce_paypal_payments_cart_line_item_name', $item['name'], $item['cart_item_key'] ?? null ); } } return $data; } ); add_action( 'woocommerce_paypal_payments_paypal_order_created', function ( Order $order ) use ( $c ) { $transient = $c->has( 'api.helper.order-transient' ) ? $c->get( 'api.helper.order-transient' ) : null; if ( $transient instanceof OrderTransient ) { $transient->on_order_created( $order ); } }, 10, 1 ); add_action( 'woocommerce_paypal_payments_woocommerce_order_created', function ( WC_Order $wc_order, Order $order ) use ( $c ) { $transient = $c->has( 'api.helper.order-transient' ) ? $c->get( 'api.helper.order-transient' ) : null; if ( $transient instanceof OrderTransient ) { $transient->on_woocommerce_order_created( $wc_order, $order ); } }, 10, 2 ); add_action( 'woocommerce_paypal_payments_clear_apm_product_status', function () use ( $c ) { $failure_registry = $c->has( 'api.helper.failure-registry' ) ? $c->get( 'api.helper.failure-registry' ) : null; if ( $failure_registry instanceof FailureRegistry ) { $failure_registry->clear_failures( FailureRegistry::SELLER_STATUS_KEY ); } }, 10, 2 ); add_action( 'wp_logout', function( int $user_id ) use ( $c ) { $client_credentials_cache = $c->get( 'api.client-credentials-cache' ); assert( $client_credentials_cache instanceof Cache ); if ( $client_credentials_cache->has( UserIdToken::CACHE_KEY . '-' . (string) $user_id ) ) { $client_credentials_cache->delete( UserIdToken::CACHE_KEY . '-' . (string) $user_id ); } } ); } /** * Returns the key for the module. * * @return string|void */ public function getKey() { } }