'offline', 'paypalcommerce' => 'paypal', 'paypaladaptive' => 'paypal', 'paypal_pro' => 'paypal', 'paypal_express' => 'paypal', 'paypal_standard' => 'paypal', 'stripe_checkout' => 'stripe', 'stripe_ach' => 'stripe', 'stripe_ideal' => 'stripe', 'stripe_sepa' => 'stripe', 'stripe_apple_pay' => 'stripe', 'stripe_google_pay' => 'stripe', 'stripe_becs' => 'stripe', 'stripe_bancontact' => 'stripe', ]; return isset( $map[ $givewp_gateway ] ) ? $map[ $givewp_gateway ] : $givewp_gateway; } /** * Map a GiveWP donation status (post_status on the give_payment CPT) to * the SureDonation `payment_status` value stored on the donations row. * * @param string $givewp_status GiveWP donation post_status. * @return string SureDonation payment_status value. * @since 1.0.0 */ public static function map_donation_status( $givewp_status ) { $givewp_status = is_string( $givewp_status ) ? $givewp_status : ''; $map = [ 'publish' => 'completed', 'give_complete' => 'completed', 'give_pending' => 'pending', 'pending' => 'pending', 'give_processing' => 'processing', 'give_cancelled' => 'cancelled', 'give_abandoned' => 'cancelled', 'give_failed' => 'failed', 'give_revoked' => 'cancelled', 'give_preapproval' => 'pending', 'refunded' => 'refunded', 'give_refunded' => 'refunded', ]; return isset( $map[ $givewp_status ] ) ? $map[ $givewp_status ] : 'pending'; } /** * Map a GiveWP subscription status to SureDonation's subscription_status value. * * @param string $givewp_status GiveWP subscription status. * @return string SureDonation subscription_status value. * @since 1.0.0 */ public static function map_subscription_status( $givewp_status ) { $givewp_status = is_string( $givewp_status ) ? $givewp_status : ''; $map = [ 'active' => 'active', 'cancelled' => 'cancelled', 'expired' => 'expired', 'completed' => 'completed', 'pending' => 'pending', 'failing' => 'past_due', 'suspended' => 'paused', ]; return isset( $map[ $givewp_status ] ) ? $map[ $givewp_status ] : 'pending'; } /** * Check whether a SureDonation gateway is currently loaded on this site. * * Used by the migration tool to display per-gateway "live vs historical" * badges in the data-found panel: records for gateways whose helper class * is loaded will be fully functional after import; others import as * historical-only ledger rows. * * @param string $sd_gateway SureDonation gateway slug. * @return bool True if the gateway's helper class is loaded (or offline, which is always available). * @since 1.0.0 */ public static function is_gateway_live( $sd_gateway ) { if ( 'offline' === $sd_gateway ) { return true; } $detectors = [ 'stripe' => 'SureDonation\\Inc\\Payments\\Stripe\\Stripe_Helper', 'paypal' => 'SureDonation\\Inc\\Payments\\PayPal\\PayPal_Helper', 'mollie' => 'SureDonation\\Inc\\Payments\\Mollie\\Mollie_Helper', 'razorpay' => 'SureDonation\\Inc\\Payments\\Razorpay\\Razorpay_Helper', ]; if ( ! isset( $detectors[ $sd_gateway ] ) ) { return false; } return class_exists( $detectors[ $sd_gateway ] ); } /** * Check whether a SureDonation gateway's Pro recurring handler is loaded. * * Imported subscriptions for gateways whose handler is NOT loaded are * stored with `subscription_status = 'imported-historical'` so the donor * dashboard can hide cancel/suspend/activate actions. This mitigates the * default-to-Stripe fallback in * suredonation-pro/inc/recurring/subscription-api.php:362. * * @param string $sd_gateway SureDonation gateway slug. * @return bool True if the gateway's subscription handler class is loaded. * @since 1.0.0 */ public static function is_subscription_handler_live( $sd_gateway ) { $detectors = [ 'stripe' => 'SureDonationPro\\Inc\\Recurring\\Subscription_Handler', 'paypal' => 'SureDonationPro\\Inc\\Payments\\PayPal\\PayPal_Subscription_Handler', 'mollie' => 'SureDonationPro\\Inc\\Payments\\Mollie\\Mollie_Subscription_Handler', 'razorpay' => 'SureDonationPro\\Inc\\Payments\\Razorpay\\Razorpay_Subscription_Handler', ]; if ( ! isset( $detectors[ $sd_gateway ] ) ) { return false; } return class_exists( $detectors[ $sd_gateway ] ); } }