WC_Gateway_Braintree_Subscriptions_AngellEYE

The PayPal for WooCommerce WC Gateway Braintree Subscriptions AngellEYE class.

Defined (1)

The class is defined in the following location(s).

/classes/subscriptions/wc-gateway-braintree-subscriptions-angelleye.php  
  1. class WC_Gateway_Braintree_Subscriptions_AngellEYE extends WC_Gateway_Braintree_AngellEYE { 
  2.  
  3. public function __construct() { 
  4. parent::__construct(); 
  5. if (class_exists('WC_Subscriptions_Order')) { 
  6. add_action('woocommerce_scheduled_subscription_payment_' . $this->id, array($this, 'scheduled_subscription_payment'), 10, 2); 
  7. add_filter('woocommerce_subscription_payment_meta', array($this, 'add_subscription_payment_meta'), 10, 2); 
  8. add_filter('woocommerce_subscription_validate_payment_meta', array($this, 'validate_subscription_payment_meta'), 10, 2); 
  9. add_action('wcs_resubscribe_order_created', array($this, 'delete_resubscribe_meta'), 10); 
  10. add_action('woocommerce_subscription_failing_payment_method_updated_stripe', array($this, 'update_failing_payment_method'), 10, 2); 
  11.  
  12. public function is_subscription($order_id) { 
  13. return ( function_exists('wcs_order_contains_subscription') && ( wcs_order_contains_subscription($order_id) || wcs_is_subscription($order_id) || wcs_order_contains_renewal($order_id) ) ); 
  14.  
  15. public function process_payment($order_id) { 
  16. if ($this->is_subscription($order_id)) { 
  17. $order = new WC_Order($order_id); 
  18. if ($order->get_total() == 0) { 
  19. return parent::subscription_process_payment($order_id); 
  20. } else { 
  21. return parent::process_payment($order_id); 
  22. } else { 
  23. return parent::process_payment($order_id); 
  24.  
  25. public function scheduled_subscription_payment($amount_to_charge, $renewal_order) { 
  26. parent::process_subscription_payment($renewal_order, $amount_to_charge); 
  27.  
  28. public function add_subscription_payment_meta($payment_meta, $subscription) { 
  29. $payment_meta[$this->id] = array( 
  30. 'post_meta' => array( 
  31. '_payment_tokens_id' => array( 
  32. 'value' => get_post_meta($subscription->id, '_payment_tokens_id', true),  
  33. 'label' => 'Payment Tokens ID',  
  34. ); 
  35. return $payment_meta; 
  36.  
  37. public function validate_subscription_payment_meta($payment_method_id, $payment_meta) { 
  38. if ($this->id === $payment_method_id) { 
  39. if (!empty($payment_meta['post_meta']['_payment_tokens_id']['value']) && empty($payment_meta['post_meta']['_payment_tokens_id']['value'])) { 
  40. throw new Exception('A "_payment_tokens_id" value is required.'); 
  41.  
  42. public function save_payment_token($order, $payment_tokens_id) { 
  43. $order_id = version_compare(WC_VERSION, '3.0', '<') ? $order->id : $order->get_id(); 
  44. parent::save_payment_token($order, $payment_tokens_id); 
  45. // Also store it on the subscriptions being purchased or paid for in the order 
  46. if (function_exists('wcs_order_contains_subscription') && wcs_order_contains_subscription($order_id)) { 
  47. $subscriptions = wcs_get_subscriptions_for_order($order_id); 
  48. } elseif (function_exists('wcs_order_contains_renewal') && wcs_order_contains_renewal($order_id)) { 
  49. $subscriptions = wcs_get_subscriptions_for_renewal_order($order_id); 
  50. } else { 
  51. $subscriptions = array(); 
  52. if (!empty($subscriptions)) { 
  53. foreach ($subscriptions as $subscription) { 
  54. update_post_meta($subscription->id, '_payment_tokens_id', $payment_tokens_id); 
  55.  
  56. public function delete_resubscribe_meta($resubscribe_order) { 
  57. delete_post_meta($resubscribe_order->id, '_payment_tokens_id'); 
  58.  
  59. public function update_failing_payment_method($subscription, $renewal_order) { 
  60. update_post_meta($subscription->id, '_payment_tokens_id', $renewal_order->payment_tokens_id); 
  61.