MS_Gateway_Stripe_View_Card

The Membership 2 MS Gateway Stripe View Card class.

Defined (1)

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

/app/gateway/stripe/view/class-ms-gateway-stripe-view-card.php  
  1. class MS_Gateway_Stripe_View_Card extends MS_View { 
  2.  
  3. public function to_html() { 
  4. $fields = $this->prepare_fields(); 
  5.  
  6. ob_start(); 
  7. ?> 
  8. <div class="ms-wrap ms-card-info-wrapper"> 
  9. <h2><?php _e( 'Credit card info', 'membership2' ); ?> </h2> 
  10. <table class="ms-table"> 
  11. <tbody> 
  12. <tr> 
  13. <th><?php _e( 'Card Number', 'membership2' ); ?></th> 
  14. <th><?php _e( 'Card Expiration date', 'membership2' ); ?></th> 
  15. </tr> 
  16. <tr> 
  17. <td><?php echo '**** **** **** '. $this->data['stripe']['card_num']; ?></td> 
  18. <td><?php echo '' . $this->data['stripe']['card_exp']; ?></td> 
  19. </tr> 
  20. </tbody> 
  21. </table> 
  22. <form action="" method="post"> 
  23. <?php 
  24. foreach ( $fields as $field ) { 
  25. MS_Helper_Html::html_element( $field ); 
  26. ?> 
  27. <script 
  28. src="https://checkout.stripe.com/checkout.js" class="stripe-button" 
  29. data-key="<?php echo esc_attr( $this->data['publishable_key'] ); ?>" 
  30. data-amount="0" 
  31. data-name="<?php echo esc_attr( bloginfo( 'name' ) ); ?>" 
  32. data-description="<?php esc_attr_e( 'Just change card', 'membership2' ); ?>" 
  33. data-panel-label="<?php esc_attr_e( 'Change credit card', 'membership2' ); ?>" 
  34. data-email="<?php echo esc_attr( $this->data['member']->email ); ?>" 
  35. data-label="<?php esc_attr_e( 'Change card number', 'membership2' ); ?>" 
  36. </script> 
  37. </form> 
  38. <div class="clear"></div> 
  39. </div> 
  40. <?php 
  41. $html = ob_get_clean(); 
  42. return $html; 
  43.  
  44. private function prepare_fields() { 
  45. $fields = array( 
  46. 'gateway' => array( 
  47. 'id' => 'gateway',  
  48. 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN,  
  49. 'value' => $this->data['gateway']->id,  
  50. ),  
  51.  
  52. 'ms_relationship_id' => array( 
  53. 'id' => 'ms_relationship_id',  
  54. 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN,  
  55. 'value' => $this->data['ms_relationship_id'],  
  56. ),  
  57.  
  58. '_wpnonce' => array( 
  59. 'id' => '_wpnonce',  
  60. 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN,  
  61. 'value' => wp_create_nonce( 'update_card' ),  
  62. ),  
  63.  
  64. 'action' => array( 
  65. 'id' => 'action',  
  66. 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN,  
  67. 'value' => 'update_card',  
  68. ),  
  69. ); 
  70.  
  71. return $fields;