@@ -7,21 +7,21 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | -do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
|
| 12 | +do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin); |
|
| 13 | 13 | |
| 14 | -do_action( 'wpinv_email_before_note_details', $invoice, $email_type, $sent_to_admin, $customer_note ); |
|
| 14 | +do_action('wpinv_email_before_note_details', $invoice, $email_type, $sent_to_admin, $customer_note); |
|
| 15 | 15 | |
| 16 | 16 | // Generate the custom message body. |
| 17 | -echo wptexturize( wp_kses_post( str_replace( '{customer_note}', $customer_note, $message_body ) ) ); |
|
| 17 | +echo wptexturize(wp_kses_post(str_replace('{customer_note}', $customer_note, $message_body))); |
|
| 18 | 18 | |
| 19 | -do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin ); |
|
| 19 | +do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin); |
|
| 20 | 20 | |
| 21 | -do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin ); |
|
| 21 | +do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin); |
|
| 22 | 22 | |
| 23 | -do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin ); |
|
| 23 | +do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin); |
|
| 24 | 24 | |
| 25 | -do_action( 'wpinv_email_after_note_details', $invoice, $email_type, $sent_to_admin, $customer_note ); |
|
| 25 | +do_action('wpinv_email_after_note_details', $invoice, $email_type, $sent_to_admin, $customer_note); |
|
| 26 | 26 | |
| 27 | -do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin ); |
|
| 28 | 27 | \ No newline at end of file |
| 28 | +do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin); |
|
| 29 | 29 | \ No newline at end of file |
@@ -8,22 +8,22 @@ discard block |
||
| 8 | 8 | * @var WPInv_Invoice $invoice |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -defined( 'ABSPATH' ) || exit; |
|
| 11 | +defined('ABSPATH') || exit; |
|
| 12 | 12 | |
| 13 | 13 | // Totals rows. |
| 14 | -$totals = getpaid_invoice_totals_rows( $invoice ); |
|
| 14 | +$totals = getpaid_invoice_totals_rows($invoice); |
|
| 15 | 15 | |
| 16 | -do_action( 'getpaid_before_email_line_totals', $invoice, $totals ); |
|
| 16 | +do_action('getpaid_before_email_line_totals', $invoice, $totals); |
|
| 17 | 17 | |
| 18 | 18 | ?> |
| 19 | 19 | |
| 20 | 20 | |
| 21 | -<?php if ( has_action( 'wpinv_email_footer_buttons' ) ) : ?> |
|
| 21 | +<?php if (has_action('wpinv_email_footer_buttons')) : ?> |
|
| 22 | 22 | |
| 23 | 23 | <tr class="wpinv_cart_footer_row"> |
| 24 | 24 | |
| 25 | - <td colspan="<?php echo ( (int) $column_count ); ?>"> |
|
| 26 | - <?php do_action( 'wpinv_email_footer_buttons' ); ?> |
|
| 25 | + <td colspan="<?php echo ((int) $column_count); ?>"> |
|
| 26 | + <?php do_action('wpinv_email_footer_buttons'); ?> |
|
| 27 | 27 | </td> |
| 28 | 28 | |
| 29 | 29 | </tr> |
@@ -31,44 +31,44 @@ discard block |
||
| 31 | 31 | <?php endif; ?> |
| 32 | 32 | |
| 33 | 33 | |
| 34 | -<?php foreach ( $totals as $key => $label ) : ?> |
|
| 34 | +<?php foreach ($totals as $key => $label) : ?> |
|
| 35 | 35 | |
| 36 | - <tr class="wpinv_cart_footer_row wpinv_cart_<?php echo sanitize_html_class( $key ); ?>_row"> |
|
| 36 | + <tr class="wpinv_cart_footer_row wpinv_cart_<?php echo sanitize_html_class($key); ?>_row"> |
|
| 37 | 37 | |
| 38 | - <td colspan="<?php echo ( $column_count - 1 ); ?>" class="wpinv_cart_<?php echo sanitize_html_class( $key ); ?>_label text-right"> |
|
| 39 | - <strong><?php echo sanitize_text_field( $label ); ?>:</strong> |
|
| 38 | + <td colspan="<?php echo ($column_count - 1); ?>" class="wpinv_cart_<?php echo sanitize_html_class($key); ?>_label text-right"> |
|
| 39 | + <strong><?php echo sanitize_text_field($label); ?>:</strong> |
|
| 40 | 40 | </td> |
| 41 | 41 | |
| 42 | - <td class="wpinv_cart_<?php echo sanitize_html_class( $key ); ?> text-right"> |
|
| 42 | + <td class="wpinv_cart_<?php echo sanitize_html_class($key); ?> text-right"> |
|
| 43 | 43 | |
| 44 | 44 | <?php |
| 45 | 45 | |
| 46 | 46 | // Total tax. |
| 47 | - if ( 'tax' == $key ) { |
|
| 48 | - echo wpinv_price( wpinv_format_amount( $invoice->get_total_tax() ), $invoice->get_currency() ); |
|
| 47 | + if ('tax' == $key) { |
|
| 48 | + echo wpinv_price(wpinv_format_amount($invoice->get_total_tax()), $invoice->get_currency()); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - if ( 'fee' == $key ) { |
|
| 52 | - echo wpinv_price( wpinv_format_amount( $invoice->get_total_fees() ), $invoice->get_currency() ); |
|
| 51 | + if ('fee' == $key) { |
|
| 52 | + echo wpinv_price(wpinv_format_amount($invoice->get_total_fees()), $invoice->get_currency()); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | // Total discount. |
| 56 | - if ( 'discount' == $key ) { |
|
| 57 | - echo wpinv_price( wpinv_format_amount( $invoice->get_total_discount() ), $invoice->get_currency() ); |
|
| 56 | + if ('discount' == $key) { |
|
| 57 | + echo wpinv_price(wpinv_format_amount($invoice->get_total_discount()), $invoice->get_currency()); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | // Sub total. |
| 61 | - if ( 'subtotal' == $key ) { |
|
| 62 | - echo wpinv_price( wpinv_format_amount( $invoice->get_subtotal() ), $invoice->get_currency() ); |
|
| 61 | + if ('subtotal' == $key) { |
|
| 62 | + echo wpinv_price(wpinv_format_amount($invoice->get_subtotal()), $invoice->get_currency()); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | // Total. |
| 66 | - if ( 'total' == $key ) { |
|
| 67 | - echo wpinv_price( wpinv_format_amount( $invoice->get_total() ), $invoice->get_currency() ); |
|
| 66 | + if ('total' == $key) { |
|
| 67 | + echo wpinv_price(wpinv_format_amount($invoice->get_total()), $invoice->get_currency()); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | // Fires when printing a cart total in an email. |
| 71 | - do_action( "getpaid_email_cart_totals_$key", $invoice ); |
|
| 71 | + do_action("getpaid_email_cart_totals_$key", $invoice); |
|
| 72 | 72 | |
| 73 | 73 | ?> |
| 74 | 74 | |
@@ -80,4 +80,4 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | <?php |
| 82 | 82 | |
| 83 | - do_action( 'getpaid_after_email_line_totals', $invoice, $totals ); |
|
| 83 | + do_action('getpaid_after_email_line_totals', $invoice, $totals); |
|
@@ -13,94 +13,94 @@ discard block |
||
| 13 | 13 | class GetPaid_Paypal_Gateway extends GetPaid_Payment_Gateway { |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | - * Payment method id. |
|
| 17 | - * |
|
| 18 | - * @var string |
|
| 19 | - */ |
|
| 16 | + * Payment method id. |
|
| 17 | + * |
|
| 18 | + * @var string |
|
| 19 | + */ |
|
| 20 | 20 | public $id = 'paypal'; |
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | - * An array of features that this gateway supports. |
|
| 24 | - * |
|
| 25 | - * @var array |
|
| 26 | - */ |
|
| 23 | + * An array of features that this gateway supports. |
|
| 24 | + * |
|
| 25 | + * @var array |
|
| 26 | + */ |
|
| 27 | 27 | protected $supports = array( 'subscription', 'sandbox' ); |
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | - * Payment method order. |
|
| 31 | - * |
|
| 32 | - * @var int |
|
| 33 | - */ |
|
| 30 | + * Payment method order. |
|
| 31 | + * |
|
| 32 | + * @var int |
|
| 33 | + */ |
|
| 34 | 34 | public $order = 1; |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | - * Stores line items to send to PayPal. |
|
| 38 | - * |
|
| 39 | - * @var array |
|
| 40 | - */ |
|
| 37 | + * Stores line items to send to PayPal. |
|
| 38 | + * |
|
| 39 | + * @var array |
|
| 40 | + */ |
|
| 41 | 41 | protected $line_items = array(); |
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | - * Endpoint for requests from PayPal. |
|
| 45 | - * |
|
| 46 | - * @var string |
|
| 47 | - */ |
|
| 48 | - protected $notify_url; |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * Endpoint for requests to PayPal. |
|
| 52 | - * |
|
| 53 | - * @var string |
|
| 54 | - */ |
|
| 44 | + * Endpoint for requests from PayPal. |
|
| 45 | + * |
|
| 46 | + * @var string |
|
| 47 | + */ |
|
| 48 | + protected $notify_url; |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * Endpoint for requests to PayPal. |
|
| 52 | + * |
|
| 53 | + * @var string |
|
| 54 | + */ |
|
| 55 | 55 | protected $endpoint; |
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | - * Currencies this gateway is allowed for. |
|
| 59 | - * |
|
| 60 | - * @var array |
|
| 61 | - */ |
|
| 62 | - public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' ); |
|
| 58 | + * Currencies this gateway is allowed for. |
|
| 59 | + * |
|
| 60 | + * @var array |
|
| 61 | + */ |
|
| 62 | + public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' ); |
|
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | - * URL to view a transaction. |
|
| 66 | - * |
|
| 67 | - * @var string |
|
| 68 | - */ |
|
| 65 | + * URL to view a transaction. |
|
| 66 | + * |
|
| 67 | + * @var string |
|
| 68 | + */ |
|
| 69 | 69 | public $view_transaction_url = 'https://www.{sandbox}paypal.com/activity/payment/%s'; |
| 70 | 70 | |
| 71 | 71 | /** |
| 72 | - * URL to view a subscription. |
|
| 73 | - * |
|
| 74 | - * @var string |
|
| 75 | - */ |
|
| 76 | - public $view_subscription_url = 'https://www.{sandbox}paypal.com/cgi-bin/webscr?cmd=_profile-recurring-payments&encrypted_profile_id=%s'; |
|
| 72 | + * URL to view a subscription. |
|
| 73 | + * |
|
| 74 | + * @var string |
|
| 75 | + */ |
|
| 76 | + public $view_subscription_url = 'https://www.{sandbox}paypal.com/cgi-bin/webscr?cmd=_profile-recurring-payments&encrypted_profile_id=%s'; |
|
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | - * Class constructor. |
|
| 80 | - */ |
|
| 81 | - public function __construct() { |
|
| 79 | + * Class constructor. |
|
| 80 | + */ |
|
| 81 | + public function __construct() { |
|
| 82 | 82 | |
| 83 | 83 | $this->title = __( 'PayPal Standard', 'invoicing' ); |
| 84 | 84 | $this->method_title = __( 'PayPal Standard', 'invoicing' ); |
| 85 | 85 | $this->checkout_button_text = __( 'Proceed to PayPal', 'invoicing' ); |
| 86 | 86 | $this->notify_url = wpinv_get_ipn_url( $this->id ); |
| 87 | 87 | |
| 88 | - add_filter( 'getpaid_paypal_args', array( $this, 'process_subscription' ), 10, 2 ); |
|
| 88 | + add_filter( 'getpaid_paypal_args', array( $this, 'process_subscription' ), 10, 2 ); |
|
| 89 | 89 | add_filter( 'getpaid_paypal_sandbox_notice', array( $this, 'sandbox_notice' ) ); |
| 90 | 90 | |
| 91 | 91 | parent::__construct(); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /** |
| 95 | - * Process Payment. |
|
| 96 | - * |
|
| 97 | - * |
|
| 98 | - * @param WPInv_Invoice $invoice Invoice. |
|
| 99 | - * @param array $submission_data Posted checkout fields. |
|
| 100 | - * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
| 101 | - * @return array |
|
| 102 | - */ |
|
| 103 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
| 95 | + * Process Payment. |
|
| 96 | + * |
|
| 97 | + * |
|
| 98 | + * @param WPInv_Invoice $invoice Invoice. |
|
| 99 | + * @param array $submission_data Posted checkout fields. |
|
| 100 | + * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
| 101 | + * @return array |
|
| 102 | + */ |
|
| 103 | + public function process_payment( $invoice, $submission_data, $submission ) { |
|
| 104 | 104 | |
| 105 | 105 | // Get redirect url. |
| 106 | 106 | $paypal_redirect = $this->get_request_url( $invoice ); |
@@ -123,15 +123,15 @@ discard block |
||
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | /** |
| 126 | - * Get the PayPal request URL for an invoice. |
|
| 127 | - * |
|
| 128 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 129 | - * @return string |
|
| 130 | - */ |
|
| 131 | - public function get_request_url( $invoice ) { |
|
| 126 | + * Get the PayPal request URL for an invoice. |
|
| 127 | + * |
|
| 128 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 129 | + * @return string |
|
| 130 | + */ |
|
| 131 | + public function get_request_url( $invoice ) { |
|
| 132 | 132 | |
| 133 | 133 | // Endpoint for this request |
| 134 | - $this->endpoint = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?'; |
|
| 134 | + $this->endpoint = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?'; |
|
| 135 | 135 | |
| 136 | 136 | // Retrieve paypal args. |
| 137 | 137 | $paypal_args = map_deep( $this->get_paypal_args( $invoice ), 'urlencode' ); |
@@ -144,44 +144,44 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | return add_query_arg( $paypal_args, $this->endpoint ); |
| 146 | 146 | |
| 147 | - } |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | 149 | /** |
| 150 | - * Get PayPal Args for passing to PP. |
|
| 151 | - * |
|
| 152 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 153 | - * @return array |
|
| 154 | - */ |
|
| 155 | - protected function get_paypal_args( $invoice ) { |
|
| 150 | + * Get PayPal Args for passing to PP. |
|
| 151 | + * |
|
| 152 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 153 | + * @return array |
|
| 154 | + */ |
|
| 155 | + protected function get_paypal_args( $invoice ) { |
|
| 156 | 156 | |
| 157 | 157 | // Whether or not to send the line items as one item. |
| 158 | - $force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', false, $invoice ); |
|
| 159 | - |
|
| 160 | - if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) { |
|
| 161 | - $force_one_line_item = true; |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - $paypal_args = apply_filters( |
|
| 165 | - 'getpaid_paypal_args', |
|
| 166 | - array_merge( |
|
| 167 | - $this->get_transaction_args( $invoice ), |
|
| 168 | - $this->get_line_item_args( $invoice, $force_one_line_item ) |
|
| 169 | - ), |
|
| 170 | - $invoice |
|
| 171 | - ); |
|
| 172 | - |
|
| 173 | - return $this->fix_request_length( $invoice, $paypal_args ); |
|
| 158 | + $force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', false, $invoice ); |
|
| 159 | + |
|
| 160 | + if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) { |
|
| 161 | + $force_one_line_item = true; |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + $paypal_args = apply_filters( |
|
| 165 | + 'getpaid_paypal_args', |
|
| 166 | + array_merge( |
|
| 167 | + $this->get_transaction_args( $invoice ), |
|
| 168 | + $this->get_line_item_args( $invoice, $force_one_line_item ) |
|
| 169 | + ), |
|
| 170 | + $invoice |
|
| 171 | + ); |
|
| 172 | + |
|
| 173 | + return $this->fix_request_length( $invoice, $paypal_args ); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
| 177 | - * Get transaction args for paypal request. |
|
| 178 | - * |
|
| 179 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 180 | - * @return array |
|
| 181 | - */ |
|
| 182 | - protected function get_transaction_args( $invoice ) { |
|
| 183 | - |
|
| 184 | - return array( |
|
| 177 | + * Get transaction args for paypal request. |
|
| 178 | + * |
|
| 179 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 180 | + * @return array |
|
| 181 | + */ |
|
| 182 | + protected function get_transaction_args( $invoice ) { |
|
| 183 | + |
|
| 184 | + return array( |
|
| 185 | 185 | 'cmd' => '_cart', |
| 186 | 186 | 'business' => wpinv_get_option( 'paypal_email', false ), |
| 187 | 187 | 'no_shipping' => '1', |
@@ -206,16 +206,16 @@ discard block |
||
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | /** |
| 209 | - * Get line item args for paypal request. |
|
| 210 | - * |
|
| 211 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 212 | - * @param bool $force_one_line_item Create only one item for this invoice. |
|
| 213 | - * @return array |
|
| 214 | - */ |
|
| 215 | - protected function get_line_item_args( $invoice, $force_one_line_item = false ) { |
|
| 209 | + * Get line item args for paypal request. |
|
| 210 | + * |
|
| 211 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 212 | + * @param bool $force_one_line_item Create only one item for this invoice. |
|
| 213 | + * @return array |
|
| 214 | + */ |
|
| 215 | + protected function get_line_item_args( $invoice, $force_one_line_item = false ) { |
|
| 216 | 216 | |
| 217 | 217 | // Maybe send invoice as a single item. |
| 218 | - if ( $force_one_line_item ) { |
|
| 218 | + if ( $force_one_line_item ) { |
|
| 219 | 219 | return $this->get_line_item_args_single_item( $invoice ); |
| 220 | 220 | } |
| 221 | 221 | |
@@ -235,129 +235,129 @@ discard block |
||
| 235 | 235 | $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_discount(), 2 ); |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - return array_merge( $line_item_args, $this->get_line_items() ); |
|
| 238 | + return array_merge( $line_item_args, $this->get_line_items() ); |
|
| 239 | 239 | |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /** |
| 243 | - * Get line item args for paypal request as a single line item. |
|
| 244 | - * |
|
| 245 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 246 | - * @return array |
|
| 247 | - */ |
|
| 248 | - protected function get_line_item_args_single_item( $invoice ) { |
|
| 249 | - $this->delete_line_items(); |
|
| 243 | + * Get line item args for paypal request as a single line item. |
|
| 244 | + * |
|
| 245 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 246 | + * @return array |
|
| 247 | + */ |
|
| 248 | + protected function get_line_item_args_single_item( $invoice ) { |
|
| 249 | + $this->delete_line_items(); |
|
| 250 | 250 | |
| 251 | 251 | $item_name = sprintf( __( 'Invoice #%s', 'invoicing' ), $invoice->get_number() ); |
| 252 | - $this->add_line_item( $item_name, 1, wpinv_sanitize_amount( (float) $invoice->get_total(), 2 ), $invoice->get_id() ); |
|
| 252 | + $this->add_line_item( $item_name, 1, wpinv_sanitize_amount( (float) $invoice->get_total(), 2 ), $invoice->get_id() ); |
|
| 253 | 253 | |
| 254 | - return $this->get_line_items(); |
|
| 254 | + return $this->get_line_items(); |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | /** |
| 258 | - * Return all line items. |
|
| 259 | - */ |
|
| 260 | - protected function get_line_items() { |
|
| 261 | - return $this->line_items; |
|
| 262 | - } |
|
| 258 | + * Return all line items. |
|
| 259 | + */ |
|
| 260 | + protected function get_line_items() { |
|
| 261 | + return $this->line_items; |
|
| 262 | + } |
|
| 263 | 263 | |
| 264 | 264 | /** |
| 265 | - * Remove all line items. |
|
| 266 | - */ |
|
| 267 | - protected function delete_line_items() { |
|
| 268 | - $this->line_items = array(); |
|
| 265 | + * Remove all line items. |
|
| 266 | + */ |
|
| 267 | + protected function delete_line_items() { |
|
| 268 | + $this->line_items = array(); |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | /** |
| 272 | - * Prepare line items to send to paypal. |
|
| 273 | - * |
|
| 274 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 275 | - */ |
|
| 276 | - protected function prepare_line_items( $invoice ) { |
|
| 277 | - $this->delete_line_items(); |
|
| 278 | - |
|
| 279 | - // Items. |
|
| 280 | - foreach ( $invoice->get_items() as $item ) { |
|
| 281 | - $amount = $invoice->get_template() == 'amount' ? $item->get_price() : $item->get_sub_total(); |
|
| 282 | - $quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity(); |
|
| 283 | - $this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() ); |
|
| 272 | + * Prepare line items to send to paypal. |
|
| 273 | + * |
|
| 274 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 275 | + */ |
|
| 276 | + protected function prepare_line_items( $invoice ) { |
|
| 277 | + $this->delete_line_items(); |
|
| 278 | + |
|
| 279 | + // Items. |
|
| 280 | + foreach ( $invoice->get_items() as $item ) { |
|
| 281 | + $amount = $invoice->get_template() == 'amount' ? $item->get_price() : $item->get_sub_total(); |
|
| 282 | + $quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity(); |
|
| 283 | + $this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() ); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | // Fees. |
| 287 | - foreach ( $invoice->get_fees() as $fee => $data ) { |
|
| 287 | + foreach ( $invoice->get_fees() as $fee => $data ) { |
|
| 288 | 288 | $this->add_line_item( $fee, 1, wpinv_sanitize_amount( $data['initial_fee'] ) ); |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | /** |
| 294 | - * Add PayPal Line Item. |
|
| 295 | - * |
|
| 296 | - * @param string $item_name Item name. |
|
| 297 | - * @param int $quantity Item quantity. |
|
| 298 | - * @param float $amount Amount. |
|
| 299 | - * @param string $item_number Item number. |
|
| 300 | - */ |
|
| 301 | - protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) { |
|
| 302 | - $index = ( count( $this->line_items ) / 4 ) + 1; |
|
| 303 | - |
|
| 304 | - $item = apply_filters( |
|
| 305 | - 'getpaid_paypal_line_item', |
|
| 306 | - array( |
|
| 307 | - 'item_name' => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ), |
|
| 308 | - 'quantity' => (int) $quantity, |
|
| 309 | - 'amount' => wpinv_sanitize_amount( (float) $amount, 2 ), |
|
| 310 | - 'item_number' => $item_number, |
|
| 311 | - ), |
|
| 312 | - $item_name, |
|
| 313 | - $quantity, |
|
| 314 | - $amount, |
|
| 315 | - $item_number |
|
| 316 | - ); |
|
| 317 | - |
|
| 318 | - $this->line_items[ 'item_name_' . $index ] = getpaid_limit_length( $item['item_name'], 127 ); |
|
| 294 | + * Add PayPal Line Item. |
|
| 295 | + * |
|
| 296 | + * @param string $item_name Item name. |
|
| 297 | + * @param int $quantity Item quantity. |
|
| 298 | + * @param float $amount Amount. |
|
| 299 | + * @param string $item_number Item number. |
|
| 300 | + */ |
|
| 301 | + protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) { |
|
| 302 | + $index = ( count( $this->line_items ) / 4 ) + 1; |
|
| 303 | + |
|
| 304 | + $item = apply_filters( |
|
| 305 | + 'getpaid_paypal_line_item', |
|
| 306 | + array( |
|
| 307 | + 'item_name' => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ), |
|
| 308 | + 'quantity' => (int) $quantity, |
|
| 309 | + 'amount' => wpinv_sanitize_amount( (float) $amount, 2 ), |
|
| 310 | + 'item_number' => $item_number, |
|
| 311 | + ), |
|
| 312 | + $item_name, |
|
| 313 | + $quantity, |
|
| 314 | + $amount, |
|
| 315 | + $item_number |
|
| 316 | + ); |
|
| 317 | + |
|
| 318 | + $this->line_items[ 'item_name_' . $index ] = getpaid_limit_length( $item['item_name'], 127 ); |
|
| 319 | 319 | $this->line_items[ 'quantity_' . $index ] = $item['quantity']; |
| 320 | 320 | |
| 321 | 321 | // The price or amount of the product, service, or contribution, not including shipping, handling, or tax. |
| 322 | - $this->line_items[ 'amount_' . $index ] = $item['amount']; |
|
| 323 | - $this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 ); |
|
| 322 | + $this->line_items[ 'amount_' . $index ] = $item['amount']; |
|
| 323 | + $this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 ); |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | /** |
| 327 | - * If the default request with line items is too long, generate a new one with only one line item. |
|
| 328 | - * |
|
| 329 | - * https://support.microsoft.com/en-us/help/208427/maximum-url-length-is-2-083-characters-in-internet-explorer. |
|
| 330 | - * |
|
| 331 | - * @param WPInv_Invoice $invoice Invoice to be sent to Paypal. |
|
| 332 | - * @param array $paypal_args Arguments sent to Paypal in the request. |
|
| 333 | - * @return array |
|
| 334 | - */ |
|
| 335 | - protected function fix_request_length( $invoice, $paypal_args ) { |
|
| 336 | - $max_paypal_length = 2083; |
|
| 337 | - $query_candidate = http_build_query( $paypal_args, '', '&' ); |
|
| 338 | - |
|
| 339 | - if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) { |
|
| 340 | - return $paypal_args; |
|
| 341 | - } |
|
| 342 | - |
|
| 343 | - return apply_filters( |
|
| 344 | - 'getpaid_paypal_args', |
|
| 345 | - array_merge( |
|
| 346 | - $this->get_transaction_args( $invoice ), |
|
| 347 | - $this->get_line_item_args( $invoice, true ) |
|
| 348 | - ), |
|
| 349 | - $invoice |
|
| 350 | - ); |
|
| 327 | + * If the default request with line items is too long, generate a new one with only one line item. |
|
| 328 | + * |
|
| 329 | + * https://support.microsoft.com/en-us/help/208427/maximum-url-length-is-2-083-characters-in-internet-explorer. |
|
| 330 | + * |
|
| 331 | + * @param WPInv_Invoice $invoice Invoice to be sent to Paypal. |
|
| 332 | + * @param array $paypal_args Arguments sent to Paypal in the request. |
|
| 333 | + * @return array |
|
| 334 | + */ |
|
| 335 | + protected function fix_request_length( $invoice, $paypal_args ) { |
|
| 336 | + $max_paypal_length = 2083; |
|
| 337 | + $query_candidate = http_build_query( $paypal_args, '', '&' ); |
|
| 338 | + |
|
| 339 | + if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) { |
|
| 340 | + return $paypal_args; |
|
| 341 | + } |
|
| 342 | + |
|
| 343 | + return apply_filters( |
|
| 344 | + 'getpaid_paypal_args', |
|
| 345 | + array_merge( |
|
| 346 | + $this->get_transaction_args( $invoice ), |
|
| 347 | + $this->get_line_item_args( $invoice, true ) |
|
| 348 | + ), |
|
| 349 | + $invoice |
|
| 350 | + ); |
|
| 351 | 351 | |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | /** |
| 355 | - * Processes recurring invoices. |
|
| 356 | - * |
|
| 357 | - * @param array $paypal_args PayPal args. |
|
| 358 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 359 | - */ |
|
| 360 | - public function process_subscription( $paypal_args, $invoice ) { |
|
| 355 | + * Processes recurring invoices. |
|
| 356 | + * |
|
| 357 | + * @param array $paypal_args PayPal args. |
|
| 358 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 359 | + */ |
|
| 360 | + public function process_subscription( $paypal_args, $invoice ) { |
|
| 361 | 361 | |
| 362 | 362 | // Make sure this is a subscription. |
| 363 | 363 | if ( ! $invoice->is_recurring() || ! $subscription = wpinv_get_subscription( $invoice ) ) { |
@@ -382,11 +382,11 @@ discard block |
||
| 382 | 382 | |
| 383 | 383 | $paypal_args['a1'] = 0 == $initial_amount ? 0 : $initial_amount; |
| 384 | 384 | |
| 385 | - // Trial period length. |
|
| 386 | - $paypal_args['p1'] = $subscription_item->get_trial_interval(); |
|
| 385 | + // Trial period length. |
|
| 386 | + $paypal_args['p1'] = $subscription_item->get_trial_interval(); |
|
| 387 | 387 | |
| 388 | - // Trial period. |
|
| 389 | - $paypal_args['t1'] = $subscription_item->get_trial_period(); |
|
| 388 | + // Trial period. |
|
| 389 | + $paypal_args['t1'] = $subscription_item->get_trial_period(); |
|
| 390 | 390 | |
| 391 | 391 | } else if ( $initial_amount != $recurring_amount ) { |
| 392 | 392 | |
@@ -409,40 +409,40 @@ discard block |
||
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | // We have a recurring payment |
| 412 | - if ( ! isset( $param_number ) || 1 == $param_number ) { |
|
| 412 | + if ( ! isset( $param_number ) || 1 == $param_number ) { |
|
| 413 | 413 | |
| 414 | - // Subscription price |
|
| 415 | - $paypal_args['a3'] = $recurring_amount; |
|
| 414 | + // Subscription price |
|
| 415 | + $paypal_args['a3'] = $recurring_amount; |
|
| 416 | 416 | |
| 417 | - // Subscription duration |
|
| 418 | - $paypal_args['p3'] = $interval; |
|
| 417 | + // Subscription duration |
|
| 418 | + $paypal_args['p3'] = $interval; |
|
| 419 | 419 | |
| 420 | - // Subscription period |
|
| 421 | - $paypal_args['t3'] = $period; |
|
| 420 | + // Subscription period |
|
| 421 | + $paypal_args['t3'] = $period; |
|
| 422 | 422 | |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | // Recurring payments |
| 426 | - if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) { |
|
| 426 | + if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) { |
|
| 427 | 427 | |
| 428 | - // Non-recurring payments |
|
| 429 | - $paypal_args['src'] = 0; |
|
| 428 | + // Non-recurring payments |
|
| 429 | + $paypal_args['src'] = 0; |
|
| 430 | 430 | |
| 431 | - } else { |
|
| 431 | + } else { |
|
| 432 | 432 | |
| 433 | - $paypal_args['src'] = 1; |
|
| 433 | + $paypal_args['src'] = 1; |
|
| 434 | 434 | |
| 435 | - if ( $bill_times > 0 ) { |
|
| 435 | + if ( $bill_times > 0 ) { |
|
| 436 | 436 | |
| 437 | - // An initial period is being used to charge a sign-up fee |
|
| 438 | - if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) { |
|
| 439 | - $bill_times--; |
|
| 440 | - } |
|
| 437 | + // An initial period is being used to charge a sign-up fee |
|
| 438 | + if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) { |
|
| 439 | + $bill_times--; |
|
| 440 | + } |
|
| 441 | 441 | |
| 442 | 442 | // Make sure it's not over the max of 52 |
| 443 | 443 | $paypal_args['srt'] = ( $bill_times <= 52 ? absint( $bill_times ) : 52 ); |
| 444 | 444 | |
| 445 | - } |
|
| 445 | + } |
|
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | // Force return URL so that order description & instructions display |
@@ -458,19 +458,19 @@ discard block |
||
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | return apply_filters( |
| 461 | - 'getpaid_paypal_subscription_args', |
|
| 462 | - $paypal_args, |
|
| 463 | - $invoice |
|
| 461 | + 'getpaid_paypal_subscription_args', |
|
| 462 | + $paypal_args, |
|
| 463 | + $invoice |
|
| 464 | 464 | ); |
| 465 | 465 | |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | /** |
| 469 | - * Processes ipns and marks payments as complete. |
|
| 470 | - * |
|
| 471 | - * @return void |
|
| 472 | - */ |
|
| 473 | - public function verify_ipn() { |
|
| 469 | + * Processes ipns and marks payments as complete. |
|
| 470 | + * |
|
| 471 | + * @return void |
|
| 472 | + */ |
|
| 473 | + public function verify_ipn() { |
|
| 474 | 474 | new GetPaid_Paypal_Gateway_IPN_Handler( $this ); |
| 475 | 475 | } |
| 476 | 476 | |
@@ -480,10 +480,10 @@ discard block |
||
| 480 | 480 | public function sandbox_notice() { |
| 481 | 481 | |
| 482 | 482 | return sprintf( |
| 483 | - __( 'SANDBOX ENABLED. You can use sandbox testing accounts only. See the %sPayPal Sandbox Testing Guide%s for more details.', 'invoicing' ), |
|
| 484 | - '<a href="https://developer.paypal.com/docs/classic/lifecycle/ug_sandbox/">', |
|
| 485 | - '</a>' |
|
| 486 | - ); |
|
| 483 | + __( 'SANDBOX ENABLED. You can use sandbox testing accounts only. See the %sPayPal Sandbox Testing Guide%s for more details.', 'invoicing' ), |
|
| 484 | + '<a href="https://developer.paypal.com/docs/classic/lifecycle/ug_sandbox/">', |
|
| 485 | + '</a>' |
|
| 486 | + ); |
|
| 487 | 487 | |
| 488 | 488 | } |
| 489 | 489 | |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | -defined( 'ABSPATH' ) || exit; |
|
| 7 | +defined('ABSPATH') || exit; |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Paypal Payment Gateway class. |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * @var array |
| 26 | 26 | */ |
| 27 | - protected $supports = array( 'subscription', 'sandbox' ); |
|
| 27 | + protected $supports = array('subscription', 'sandbox'); |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * Payment method order. |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * |
| 60 | 60 | * @var array |
| 61 | 61 | */ |
| 62 | - public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' ); |
|
| 62 | + public $currencies = array('AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR'); |
|
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | 65 | * URL to view a transaction. |
@@ -80,13 +80,13 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | public function __construct() { |
| 82 | 82 | |
| 83 | - $this->title = __( 'PayPal Standard', 'invoicing' ); |
|
| 84 | - $this->method_title = __( 'PayPal Standard', 'invoicing' ); |
|
| 85 | - $this->checkout_button_text = __( 'Proceed to PayPal', 'invoicing' ); |
|
| 86 | - $this->notify_url = wpinv_get_ipn_url( $this->id ); |
|
| 83 | + $this->title = __('PayPal Standard', 'invoicing'); |
|
| 84 | + $this->method_title = __('PayPal Standard', 'invoicing'); |
|
| 85 | + $this->checkout_button_text = __('Proceed to PayPal', 'invoicing'); |
|
| 86 | + $this->notify_url = wpinv_get_ipn_url($this->id); |
|
| 87 | 87 | |
| 88 | - add_filter( 'getpaid_paypal_args', array( $this, 'process_subscription' ), 10, 2 ); |
|
| 89 | - add_filter( 'getpaid_paypal_sandbox_notice', array( $this, 'sandbox_notice' ) ); |
|
| 88 | + add_filter('getpaid_paypal_args', array($this, 'process_subscription'), 10, 2); |
|
| 89 | + add_filter('getpaid_paypal_sandbox_notice', array($this, 'sandbox_notice')); |
|
| 90 | 90 | |
| 91 | 91 | parent::__construct(); |
| 92 | 92 | } |
@@ -100,16 +100,16 @@ discard block |
||
| 100 | 100 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
| 101 | 101 | * @return array |
| 102 | 102 | */ |
| 103 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
| 103 | + public function process_payment($invoice, $submission_data, $submission) { |
|
| 104 | 104 | |
| 105 | 105 | // Get redirect url. |
| 106 | - $paypal_redirect = $this->get_request_url( $invoice ); |
|
| 106 | + $paypal_redirect = $this->get_request_url($invoice); |
|
| 107 | 107 | |
| 108 | 108 | // Add a note about the request url. |
| 109 | 109 | $invoice->add_note( |
| 110 | 110 | sprintf( |
| 111 | - __( 'Redirecting to PayPal: %s', 'invoicing' ), |
|
| 112 | - esc_url( $paypal_redirect ) |
|
| 111 | + __('Redirecting to PayPal: %s', 'invoicing'), |
|
| 112 | + esc_url($paypal_redirect) |
|
| 113 | 113 | ), |
| 114 | 114 | false, |
| 115 | 115 | false, |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | ); |
| 118 | 118 | |
| 119 | 119 | // Redirect to PayPal |
| 120 | - wp_redirect( $paypal_redirect ); |
|
| 120 | + wp_redirect($paypal_redirect); |
|
| 121 | 121 | exit; |
| 122 | 122 | |
| 123 | 123 | } |
@@ -128,21 +128,21 @@ discard block |
||
| 128 | 128 | * @param WPInv_Invoice $invoice Invoice object. |
| 129 | 129 | * @return string |
| 130 | 130 | */ |
| 131 | - public function get_request_url( $invoice ) { |
|
| 131 | + public function get_request_url($invoice) { |
|
| 132 | 132 | |
| 133 | 133 | // Endpoint for this request |
| 134 | - $this->endpoint = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?'; |
|
| 134 | + $this->endpoint = $this->is_sandbox($invoice) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?'; |
|
| 135 | 135 | |
| 136 | 136 | // Retrieve paypal args. |
| 137 | - $paypal_args = map_deep( $this->get_paypal_args( $invoice ), 'urlencode' ); |
|
| 137 | + $paypal_args = map_deep($this->get_paypal_args($invoice), 'urlencode'); |
|
| 138 | 138 | |
| 139 | - if ( $invoice->is_recurring() ) { |
|
| 139 | + if ($invoice->is_recurring()) { |
|
| 140 | 140 | $paypal_args['bn'] = 'GetPaid_Subscribe_WPS_US'; |
| 141 | 141 | } else { |
| 142 | 142 | $paypal_args['bn'] = 'GetPaid_ShoppingCart_WPS_US'; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - return add_query_arg( $paypal_args, $this->endpoint ); |
|
| 145 | + return add_query_arg($paypal_args, $this->endpoint); |
|
| 146 | 146 | |
| 147 | 147 | } |
| 148 | 148 | |
@@ -152,25 +152,25 @@ discard block |
||
| 152 | 152 | * @param WPInv_Invoice $invoice Invoice object. |
| 153 | 153 | * @return array |
| 154 | 154 | */ |
| 155 | - protected function get_paypal_args( $invoice ) { |
|
| 155 | + protected function get_paypal_args($invoice) { |
|
| 156 | 156 | |
| 157 | 157 | // Whether or not to send the line items as one item. |
| 158 | - $force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', false, $invoice ); |
|
| 158 | + $force_one_line_item = apply_filters('getpaid_paypal_force_one_line_item', false, $invoice); |
|
| 159 | 159 | |
| 160 | - if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) { |
|
| 160 | + if ($invoice->is_recurring() || (wpinv_use_taxes() && wpinv_prices_include_tax())) { |
|
| 161 | 161 | $force_one_line_item = true; |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | $paypal_args = apply_filters( |
| 165 | 165 | 'getpaid_paypal_args', |
| 166 | 166 | array_merge( |
| 167 | - $this->get_transaction_args( $invoice ), |
|
| 168 | - $this->get_line_item_args( $invoice, $force_one_line_item ) |
|
| 167 | + $this->get_transaction_args($invoice), |
|
| 168 | + $this->get_line_item_args($invoice, $force_one_line_item) |
|
| 169 | 169 | ), |
| 170 | 170 | $invoice |
| 171 | 171 | ); |
| 172 | 172 | |
| 173 | - return $this->fix_request_length( $invoice, $paypal_args ); |
|
| 173 | + return $this->fix_request_length($invoice, $paypal_args); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
@@ -179,11 +179,11 @@ discard block |
||
| 179 | 179 | * @param WPInv_Invoice $invoice Invoice object. |
| 180 | 180 | * @return array |
| 181 | 181 | */ |
| 182 | - protected function get_transaction_args( $invoice ) { |
|
| 182 | + protected function get_transaction_args($invoice) { |
|
| 183 | 183 | |
| 184 | 184 | return array( |
| 185 | 185 | 'cmd' => '_cart', |
| 186 | - 'business' => wpinv_get_option( 'paypal_email', false ), |
|
| 186 | + 'business' => wpinv_get_option('paypal_email', false), |
|
| 187 | 187 | 'no_shipping' => '1', |
| 188 | 188 | 'shipping' => '0', |
| 189 | 189 | 'no_note' => '1', |
@@ -191,16 +191,16 @@ discard block |
||
| 191 | 191 | 'rm' => is_ssl() ? 2 : 1, |
| 192 | 192 | 'upload' => 1, |
| 193 | 193 | 'currency_code' => $invoice->get_currency(), // https://developer.paypal.com/docs/nvp-soap-api/currency-codes/#paypal |
| 194 | - 'return' => esc_url_raw( $this->get_return_url( $invoice ) ), |
|
| 195 | - 'cancel_return' => esc_url_raw( $invoice->get_checkout_payment_url() ), |
|
| 196 | - 'notify_url' => getpaid_limit_length( $this->notify_url, 255 ), |
|
| 197 | - 'invoice' => getpaid_limit_length( $invoice->get_number(), 127 ), |
|
| 194 | + 'return' => esc_url_raw($this->get_return_url($invoice)), |
|
| 195 | + 'cancel_return' => esc_url_raw($invoice->get_checkout_payment_url()), |
|
| 196 | + 'notify_url' => getpaid_limit_length($this->notify_url, 255), |
|
| 197 | + 'invoice' => getpaid_limit_length($invoice->get_number(), 127), |
|
| 198 | 198 | 'custom' => $invoice->get_id(), |
| 199 | - 'first_name' => getpaid_limit_length( $invoice->get_first_name(), 32 ), |
|
| 200 | - 'last_name' => getpaid_limit_length( $invoice->get_last_name(), 64 ), |
|
| 201 | - 'country' => getpaid_limit_length( $invoice->get_country(), 2 ), |
|
| 202 | - 'email' => getpaid_limit_length( $invoice->get_email(), 127 ), |
|
| 203 | - 'cbt' => get_bloginfo( 'name' ) |
|
| 199 | + 'first_name' => getpaid_limit_length($invoice->get_first_name(), 32), |
|
| 200 | + 'last_name' => getpaid_limit_length($invoice->get_last_name(), 64), |
|
| 201 | + 'country' => getpaid_limit_length($invoice->get_country(), 2), |
|
| 202 | + 'email' => getpaid_limit_length($invoice->get_email(), 127), |
|
| 203 | + 'cbt' => get_bloginfo('name') |
|
| 204 | 204 | ); |
| 205 | 205 | |
| 206 | 206 | } |
@@ -212,30 +212,30 @@ discard block |
||
| 212 | 212 | * @param bool $force_one_line_item Create only one item for this invoice. |
| 213 | 213 | * @return array |
| 214 | 214 | */ |
| 215 | - protected function get_line_item_args( $invoice, $force_one_line_item = false ) { |
|
| 215 | + protected function get_line_item_args($invoice, $force_one_line_item = false) { |
|
| 216 | 216 | |
| 217 | 217 | // Maybe send invoice as a single item. |
| 218 | - if ( $force_one_line_item ) { |
|
| 219 | - return $this->get_line_item_args_single_item( $invoice ); |
|
| 218 | + if ($force_one_line_item) { |
|
| 219 | + return $this->get_line_item_args_single_item($invoice); |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | // Send each line item individually. |
| 223 | 223 | $line_item_args = array(); |
| 224 | 224 | |
| 225 | 225 | // Prepare line items. |
| 226 | - $this->prepare_line_items( $invoice ); |
|
| 226 | + $this->prepare_line_items($invoice); |
|
| 227 | 227 | |
| 228 | 228 | // Add taxes to the cart |
| 229 | - if ( wpinv_use_taxes() && $invoice->is_taxable() ) { |
|
| 230 | - $line_item_args['tax_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_tax(), 2 ); |
|
| 229 | + if (wpinv_use_taxes() && $invoice->is_taxable()) { |
|
| 230 | + $line_item_args['tax_cart'] = wpinv_sanitize_amount((float) $invoice->get_total_tax(), 2); |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | // Add discount. |
| 234 | - if ( $invoice->get_total_discount() > 0 ) { |
|
| 235 | - $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_discount(), 2 ); |
|
| 234 | + if ($invoice->get_total_discount() > 0) { |
|
| 235 | + $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount((float) $invoice->get_total_discount(), 2); |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - return array_merge( $line_item_args, $this->get_line_items() ); |
|
| 238 | + return array_merge($line_item_args, $this->get_line_items()); |
|
| 239 | 239 | |
| 240 | 240 | } |
| 241 | 241 | |
@@ -245,11 +245,11 @@ discard block |
||
| 245 | 245 | * @param WPInv_Invoice $invoice Invoice object. |
| 246 | 246 | * @return array |
| 247 | 247 | */ |
| 248 | - protected function get_line_item_args_single_item( $invoice ) { |
|
| 248 | + protected function get_line_item_args_single_item($invoice) { |
|
| 249 | 249 | $this->delete_line_items(); |
| 250 | 250 | |
| 251 | - $item_name = sprintf( __( 'Invoice #%s', 'invoicing' ), $invoice->get_number() ); |
|
| 252 | - $this->add_line_item( $item_name, 1, wpinv_sanitize_amount( (float) $invoice->get_total(), 2 ), $invoice->get_id() ); |
|
| 251 | + $item_name = sprintf(__('Invoice #%s', 'invoicing'), $invoice->get_number()); |
|
| 252 | + $this->add_line_item($item_name, 1, wpinv_sanitize_amount((float) $invoice->get_total(), 2), $invoice->get_id()); |
|
| 253 | 253 | |
| 254 | 254 | return $this->get_line_items(); |
| 255 | 255 | } |
@@ -273,19 +273,19 @@ discard block |
||
| 273 | 273 | * |
| 274 | 274 | * @param WPInv_Invoice $invoice Invoice object. |
| 275 | 275 | */ |
| 276 | - protected function prepare_line_items( $invoice ) { |
|
| 276 | + protected function prepare_line_items($invoice) { |
|
| 277 | 277 | $this->delete_line_items(); |
| 278 | 278 | |
| 279 | 279 | // Items. |
| 280 | - foreach ( $invoice->get_items() as $item ) { |
|
| 280 | + foreach ($invoice->get_items() as $item) { |
|
| 281 | 281 | $amount = $invoice->get_template() == 'amount' ? $item->get_price() : $item->get_sub_total(); |
| 282 | 282 | $quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity(); |
| 283 | - $this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() ); |
|
| 283 | + $this->add_line_item($item->get_raw_name(), $quantity, $amount, $item->get_id()); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | // Fees. |
| 287 | - foreach ( $invoice->get_fees() as $fee => $data ) { |
|
| 288 | - $this->add_line_item( $fee, 1, wpinv_sanitize_amount( $data['initial_fee'] ) ); |
|
| 287 | + foreach ($invoice->get_fees() as $fee => $data) { |
|
| 288 | + $this->add_line_item($fee, 1, wpinv_sanitize_amount($data['initial_fee'])); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | } |
@@ -298,15 +298,15 @@ discard block |
||
| 298 | 298 | * @param float $amount Amount. |
| 299 | 299 | * @param string $item_number Item number. |
| 300 | 300 | */ |
| 301 | - protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) { |
|
| 302 | - $index = ( count( $this->line_items ) / 4 ) + 1; |
|
| 301 | + protected function add_line_item($item_name, $quantity = 1, $amount = 0.0, $item_number = '') { |
|
| 302 | + $index = (count($this->line_items) / 4) + 1; |
|
| 303 | 303 | |
| 304 | 304 | $item = apply_filters( |
| 305 | 305 | 'getpaid_paypal_line_item', |
| 306 | 306 | array( |
| 307 | - 'item_name' => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ), |
|
| 307 | + 'item_name' => html_entity_decode(getpaid_limit_length($item_name ? wp_strip_all_tags($item_name) : __('Item', 'invoicing'), 127), ENT_NOQUOTES, 'UTF-8'), |
|
| 308 | 308 | 'quantity' => (int) $quantity, |
| 309 | - 'amount' => wpinv_sanitize_amount( (float) $amount, 2 ), |
|
| 309 | + 'amount' => wpinv_sanitize_amount((float) $amount, 2), |
|
| 310 | 310 | 'item_number' => $item_number, |
| 311 | 311 | ), |
| 312 | 312 | $item_name, |
@@ -315,12 +315,12 @@ discard block |
||
| 315 | 315 | $item_number |
| 316 | 316 | ); |
| 317 | 317 | |
| 318 | - $this->line_items[ 'item_name_' . $index ] = getpaid_limit_length( $item['item_name'], 127 ); |
|
| 319 | - $this->line_items[ 'quantity_' . $index ] = $item['quantity']; |
|
| 318 | + $this->line_items['item_name_' . $index] = getpaid_limit_length($item['item_name'], 127); |
|
| 319 | + $this->line_items['quantity_' . $index] = $item['quantity']; |
|
| 320 | 320 | |
| 321 | 321 | // The price or amount of the product, service, or contribution, not including shipping, handling, or tax. |
| 322 | - $this->line_items[ 'amount_' . $index ] = $item['amount']; |
|
| 323 | - $this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 ); |
|
| 322 | + $this->line_items['amount_' . $index] = $item['amount']; |
|
| 323 | + $this->line_items['item_number_' . $index] = getpaid_limit_length($item['item_number'], 127); |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | /** |
@@ -332,19 +332,19 @@ discard block |
||
| 332 | 332 | * @param array $paypal_args Arguments sent to Paypal in the request. |
| 333 | 333 | * @return array |
| 334 | 334 | */ |
| 335 | - protected function fix_request_length( $invoice, $paypal_args ) { |
|
| 335 | + protected function fix_request_length($invoice, $paypal_args) { |
|
| 336 | 336 | $max_paypal_length = 2083; |
| 337 | - $query_candidate = http_build_query( $paypal_args, '', '&' ); |
|
| 337 | + $query_candidate = http_build_query($paypal_args, '', '&'); |
|
| 338 | 338 | |
| 339 | - if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) { |
|
| 339 | + if (strlen($this->endpoint . $query_candidate) <= $max_paypal_length) { |
|
| 340 | 340 | return $paypal_args; |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | return apply_filters( |
| 344 | 344 | 'getpaid_paypal_args', |
| 345 | 345 | array_merge( |
| 346 | - $this->get_transaction_args( $invoice ), |
|
| 347 | - $this->get_line_item_args( $invoice, true ) |
|
| 346 | + $this->get_transaction_args($invoice), |
|
| 347 | + $this->get_line_item_args($invoice, true) |
|
| 348 | 348 | ), |
| 349 | 349 | $invoice |
| 350 | 350 | ); |
@@ -357,10 +357,10 @@ discard block |
||
| 357 | 357 | * @param array $paypal_args PayPal args. |
| 358 | 358 | * @param WPInv_Invoice $invoice Invoice object. |
| 359 | 359 | */ |
| 360 | - public function process_subscription( $paypal_args, $invoice ) { |
|
| 360 | + public function process_subscription($paypal_args, $invoice) { |
|
| 361 | 361 | |
| 362 | 362 | // Make sure this is a subscription. |
| 363 | - if ( ! $invoice->is_recurring() || ! $subscription = wpinv_get_subscription( $invoice ) ) { |
|
| 363 | + if (!$invoice->is_recurring() || !$subscription = wpinv_get_subscription($invoice)) { |
|
| 364 | 364 | return $paypal_args; |
| 365 | 365 | } |
| 366 | 366 | |
@@ -368,17 +368,17 @@ discard block |
||
| 368 | 368 | $paypal_args['cmd'] = '_xclick-subscriptions'; |
| 369 | 369 | |
| 370 | 370 | // Subscription name. |
| 371 | - $paypal_args['item_name'] = sprintf( __( 'Invoice #%s', 'invoicing' ), $invoice->get_number() ); |
|
| 371 | + $paypal_args['item_name'] = sprintf(__('Invoice #%s', 'invoicing'), $invoice->get_number()); |
|
| 372 | 372 | |
| 373 | 373 | // Get subscription args. |
| 374 | - $period = strtoupper( substr( $subscription->get_period(), 0, 1) ); |
|
| 374 | + $period = strtoupper(substr($subscription->get_period(), 0, 1)); |
|
| 375 | 375 | $interval = (int) $subscription->get_frequency(); |
| 376 | 376 | $bill_times = (int) $subscription->get_bill_times(); |
| 377 | - $initial_amount = (float) wpinv_sanitize_amount( $invoice->get_initial_total(), 2 ); |
|
| 378 | - $recurring_amount = (float) wpinv_sanitize_amount( $invoice->get_recurring_total(), 2 ); |
|
| 379 | - $subscription_item = $invoice->get_recurring( true ); |
|
| 377 | + $initial_amount = (float) wpinv_sanitize_amount($invoice->get_initial_total(), 2); |
|
| 378 | + $recurring_amount = (float) wpinv_sanitize_amount($invoice->get_recurring_total(), 2); |
|
| 379 | + $subscription_item = $invoice->get_recurring(true); |
|
| 380 | 380 | |
| 381 | - if ( $subscription_item->has_free_trial() ) { |
|
| 381 | + if ($subscription_item->has_free_trial()) { |
|
| 382 | 382 | |
| 383 | 383 | $paypal_args['a1'] = 0 == $initial_amount ? 0 : $initial_amount; |
| 384 | 384 | |
@@ -388,28 +388,28 @@ discard block |
||
| 388 | 388 | // Trial period. |
| 389 | 389 | $paypal_args['t1'] = $subscription_item->get_trial_period(); |
| 390 | 390 | |
| 391 | - } else if ( $initial_amount != $recurring_amount ) { |
|
| 391 | + } else if ($initial_amount != $recurring_amount) { |
|
| 392 | 392 | |
| 393 | 393 | // No trial period, but initial amount includes a sign-up fee and/or other items, so charge it as a separate period. |
| 394 | 394 | |
| 395 | - if ( 1 == $bill_times ) { |
|
| 395 | + if (1 == $bill_times) { |
|
| 396 | 396 | $param_number = 3; |
| 397 | 397 | } else { |
| 398 | 398 | $param_number = 1; |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | - $paypal_args[ 'a' . $param_number ] = $initial_amount ? $initial_amount : 0; |
|
| 401 | + $paypal_args['a' . $param_number] = $initial_amount ? $initial_amount : 0; |
|
| 402 | 402 | |
| 403 | 403 | // Sign Up interval |
| 404 | - $paypal_args[ 'p' . $param_number ] = $interval; |
|
| 404 | + $paypal_args['p' . $param_number] = $interval; |
|
| 405 | 405 | |
| 406 | 406 | // Sign Up unit of duration |
| 407 | - $paypal_args[ 't' . $param_number ] = $period; |
|
| 407 | + $paypal_args['t' . $param_number] = $period; |
|
| 408 | 408 | |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | // We have a recurring payment |
| 412 | - if ( ! isset( $param_number ) || 1 == $param_number ) { |
|
| 412 | + if (!isset($param_number) || 1 == $param_number) { |
|
| 413 | 413 | |
| 414 | 414 | // Subscription price |
| 415 | 415 | $paypal_args['a3'] = $recurring_amount; |
@@ -423,7 +423,7 @@ discard block |
||
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | // Recurring payments |
| 426 | - if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) { |
|
| 426 | + if (1 == $bill_times || ($initial_amount != $recurring_amount && !$subscription_item->has_free_trial() && 2 == $bill_times)) { |
|
| 427 | 427 | |
| 428 | 428 | // Non-recurring payments |
| 429 | 429 | $paypal_args['src'] = 0; |
@@ -432,15 +432,15 @@ discard block |
||
| 432 | 432 | |
| 433 | 433 | $paypal_args['src'] = 1; |
| 434 | 434 | |
| 435 | - if ( $bill_times > 0 ) { |
|
| 435 | + if ($bill_times > 0) { |
|
| 436 | 436 | |
| 437 | 437 | // An initial period is being used to charge a sign-up fee |
| 438 | - if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) { |
|
| 438 | + if ($initial_amount != $recurring_amount && !$subscription_item->has_free_trial()) { |
|
| 439 | 439 | $bill_times--; |
| 440 | 440 | } |
| 441 | 441 | |
| 442 | 442 | // Make sure it's not over the max of 52 |
| 443 | - $paypal_args['srt'] = ( $bill_times <= 52 ? absint( $bill_times ) : 52 ); |
|
| 443 | + $paypal_args['srt'] = ($bill_times <= 52 ? absint($bill_times) : 52); |
|
| 444 | 444 | |
| 445 | 445 | } |
| 446 | 446 | } |
@@ -449,10 +449,10 @@ discard block |
||
| 449 | 449 | $paypal_args['rm'] = 2; |
| 450 | 450 | |
| 451 | 451 | // Get rid of redudant items. |
| 452 | - foreach ( array( 'item_name_1', 'quantity_1', 'amount_1', 'item_number_1' ) as $arg ) { |
|
| 452 | + foreach (array('item_name_1', 'quantity_1', 'amount_1', 'item_number_1') as $arg) { |
|
| 453 | 453 | |
| 454 | - if ( isset( $paypal_args[ $arg ] ) ) { |
|
| 455 | - unset( $paypal_args[ $arg ] ); |
|
| 454 | + if (isset($paypal_args[$arg])) { |
|
| 455 | + unset($paypal_args[$arg]); |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | } |
@@ -471,7 +471,7 @@ discard block |
||
| 471 | 471 | * @return void |
| 472 | 472 | */ |
| 473 | 473 | public function verify_ipn() { |
| 474 | - new GetPaid_Paypal_Gateway_IPN_Handler( $this ); |
|
| 474 | + new GetPaid_Paypal_Gateway_IPN_Handler($this); |
|
| 475 | 475 | } |
| 476 | 476 | |
| 477 | 477 | /** |
@@ -480,7 +480,7 @@ discard block |
||
| 480 | 480 | public function sandbox_notice() { |
| 481 | 481 | |
| 482 | 482 | return sprintf( |
| 483 | - __( 'SANDBOX ENABLED. You can use sandbox testing accounts only. See the %sPayPal Sandbox Testing Guide%s for more details.', 'invoicing' ), |
|
| 483 | + __('SANDBOX ENABLED. You can use sandbox testing accounts only. See the %sPayPal Sandbox Testing Guide%s for more details.', 'invoicing'), |
|
| 484 | 484 | '<a href="https://developer.paypal.com/docs/classic/lifecycle/ug_sandbox/">', |
| 485 | 485 | '</a>' |
| 486 | 486 | ); |
@@ -7,21 +7,21 @@ discard block |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | // The payment methods select title. |
| 13 | -if ( empty( $text ) ) { |
|
| 14 | - $text = __( 'Select Payment Method', 'invoicing' ); |
|
| 13 | +if (empty($text)) { |
|
| 14 | + $text = __('Select Payment Method', 'invoicing'); |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | // An array of active payment methods. |
| 18 | -$gateways = wpinv_get_enabled_payment_gateways( true ); |
|
| 18 | +$gateways = wpinv_get_enabled_payment_gateways(true); |
|
| 19 | 19 | |
| 20 | 20 | // The current invoice id. |
| 21 | 21 | $invoice_id = 0; |
| 22 | 22 | $chosen_gateway = wpinv_get_default_gateway(); |
| 23 | 23 | |
| 24 | -if ( ! empty( $form->invoice ) ) { |
|
| 24 | +if (!empty($form->invoice)) { |
|
| 25 | 25 | $invoice_id = $form->invoice->get_id(); |
| 26 | 26 | $chosen_gateway = $form->invoice->get_gateway(); |
| 27 | 27 | } |
@@ -30,21 +30,21 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | <div class="mt-4 mb-4 getpaid-gateways"> |
| 32 | 32 | |
| 33 | - <?php do_action( 'wpinv_payment_mode_top', $invoice_id, $chosen_gateway, $gateways, $form ); ?> |
|
| 33 | + <?php do_action('wpinv_payment_mode_top', $invoice_id, $chosen_gateway, $gateways, $form); ?> |
|
| 34 | 34 | |
| 35 | 35 | <div class="getpaid-select-gateway-title-div"> |
| 36 | - <h6><?php echo sanitize_text_field( $text ); ?></h6> |
|
| 36 | + <h6><?php echo sanitize_text_field($text); ?></h6> |
|
| 37 | 37 | </div> |
| 38 | 38 | |
| 39 | 39 | <div class="getpaid-available-gateways-div"> |
| 40 | 40 | |
| 41 | - <?php foreach ( array_keys( $gateways ) as $gateway ) : ?> |
|
| 41 | + <?php foreach (array_keys($gateways) as $gateway) : ?> |
|
| 42 | 42 | |
| 43 | - <div class="pt-1 pb-1 getpaid-gateway getpaid-gateway-<?php echo sanitize_html_class( $gateway ) ;?>" data-checkout-label='<?php echo esc_attr( apply_filters( "getpaid_gateway_{$gateway}_checkout_button_label", '' ) ); ?>'> |
|
| 43 | + <div class="pt-1 pb-1 getpaid-gateway getpaid-gateway-<?php echo sanitize_html_class($gateway); ?>" data-checkout-label='<?php echo esc_attr(apply_filters("getpaid_gateway_{$gateway}_checkout_button_label", '')); ?>'> |
|
| 44 | 44 | |
| 45 | 45 | <label class="d-block w-100 getpaid-gateway-radio"> |
| 46 | - <input type="radio" value="<?php echo esc_attr( $gateway ) ;?>" <?php checked( $gateway, $chosen_gateway ) ;?> name="wpi-gateway"> |
|
| 47 | - <span><?php echo sanitize_text_field( wpinv_get_gateway_checkout_label( $gateway ) ); ?></span> |
|
| 46 | + <input type="radio" value="<?php echo esc_attr($gateway); ?>" <?php checked($gateway, $chosen_gateway); ?> name="wpi-gateway"> |
|
| 47 | + <span><?php echo sanitize_text_field(wpinv_get_gateway_checkout_label($gateway)); ?></span> |
|
| 48 | 48 | </label> |
| 49 | 49 | |
| 50 | 50 | </div> |
@@ -55,22 +55,22 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | <div class="getpaid-gateway-descriptions-div"> |
| 57 | 57 | |
| 58 | - <?php foreach ( array_keys( $gateways ) as $gateway ) : ?> |
|
| 58 | + <?php foreach (array_keys($gateways) as $gateway) : ?> |
|
| 59 | 59 | |
| 60 | - <div class="mb-2 mt-2 bg-light border getpaid-gateway-description getpaid-description-<?php echo sanitize_html_class( $gateway ) ;?>" style="display: none;"> |
|
| 60 | + <div class="mb-2 mt-2 bg-light border getpaid-gateway-description getpaid-description-<?php echo sanitize_html_class($gateway); ?>" style="display: none;"> |
|
| 61 | 61 | <?php |
| 62 | 62 | |
| 63 | - $description = wpinv_get_gateway_description( $gateway ); |
|
| 63 | + $description = wpinv_get_gateway_description($gateway); |
|
| 64 | 64 | |
| 65 | - if ( wpinv_is_test_mode( $gateway ) ) { |
|
| 66 | - $sandbox_notice = apply_filters( "getpaid_{$gateway}_sandbox_notice", __( 'SANDBOX ENABLED: No real payments will occur.', 'invoicing' ) ); |
|
| 65 | + if (wpinv_is_test_mode($gateway)) { |
|
| 66 | + $sandbox_notice = apply_filters("getpaid_{$gateway}_sandbox_notice", __('SANDBOX ENABLED: No real payments will occur.', 'invoicing')); |
|
| 67 | 67 | $description = "$description $sandbox_notice"; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - echo wpautop( wp_kses_post( $description ) ); |
|
| 70 | + echo wpautop(wp_kses_post($description)); |
|
| 71 | 71 | |
| 72 | - do_action( 'wpinv_' . $gateway . '_checkout_fields', $invoice_id ) ; |
|
| 73 | - do_action( 'wpinv_' . $gateway . '_cc_form', $invoice_id, $form ) ; |
|
| 72 | + do_action('wpinv_' . $gateway . '_checkout_fields', $invoice_id); |
|
| 73 | + do_action('wpinv_' . $gateway . '_cc_form', $invoice_id, $form); |
|
| 74 | 74 | |
| 75 | 75 | ?> |
| 76 | 76 | </div> |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | <?php |
| 84 | 84 | echo aui()->alert( |
| 85 | 85 | array( |
| 86 | - 'content' => __( 'None of the available payment gateways support subscriptions.', 'invoicing' ), |
|
| 86 | + 'content' => __('None of the available payment gateways support subscriptions.', 'invoicing'), |
|
| 87 | 87 | 'type' => 'danger', |
| 88 | 88 | ) |
| 89 | 89 | ); |
@@ -94,14 +94,14 @@ discard block |
||
| 94 | 94 | <?php |
| 95 | 95 | echo aui()->alert( |
| 96 | 96 | array( |
| 97 | - 'content' => __( 'There is no active payment gateway available to process your request.', 'invoicing' ), |
|
| 97 | + 'content' => __('There is no active payment gateway available to process your request.', 'invoicing'), |
|
| 98 | 98 | 'type' => 'danger', |
| 99 | 99 | ) |
| 100 | 100 | ); |
| 101 | 101 | ?> |
| 102 | 102 | </div> |
| 103 | 103 | |
| 104 | - <?php do_action( 'wpinv_payment_mode_bottom', $invoice_id, $chosen_gateway, $gateways, $form ); ?> |
|
| 104 | + <?php do_action('wpinv_payment_mode_bottom', $invoice_id, $chosen_gateway, $gateways, $form); ?> |
|
| 105 | 105 | |
| 106 | 106 | </div> |
| 107 | 107 | |
@@ -10,67 +10,67 @@ discard block |
||
| 10 | 10 | * @var array $columns |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | -defined( 'ABSPATH' ) || exit; |
|
| 13 | +defined('ABSPATH') || exit; |
|
| 14 | 14 | |
| 15 | 15 | ?> |
| 16 | 16 | |
| 17 | -<?php do_action( 'getpaid_before_email_line_item', $invoice, $item ); ?> |
|
| 17 | +<?php do_action('getpaid_before_email_line_item', $invoice, $item); ?> |
|
| 18 | 18 | |
| 19 | -<tr class="wpinv_cart_item item-type-<?php echo sanitize_html_class( $item->get_type() ); ?>"> |
|
| 19 | +<tr class="wpinv_cart_item item-type-<?php echo sanitize_html_class($item->get_type()); ?>"> |
|
| 20 | 20 | |
| 21 | - <?php foreach ( array_keys( $columns ) as $column ): ?> |
|
| 21 | + <?php foreach (array_keys($columns) as $column): ?> |
|
| 22 | 22 | |
| 23 | - <td class="<?php echo 'name' == $column ? 'text-left' : 'text-right' ?> wpinv_cart_item_<?php echo sanitize_html_class( $column ); ?>"> |
|
| 23 | + <td class="<?php echo 'name' == $column ? 'text-left' : 'text-right' ?> wpinv_cart_item_<?php echo sanitize_html_class($column); ?>"> |
|
| 24 | 24 | |
| 25 | 25 | <?php |
| 26 | 26 | |
| 27 | 27 | // Fires before printing a line item column. |
| 28 | - do_action( "getpaid_email_line_item_before_$column", $item, $invoice ); |
|
| 28 | + do_action("getpaid_email_line_item_before_$column", $item, $invoice); |
|
| 29 | 29 | |
| 30 | 30 | // Item name. |
| 31 | - if ( 'name' == $column ) { |
|
| 31 | + if ('name' == $column) { |
|
| 32 | 32 | |
| 33 | 33 | // Display the name. |
| 34 | - echo '<div class="wpinv_email_cart_item_title">' . sanitize_text_field( $item->get_name() ) . '</div>'; |
|
| 34 | + echo '<div class="wpinv_email_cart_item_title">' . sanitize_text_field($item->get_name()) . '</div>'; |
|
| 35 | 35 | |
| 36 | 36 | // And an optional description. |
| 37 | 37 | $description = $item->get_description(); |
| 38 | 38 | |
| 39 | - if ( ! empty( $description ) ) { |
|
| 40 | - $description = wp_kses_post( $description ); |
|
| 39 | + if (!empty($description)) { |
|
| 40 | + $description = wp_kses_post($description); |
|
| 41 | 41 | echo "<p class='small'>$description</p>"; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | // Price help text |
| 45 | - $description = getpaid_item_recurring_price_help_text( $item, $invoice->get_currency() ); |
|
| 46 | - if ( $description ) { |
|
| 45 | + $description = getpaid_item_recurring_price_help_text($item, $invoice->get_currency()); |
|
| 46 | + if ($description) { |
|
| 47 | 47 | echo "<p class='small'>$description</p>"; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | // Item price. |
| 53 | - if ( 'price' == $column ) { |
|
| 53 | + if ('price' == $column) { |
|
| 54 | 54 | |
| 55 | 55 | // Display the item price (or recurring price if this is a renewal invoice) |
| 56 | 56 | $price = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price(); |
| 57 | - echo wpinv_price( $price ); |
|
| 57 | + echo wpinv_price($price); |
|
| 58 | 58 | |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | // Item quantity. |
| 62 | - if ( 'quantity' == $column ) { |
|
| 62 | + if ('quantity' == $column) { |
|
| 63 | 63 | echo (int) $item->get_quantity(); |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | // Item sub total. |
| 67 | - if ( 'subtotal' == $column ) { |
|
| 67 | + if ('subtotal' == $column) { |
|
| 68 | 68 | $subtotal = $invoice->is_renewal() ? $item->get_recurring_sub_total() : $item->get_sub_total(); |
| 69 | - echo wpinv_price( $subtotal ); |
|
| 69 | + echo wpinv_price($subtotal); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | // Fires when printing a line item column. |
| 73 | - do_action( "getpaid_email_line_item_$column", $item, $invoice ); |
|
| 73 | + do_action("getpaid_email_line_item_$column", $item, $invoice); |
|
| 74 | 74 | |
| 75 | 75 | ?> |
| 76 | 76 | |
@@ -80,4 +80,4 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | </tr> |
| 82 | 82 | |
| 83 | -<?php do_action( 'getpaid_after_email_line_item', $invoice, $item ); ?> |
|
| 83 | +<?php do_action('getpaid_after_email_line_item', $invoice, $item); ?> |
|
@@ -10,63 +10,63 @@ discard block |
||
| 10 | 10 | * @var array $columns |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | -defined( 'ABSPATH' ) || exit; |
|
| 13 | +defined('ABSPATH') || exit; |
|
| 14 | 14 | |
| 15 | 15 | ?> |
| 16 | 16 | |
| 17 | -<?php do_action( 'getpaid_before_email_fee_item', $invoice, $fee ); ?> |
|
| 17 | +<?php do_action('getpaid_before_email_fee_item', $invoice, $fee); ?> |
|
| 18 | 18 | |
| 19 | 19 | <tr class="wpinv_cart_item item-fee"> |
| 20 | 20 | |
| 21 | - <?php foreach ( array_keys( $columns ) as $column ): ?> |
|
| 21 | + <?php foreach (array_keys($columns) as $column): ?> |
|
| 22 | 22 | |
| 23 | - <td class="<?php echo 'name' == $column ? 'text-left' : 'text-right' ?> wpinv_cart_item_<?php echo sanitize_html_class( $column ); ?>"> |
|
| 23 | + <td class="<?php echo 'name' == $column ? 'text-left' : 'text-right' ?> wpinv_cart_item_<?php echo sanitize_html_class($column); ?>"> |
|
| 24 | 24 | |
| 25 | 25 | <?php |
| 26 | 26 | |
| 27 | 27 | // Fires before printing a fee item column. |
| 28 | - do_action( "getpaid_email_fee_item_before_$column", $fee, $invoice ); |
|
| 28 | + do_action("getpaid_email_fee_item_before_$column", $fee, $invoice); |
|
| 29 | 29 | |
| 30 | 30 | // Item name. |
| 31 | - if ( 'name' == $column ) { |
|
| 31 | + if ('name' == $column) { |
|
| 32 | 32 | |
| 33 | 33 | // Display the name. |
| 34 | - echo '<div class="wpinv_email_cart_item_title">' . sanitize_text_field( $fee['name'] ) . '</div>'; |
|
| 34 | + echo '<div class="wpinv_email_cart_item_title">' . sanitize_text_field($fee['name']) . '</div>'; |
|
| 35 | 35 | |
| 36 | 36 | // And an optional description. |
| 37 | - $description = esc_html__( 'Fee', 'invoicing' ); |
|
| 37 | + $description = esc_html__('Fee', 'invoicing'); |
|
| 38 | 38 | echo "<p class='small'>$description</p>"; |
| 39 | 39 | |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | // Item price. |
| 43 | - if ( 'price' == $column ) { |
|
| 43 | + if ('price' == $column) { |
|
| 44 | 44 | |
| 45 | 45 | // Display the item price (or recurring price if this is a renewal invoice) |
| 46 | - if ( $invoice->is_recurring() && $invoice->is_renewal() ) { |
|
| 47 | - echo wpinv_price( $fee['recurring_fee'], $invoice->get_currency() ); |
|
| 46 | + if ($invoice->is_recurring() && $invoice->is_renewal()) { |
|
| 47 | + echo wpinv_price($fee['recurring_fee'], $invoice->get_currency()); |
|
| 48 | 48 | } else { |
| 49 | - echo wpinv_price( $fee['initial_fee'], $invoice->get_currency() ); |
|
| 49 | + echo wpinv_price($fee['initial_fee'], $invoice->get_currency()); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | // Item quantity. |
| 55 | - if ( 'quantity' == $column ) { |
|
| 55 | + if ('quantity' == $column) { |
|
| 56 | 56 | echo "—"; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | // Item sub total. |
| 60 | - if ( 'subtotal' == $column ) { |
|
| 61 | - if ( $invoice->is_recurring() && $invoice->is_renewal() ) { |
|
| 62 | - echo wpinv_price( $fee['recurring_fee'], $invoice->get_currency() ); |
|
| 60 | + if ('subtotal' == $column) { |
|
| 61 | + if ($invoice->is_recurring() && $invoice->is_renewal()) { |
|
| 62 | + echo wpinv_price($fee['recurring_fee'], $invoice->get_currency()); |
|
| 63 | 63 | } else { |
| 64 | - echo wpinv_price( $fee['initial_fee'], $invoice->get_currency() ); |
|
| 64 | + echo wpinv_price($fee['initial_fee'], $invoice->get_currency()); |
|
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | // Fires when printing a line item column. |
| 69 | - do_action( "getpaid_email_fee_item_$column", $fee, $invoice ); |
|
| 69 | + do_action("getpaid_email_fee_item_$column", $fee, $invoice); |
|
| 70 | 70 | |
| 71 | 71 | ?> |
| 72 | 72 | |
@@ -76,4 +76,4 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | </tr> |
| 78 | 78 | |
| 79 | -<?php do_action( 'getpaid_after_email_fee_item', $invoice, $fee ); ?> |
|
| 79 | +<?php do_action('getpaid_after_email_fee_item', $invoice, $fee); ?> |
|
@@ -13,450 +13,450 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | abstract class GetPaid_Payment_Gateway { |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * Set if the place checkout button should be renamed on selection. |
|
| 18 | - * |
|
| 19 | - * @var string |
|
| 20 | - */ |
|
| 21 | - public $checkout_button_text; |
|
| 22 | - |
|
| 23 | - /** |
|
| 24 | - * Boolean whether the method is enabled. |
|
| 25 | - * |
|
| 26 | - * @var bool |
|
| 27 | - */ |
|
| 28 | - public $enabled = true; |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * Payment method id. |
|
| 32 | - * |
|
| 33 | - * @var string |
|
| 34 | - */ |
|
| 35 | - public $id; |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * Payment method order. |
|
| 39 | - * |
|
| 40 | - * @var int |
|
| 41 | - */ |
|
| 42 | - public $order = 10; |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * Payment method title for the frontend. |
|
| 46 | - * |
|
| 47 | - * @var string |
|
| 48 | - */ |
|
| 49 | - public $title; |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * Payment method description for the frontend. |
|
| 53 | - * |
|
| 54 | - * @var string |
|
| 55 | - */ |
|
| 56 | - public $description; |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * Gateway title. |
|
| 60 | - * |
|
| 61 | - * @var string |
|
| 62 | - */ |
|
| 63 | - public $method_title = ''; |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * Gateway description. |
|
| 67 | - * |
|
| 68 | - * @var string |
|
| 69 | - */ |
|
| 70 | - public $method_description = ''; |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * Countries this gateway is allowed for. |
|
| 74 | - * |
|
| 75 | - * @var array |
|
| 76 | - */ |
|
| 77 | - public $countries; |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * Currencies this gateway is allowed for. |
|
| 81 | - * |
|
| 82 | - * @var array |
|
| 83 | - */ |
|
| 84 | - public $currencies; |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * Currencies this gateway is not allowed for. |
|
| 88 | - * |
|
| 89 | - * @var array |
|
| 90 | - */ |
|
| 91 | - public $exclude_currencies; |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * Maximum transaction amount, zero does not define a maximum. |
|
| 95 | - * |
|
| 96 | - * @var int |
|
| 97 | - */ |
|
| 98 | - public $max_amount = 0; |
|
| 99 | - |
|
| 100 | - /** |
|
| 101 | - * Optional URL to view a transaction. |
|
| 102 | - * |
|
| 103 | - * @var string |
|
| 104 | - */ |
|
| 105 | - public $view_transaction_url = ''; |
|
| 106 | - |
|
| 107 | - /** |
|
| 108 | - * Optional URL to view a subscription. |
|
| 109 | - * |
|
| 110 | - * @var string |
|
| 111 | - */ |
|
| 112 | - public $view_subscription_url = ''; |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * Optional label to show for "new payment method" in the payment |
|
| 116 | - * method/token selection radio selection. |
|
| 117 | - * |
|
| 118 | - * @var string |
|
| 119 | - */ |
|
| 120 | - public $new_method_label = ''; |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * Contains a user's saved tokens for this gateway. |
|
| 124 | - * |
|
| 125 | - * @var array |
|
| 126 | - */ |
|
| 127 | - protected $tokens = array(); |
|
| 128 | - |
|
| 129 | - /** |
|
| 130 | - * An array of features that this gateway supports. |
|
| 131 | - * |
|
| 132 | - * @var array |
|
| 133 | - */ |
|
| 134 | - protected $supports = array(); |
|
| 135 | - |
|
| 136 | - /** |
|
| 137 | - * Class constructor. |
|
| 138 | - */ |
|
| 139 | - public function __construct() { |
|
| 140 | - |
|
| 141 | - // Register gateway. |
|
| 142 | - add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) ); |
|
| 143 | - |
|
| 144 | - $this->enabled = wpinv_is_gateway_active( $this->id ); |
|
| 145 | - |
|
| 146 | - // Enable Subscriptions. |
|
| 147 | - if ( $this->supports( 'subscription' ) ) { |
|
| 148 | - add_filter( "wpinv_{$this->id}_support_subscription", '__return_true' ); |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - // Enable sandbox. |
|
| 152 | - if ( $this->supports( 'sandbox' ) ) { |
|
| 153 | - add_filter( "wpinv_{$this->id}_supports_sandbox", '__return_true' ); |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - // Gateway settings. |
|
| 157 | - add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) ); |
|
| 16 | + /** |
|
| 17 | + * Set if the place checkout button should be renamed on selection. |
|
| 18 | + * |
|
| 19 | + * @var string |
|
| 20 | + */ |
|
| 21 | + public $checkout_button_text; |
|
| 22 | + |
|
| 23 | + /** |
|
| 24 | + * Boolean whether the method is enabled. |
|
| 25 | + * |
|
| 26 | + * @var bool |
|
| 27 | + */ |
|
| 28 | + public $enabled = true; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * Payment method id. |
|
| 32 | + * |
|
| 33 | + * @var string |
|
| 34 | + */ |
|
| 35 | + public $id; |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * Payment method order. |
|
| 39 | + * |
|
| 40 | + * @var int |
|
| 41 | + */ |
|
| 42 | + public $order = 10; |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * Payment method title for the frontend. |
|
| 46 | + * |
|
| 47 | + * @var string |
|
| 48 | + */ |
|
| 49 | + public $title; |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * Payment method description for the frontend. |
|
| 53 | + * |
|
| 54 | + * @var string |
|
| 55 | + */ |
|
| 56 | + public $description; |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * Gateway title. |
|
| 60 | + * |
|
| 61 | + * @var string |
|
| 62 | + */ |
|
| 63 | + public $method_title = ''; |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * Gateway description. |
|
| 67 | + * |
|
| 68 | + * @var string |
|
| 69 | + */ |
|
| 70 | + public $method_description = ''; |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * Countries this gateway is allowed for. |
|
| 74 | + * |
|
| 75 | + * @var array |
|
| 76 | + */ |
|
| 77 | + public $countries; |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * Currencies this gateway is allowed for. |
|
| 81 | + * |
|
| 82 | + * @var array |
|
| 83 | + */ |
|
| 84 | + public $currencies; |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * Currencies this gateway is not allowed for. |
|
| 88 | + * |
|
| 89 | + * @var array |
|
| 90 | + */ |
|
| 91 | + public $exclude_currencies; |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * Maximum transaction amount, zero does not define a maximum. |
|
| 95 | + * |
|
| 96 | + * @var int |
|
| 97 | + */ |
|
| 98 | + public $max_amount = 0; |
|
| 99 | + |
|
| 100 | + /** |
|
| 101 | + * Optional URL to view a transaction. |
|
| 102 | + * |
|
| 103 | + * @var string |
|
| 104 | + */ |
|
| 105 | + public $view_transaction_url = ''; |
|
| 106 | + |
|
| 107 | + /** |
|
| 108 | + * Optional URL to view a subscription. |
|
| 109 | + * |
|
| 110 | + * @var string |
|
| 111 | + */ |
|
| 112 | + public $view_subscription_url = ''; |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * Optional label to show for "new payment method" in the payment |
|
| 116 | + * method/token selection radio selection. |
|
| 117 | + * |
|
| 118 | + * @var string |
|
| 119 | + */ |
|
| 120 | + public $new_method_label = ''; |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * Contains a user's saved tokens for this gateway. |
|
| 124 | + * |
|
| 125 | + * @var array |
|
| 126 | + */ |
|
| 127 | + protected $tokens = array(); |
|
| 128 | + |
|
| 129 | + /** |
|
| 130 | + * An array of features that this gateway supports. |
|
| 131 | + * |
|
| 132 | + * @var array |
|
| 133 | + */ |
|
| 134 | + protected $supports = array(); |
|
| 135 | + |
|
| 136 | + /** |
|
| 137 | + * Class constructor. |
|
| 138 | + */ |
|
| 139 | + public function __construct() { |
|
| 140 | + |
|
| 141 | + // Register gateway. |
|
| 142 | + add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) ); |
|
| 143 | + |
|
| 144 | + $this->enabled = wpinv_is_gateway_active( $this->id ); |
|
| 145 | + |
|
| 146 | + // Enable Subscriptions. |
|
| 147 | + if ( $this->supports( 'subscription' ) ) { |
|
| 148 | + add_filter( "wpinv_{$this->id}_support_subscription", '__return_true' ); |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + // Enable sandbox. |
|
| 152 | + if ( $this->supports( 'sandbox' ) ) { |
|
| 153 | + add_filter( "wpinv_{$this->id}_supports_sandbox", '__return_true' ); |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + // Gateway settings. |
|
| 157 | + add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) ); |
|
| 158 | 158 | |
| 159 | 159 | |
| 160 | - // Gateway checkout fiellds. |
|
| 161 | - add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 ); |
|
| 162 | - |
|
| 163 | - // Process payment. |
|
| 164 | - add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 ); |
|
| 160 | + // Gateway checkout fiellds. |
|
| 161 | + add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 ); |
|
| 162 | + |
|
| 163 | + // Process payment. |
|
| 164 | + add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 ); |
|
| 165 | + |
|
| 166 | + // Change the checkout button text. |
|
| 167 | + if ( ! empty( $this->checkout_button_text ) ) { |
|
| 168 | + add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) ); |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + // Check if a gateway is valid for a given currency. |
|
| 172 | + add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 ); |
|
| 173 | + |
|
| 174 | + // Generate the transaction url. |
|
| 175 | + add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 ); |
|
| 176 | + |
|
| 177 | + // Generate the subscription url. |
|
| 178 | + add_filter( "getpaid_gateway_{$this->id}_subscription_url", array( $this, 'filter_subscription_url' ), 10, 2 ); |
|
| 179 | + |
|
| 180 | + // Confirm payments. |
|
| 181 | + add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 ); |
|
| 182 | + |
|
| 183 | + // Verify IPNs. |
|
| 184 | + add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) ); |
|
| 185 | + |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + /** |
|
| 189 | + * Checks if this gateway is a given gateway. |
|
| 190 | + * |
|
| 191 | + * @since 1.0.19 |
|
| 192 | + * @return bool |
|
| 193 | + */ |
|
| 194 | + public function is( $gateway ) { |
|
| 195 | + return $gateway == $this->id; |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + /** |
|
| 199 | + * Returns a users saved tokens for this gateway. |
|
| 200 | + * |
|
| 201 | + * @since 1.0.19 |
|
| 202 | + * @return array |
|
| 203 | + */ |
|
| 204 | + public function get_tokens( $sandbox = null ) { |
|
| 205 | + |
|
| 206 | + if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) { |
|
| 207 | + $tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true ); |
|
| 208 | + |
|
| 209 | + if ( is_array( $tokens ) ) { |
|
| 210 | + $this->tokens = $tokens; |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + if ( ! is_bool( $sandbox ) ) { |
|
| 216 | + return $this->tokens; |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + $args = array( 'type' => $sandbox ? 'sandbox' : 'live' ); |
|
| 220 | + return wp_list_filter( $this->tokens, $args ); |
|
| 221 | + |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + /** |
|
| 225 | + * Saves a token for this gateway. |
|
| 226 | + * |
|
| 227 | + * @since 1.0.19 |
|
| 228 | + */ |
|
| 229 | + public function save_token( $token ) { |
|
| 230 | + |
|
| 231 | + $tokens = $this->get_tokens(); |
|
| 232 | + $tokens[] = $token; |
|
| 233 | + |
|
| 234 | + update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens ); |
|
| 235 | + |
|
| 236 | + $this->tokens = $tokens; |
|
| 237 | + |
|
| 238 | + } |
|
| 239 | + |
|
| 240 | + /** |
|
| 241 | + * Return the title for admin screens. |
|
| 242 | + * |
|
| 243 | + * @return string |
|
| 244 | + */ |
|
| 245 | + public function get_method_title() { |
|
| 246 | + return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this ); |
|
| 247 | + } |
|
| 248 | + |
|
| 249 | + /** |
|
| 250 | + * Return the description for admin screens. |
|
| 251 | + * |
|
| 252 | + * @return string |
|
| 253 | + */ |
|
| 254 | + public function get_method_description() { |
|
| 255 | + return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this ); |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + /** |
|
| 259 | + * Get the success url. |
|
| 260 | + * |
|
| 261 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 262 | + * @return string |
|
| 263 | + */ |
|
| 264 | + public function get_return_url( $invoice ) { |
|
| 265 | + |
|
| 266 | + // Payment success url |
|
| 267 | + $return_url = add_query_arg( |
|
| 268 | + array( |
|
| 269 | + 'payment-confirm' => $this->id, |
|
| 270 | + 'invoice_key' => $invoice->get_key(), |
|
| 271 | + 'utm_nooverride' => 1 |
|
| 272 | + ), |
|
| 273 | + wpinv_get_success_page_uri() |
|
| 274 | + ); |
|
| 275 | + |
|
| 276 | + return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this ); |
|
| 277 | + } |
|
| 278 | + |
|
| 279 | + /** |
|
| 280 | + * Confirms payments when rendering the success page. |
|
| 281 | + * |
|
| 282 | + * @param string $content Success page content. |
|
| 283 | + * @return string |
|
| 284 | + */ |
|
| 285 | + public function confirm_payment( $content ) { |
|
| 286 | + |
|
| 287 | + // Retrieve the invoice. |
|
| 288 | + $invoice_id = getpaid_get_current_invoice_id(); |
|
| 289 | + $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 290 | + |
|
| 291 | + // Ensure that it exists and that it is pending payment. |
|
| 292 | + if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) { |
|
| 293 | + return $content; |
|
| 294 | + } |
|
| 295 | + |
|
| 296 | + // Can the user view this invoice?? |
|
| 297 | + if ( ! wpinv_user_can_view_invoice( $invoice ) ) { |
|
| 298 | + return $content; |
|
| 299 | + } |
|
| 300 | + |
|
| 301 | + // Show payment processing indicator. |
|
| 302 | + return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) ); |
|
| 303 | + } |
|
| 304 | + |
|
| 305 | + /** |
|
| 306 | + * Processes ipns and marks payments as complete. |
|
| 307 | + * |
|
| 308 | + * @return void |
|
| 309 | + */ |
|
| 310 | + public function verify_ipn() {} |
|
| 311 | + |
|
| 312 | + /** |
|
| 313 | + * Get a link to the transaction on the 3rd party gateway site (if applicable). |
|
| 314 | + * |
|
| 315 | + * @param string $transaction_url transaction url. |
|
| 316 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 317 | + * @return string transaction URL, or empty string. |
|
| 318 | + */ |
|
| 319 | + public function filter_transaction_url( $transaction_url, $invoice ) { |
|
| 320 | + |
|
| 321 | + $transaction_id = $invoice->get_transaction_id(); |
|
| 322 | + |
|
| 323 | + if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) { |
|
| 324 | + $transaction_url = sprintf( $this->view_transaction_url, $transaction_id ); |
|
| 325 | + $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
| 326 | + $transaction_url = str_replace( '{sandbox}', $replace, $transaction_url ); |
|
| 327 | + } |
|
| 328 | + |
|
| 329 | + return $transaction_url; |
|
| 330 | + } |
|
| 331 | + |
|
| 332 | + /** |
|
| 333 | + * Get a link to the subscription on the 3rd party gateway site (if applicable). |
|
| 334 | + * |
|
| 335 | + * @param string $subscription_url transaction url. |
|
| 336 | + * @param WPInv_Invoice $invoice Invoice object. |
|
| 337 | + * @return string subscription URL, or empty string. |
|
| 338 | + */ |
|
| 339 | + public function filter_subscription_url( $subscription_url, $invoice ) { |
|
| 340 | + |
|
| 341 | + $profile_id = $invoice->get_subscription_id(); |
|
| 342 | + |
|
| 343 | + if ( ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) { |
|
| 344 | + |
|
| 345 | + $subscription_url = sprintf( $this->view_subscription_url, $profile_id ); |
|
| 346 | + $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
| 347 | + $subscription_url = str_replace( '{sandbox}', $replace, $subscription_url ); |
|
| 348 | + |
|
| 349 | + } |
|
| 350 | + |
|
| 351 | + return $subscription_url; |
|
| 352 | + } |
|
| 353 | + |
|
| 354 | + /** |
|
| 355 | + * Check if the gateway is available for use. |
|
| 356 | + * |
|
| 357 | + * @return bool |
|
| 358 | + */ |
|
| 359 | + public function is_available() { |
|
| 360 | + return ! empty( $this->enabled ); |
|
| 361 | + } |
|
| 362 | + |
|
| 363 | + /** |
|
| 364 | + * Return the gateway's title. |
|
| 365 | + * |
|
| 366 | + * @return string |
|
| 367 | + */ |
|
| 368 | + public function get_title() { |
|
| 369 | + return apply_filters( 'getpaid_gateway_title', $this->title, $this ); |
|
| 370 | + } |
|
| 371 | + |
|
| 372 | + /** |
|
| 373 | + * Return the gateway's description. |
|
| 374 | + * |
|
| 375 | + * @return string |
|
| 376 | + */ |
|
| 377 | + public function get_description() { |
|
| 378 | + return apply_filters( 'getpaid_gateway_description', $this->description, $this ); |
|
| 379 | + } |
|
| 380 | + |
|
| 381 | + /** |
|
| 382 | + * Process Payment. |
|
| 383 | + * |
|
| 384 | + * |
|
| 385 | + * @param WPInv_Invoice $invoice Invoice. |
|
| 386 | + * @param array $submission_data Posted checkout fields. |
|
| 387 | + * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
| 388 | + * @return void |
|
| 389 | + */ |
|
| 390 | + public function process_payment( $invoice, $submission_data, $submission ) { |
|
| 391 | + // Process the payment then either redirect to the success page or the gateway. |
|
| 392 | + do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission ); |
|
| 393 | + } |
|
| 394 | + |
|
| 395 | + /** |
|
| 396 | + * Process refund. |
|
| 397 | + * |
|
| 398 | + * If the gateway declares 'refunds' support, this will allow it to refund. |
|
| 399 | + * a passed in amount. |
|
| 400 | + * |
|
| 401 | + * @param WPInv_Invoice $invoice Invoice. |
|
| 402 | + * @param float $amount Refund amount. |
|
| 403 | + * @param string $reason Refund reason. |
|
| 404 | + * @return WP_Error|bool True or false based on success, or a WP_Error object. |
|
| 405 | + */ |
|
| 406 | + public function process_refund( $invoice, $amount = null, $reason = '' ) { |
|
| 407 | + return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason ); |
|
| 408 | + } |
|
| 409 | + |
|
| 410 | + /** |
|
| 411 | + * Displays the payment fields, credit cards etc. |
|
| 412 | + * |
|
| 413 | + * @param int $invoice_id 0 or invoice id. |
|
| 414 | + * @param GetPaid_Payment_Form $form Current payment form. |
|
| 415 | + */ |
|
| 416 | + public function payment_fields( $invoice_id, $form ) { |
|
| 417 | + do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form ); |
|
| 418 | + } |
|
| 419 | + |
|
| 420 | + /** |
|
| 421 | + * Filters the gateway settings. |
|
| 422 | + * |
|
| 423 | + * @param array $admin_settings |
|
| 424 | + */ |
|
| 425 | + public function admin_settings( $admin_settings ) { |
|
| 426 | + return $admin_settings; |
|
| 427 | + } |
|
| 428 | + |
|
| 429 | + /** |
|
| 430 | + * Retrieves the value of a gateway setting. |
|
| 431 | + * |
|
| 432 | + * @param string $option |
|
| 433 | + */ |
|
| 434 | + public function get_option( $option, $default = false ) { |
|
| 435 | + return wpinv_get_option( $this->id . '_' . $option, $default ); |
|
| 436 | + } |
|
| 437 | + |
|
| 438 | + /** |
|
| 439 | + * Check if a gateway supports a given feature. |
|
| 440 | + * |
|
| 441 | + * Gateways should override this to declare support (or lack of support) for a feature. |
|
| 442 | + * For backward compatibility, gateways support 'products' by default, but nothing else. |
|
| 443 | + * |
|
| 444 | + * @param string $feature string The name of a feature to test support for. |
|
| 445 | + * @return bool True if the gateway supports the feature, false otherwise. |
|
| 446 | + * @since 1.0.19 |
|
| 447 | + */ |
|
| 448 | + public function supports( $feature ) { |
|
| 449 | + return apply_filters( 'getpaid_payment_gateway_supports', in_array( $feature, $this->supports ), $feature, $this ); |
|
| 450 | + } |
|
| 165 | 451 | |
| 166 | - // Change the checkout button text. |
|
| 167 | - if ( ! empty( $this->checkout_button_text ) ) { |
|
| 168 | - add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) ); |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - // Check if a gateway is valid for a given currency. |
|
| 172 | - add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 ); |
|
| 173 | - |
|
| 174 | - // Generate the transaction url. |
|
| 175 | - add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 ); |
|
| 176 | - |
|
| 177 | - // Generate the subscription url. |
|
| 178 | - add_filter( "getpaid_gateway_{$this->id}_subscription_url", array( $this, 'filter_subscription_url' ), 10, 2 ); |
|
| 179 | - |
|
| 180 | - // Confirm payments. |
|
| 181 | - add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 ); |
|
| 182 | - |
|
| 183 | - // Verify IPNs. |
|
| 184 | - add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) ); |
|
| 185 | - |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - /** |
|
| 189 | - * Checks if this gateway is a given gateway. |
|
| 190 | - * |
|
| 191 | - * @since 1.0.19 |
|
| 192 | - * @return bool |
|
| 193 | - */ |
|
| 194 | - public function is( $gateway ) { |
|
| 195 | - return $gateway == $this->id; |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - /** |
|
| 199 | - * Returns a users saved tokens for this gateway. |
|
| 200 | - * |
|
| 201 | - * @since 1.0.19 |
|
| 202 | - * @return array |
|
| 203 | - */ |
|
| 204 | - public function get_tokens( $sandbox = null ) { |
|
| 205 | - |
|
| 206 | - if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) { |
|
| 207 | - $tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true ); |
|
| 208 | - |
|
| 209 | - if ( is_array( $tokens ) ) { |
|
| 210 | - $this->tokens = $tokens; |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - if ( ! is_bool( $sandbox ) ) { |
|
| 216 | - return $this->tokens; |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - $args = array( 'type' => $sandbox ? 'sandbox' : 'live' ); |
|
| 220 | - return wp_list_filter( $this->tokens, $args ); |
|
| 221 | - |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - /** |
|
| 225 | - * Saves a token for this gateway. |
|
| 226 | - * |
|
| 227 | - * @since 1.0.19 |
|
| 228 | - */ |
|
| 229 | - public function save_token( $token ) { |
|
| 230 | - |
|
| 231 | - $tokens = $this->get_tokens(); |
|
| 232 | - $tokens[] = $token; |
|
| 233 | - |
|
| 234 | - update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens ); |
|
| 235 | - |
|
| 236 | - $this->tokens = $tokens; |
|
| 237 | - |
|
| 238 | - } |
|
| 239 | - |
|
| 240 | - /** |
|
| 241 | - * Return the title for admin screens. |
|
| 242 | - * |
|
| 243 | - * @return string |
|
| 244 | - */ |
|
| 245 | - public function get_method_title() { |
|
| 246 | - return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this ); |
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - /** |
|
| 250 | - * Return the description for admin screens. |
|
| 251 | - * |
|
| 252 | - * @return string |
|
| 253 | - */ |
|
| 254 | - public function get_method_description() { |
|
| 255 | - return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this ); |
|
| 256 | - } |
|
| 257 | - |
|
| 258 | - /** |
|
| 259 | - * Get the success url. |
|
| 260 | - * |
|
| 261 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 262 | - * @return string |
|
| 263 | - */ |
|
| 264 | - public function get_return_url( $invoice ) { |
|
| 265 | - |
|
| 266 | - // Payment success url |
|
| 267 | - $return_url = add_query_arg( |
|
| 268 | - array( |
|
| 269 | - 'payment-confirm' => $this->id, |
|
| 270 | - 'invoice_key' => $invoice->get_key(), |
|
| 271 | - 'utm_nooverride' => 1 |
|
| 272 | - ), |
|
| 273 | - wpinv_get_success_page_uri() |
|
| 274 | - ); |
|
| 275 | - |
|
| 276 | - return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this ); |
|
| 277 | - } |
|
| 278 | - |
|
| 279 | - /** |
|
| 280 | - * Confirms payments when rendering the success page. |
|
| 281 | - * |
|
| 282 | - * @param string $content Success page content. |
|
| 283 | - * @return string |
|
| 284 | - */ |
|
| 285 | - public function confirm_payment( $content ) { |
|
| 286 | - |
|
| 287 | - // Retrieve the invoice. |
|
| 288 | - $invoice_id = getpaid_get_current_invoice_id(); |
|
| 289 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 290 | - |
|
| 291 | - // Ensure that it exists and that it is pending payment. |
|
| 292 | - if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) { |
|
| 293 | - return $content; |
|
| 294 | - } |
|
| 295 | - |
|
| 296 | - // Can the user view this invoice?? |
|
| 297 | - if ( ! wpinv_user_can_view_invoice( $invoice ) ) { |
|
| 298 | - return $content; |
|
| 299 | - } |
|
| 300 | - |
|
| 301 | - // Show payment processing indicator. |
|
| 302 | - return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) ); |
|
| 303 | - } |
|
| 304 | - |
|
| 305 | - /** |
|
| 306 | - * Processes ipns and marks payments as complete. |
|
| 307 | - * |
|
| 308 | - * @return void |
|
| 309 | - */ |
|
| 310 | - public function verify_ipn() {} |
|
| 311 | - |
|
| 312 | - /** |
|
| 313 | - * Get a link to the transaction on the 3rd party gateway site (if applicable). |
|
| 314 | - * |
|
| 315 | - * @param string $transaction_url transaction url. |
|
| 316 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 317 | - * @return string transaction URL, or empty string. |
|
| 318 | - */ |
|
| 319 | - public function filter_transaction_url( $transaction_url, $invoice ) { |
|
| 320 | - |
|
| 321 | - $transaction_id = $invoice->get_transaction_id(); |
|
| 322 | - |
|
| 323 | - if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) { |
|
| 324 | - $transaction_url = sprintf( $this->view_transaction_url, $transaction_id ); |
|
| 325 | - $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
| 326 | - $transaction_url = str_replace( '{sandbox}', $replace, $transaction_url ); |
|
| 327 | - } |
|
| 328 | - |
|
| 329 | - return $transaction_url; |
|
| 330 | - } |
|
| 331 | - |
|
| 332 | - /** |
|
| 333 | - * Get a link to the subscription on the 3rd party gateway site (if applicable). |
|
| 334 | - * |
|
| 335 | - * @param string $subscription_url transaction url. |
|
| 336 | - * @param WPInv_Invoice $invoice Invoice object. |
|
| 337 | - * @return string subscription URL, or empty string. |
|
| 338 | - */ |
|
| 339 | - public function filter_subscription_url( $subscription_url, $invoice ) { |
|
| 340 | - |
|
| 341 | - $profile_id = $invoice->get_subscription_id(); |
|
| 342 | - |
|
| 343 | - if ( ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) { |
|
| 344 | - |
|
| 345 | - $subscription_url = sprintf( $this->view_subscription_url, $profile_id ); |
|
| 346 | - $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
| 347 | - $subscription_url = str_replace( '{sandbox}', $replace, $subscription_url ); |
|
| 348 | - |
|
| 349 | - } |
|
| 350 | - |
|
| 351 | - return $subscription_url; |
|
| 352 | - } |
|
| 353 | - |
|
| 354 | - /** |
|
| 355 | - * Check if the gateway is available for use. |
|
| 356 | - * |
|
| 357 | - * @return bool |
|
| 358 | - */ |
|
| 359 | - public function is_available() { |
|
| 360 | - return ! empty( $this->enabled ); |
|
| 361 | - } |
|
| 362 | - |
|
| 363 | - /** |
|
| 364 | - * Return the gateway's title. |
|
| 365 | - * |
|
| 366 | - * @return string |
|
| 367 | - */ |
|
| 368 | - public function get_title() { |
|
| 369 | - return apply_filters( 'getpaid_gateway_title', $this->title, $this ); |
|
| 370 | - } |
|
| 371 | - |
|
| 372 | - /** |
|
| 373 | - * Return the gateway's description. |
|
| 374 | - * |
|
| 375 | - * @return string |
|
| 376 | - */ |
|
| 377 | - public function get_description() { |
|
| 378 | - return apply_filters( 'getpaid_gateway_description', $this->description, $this ); |
|
| 379 | - } |
|
| 380 | - |
|
| 381 | - /** |
|
| 382 | - * Process Payment. |
|
| 383 | - * |
|
| 384 | - * |
|
| 385 | - * @param WPInv_Invoice $invoice Invoice. |
|
| 386 | - * @param array $submission_data Posted checkout fields. |
|
| 387 | - * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
| 388 | - * @return void |
|
| 389 | - */ |
|
| 390 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
| 391 | - // Process the payment then either redirect to the success page or the gateway. |
|
| 392 | - do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission ); |
|
| 393 | - } |
|
| 394 | - |
|
| 395 | - /** |
|
| 396 | - * Process refund. |
|
| 397 | - * |
|
| 398 | - * If the gateway declares 'refunds' support, this will allow it to refund. |
|
| 399 | - * a passed in amount. |
|
| 400 | - * |
|
| 401 | - * @param WPInv_Invoice $invoice Invoice. |
|
| 402 | - * @param float $amount Refund amount. |
|
| 403 | - * @param string $reason Refund reason. |
|
| 404 | - * @return WP_Error|bool True or false based on success, or a WP_Error object. |
|
| 405 | - */ |
|
| 406 | - public function process_refund( $invoice, $amount = null, $reason = '' ) { |
|
| 407 | - return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason ); |
|
| 408 | - } |
|
| 409 | - |
|
| 410 | - /** |
|
| 411 | - * Displays the payment fields, credit cards etc. |
|
| 412 | - * |
|
| 413 | - * @param int $invoice_id 0 or invoice id. |
|
| 414 | - * @param GetPaid_Payment_Form $form Current payment form. |
|
| 415 | - */ |
|
| 416 | - public function payment_fields( $invoice_id, $form ) { |
|
| 417 | - do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form ); |
|
| 418 | - } |
|
| 419 | - |
|
| 420 | - /** |
|
| 421 | - * Filters the gateway settings. |
|
| 422 | - * |
|
| 423 | - * @param array $admin_settings |
|
| 424 | - */ |
|
| 425 | - public function admin_settings( $admin_settings ) { |
|
| 426 | - return $admin_settings; |
|
| 427 | - } |
|
| 428 | - |
|
| 429 | - /** |
|
| 430 | - * Retrieves the value of a gateway setting. |
|
| 431 | - * |
|
| 432 | - * @param string $option |
|
| 433 | - */ |
|
| 434 | - public function get_option( $option, $default = false ) { |
|
| 435 | - return wpinv_get_option( $this->id . '_' . $option, $default ); |
|
| 436 | - } |
|
| 437 | - |
|
| 438 | - /** |
|
| 439 | - * Check if a gateway supports a given feature. |
|
| 440 | - * |
|
| 441 | - * Gateways should override this to declare support (or lack of support) for a feature. |
|
| 442 | - * For backward compatibility, gateways support 'products' by default, but nothing else. |
|
| 443 | - * |
|
| 444 | - * @param string $feature string The name of a feature to test support for. |
|
| 445 | - * @return bool True if the gateway supports the feature, false otherwise. |
|
| 446 | - * @since 1.0.19 |
|
| 447 | - */ |
|
| 448 | - public function supports( $feature ) { |
|
| 449 | - return apply_filters( 'getpaid_payment_gateway_supports', in_array( $feature, $this->supports ), $feature, $this ); |
|
| 450 | - } |
|
| 451 | - |
|
| 452 | - /** |
|
| 453 | - * Returns the credit card form html. |
|
| 454 | - * |
|
| 455 | - * @param bool $save whether or not to display the save button. |
|
| 456 | - */ |
|
| 452 | + /** |
|
| 453 | + * Returns the credit card form html. |
|
| 454 | + * |
|
| 455 | + * @param bool $save whether or not to display the save button. |
|
| 456 | + */ |
|
| 457 | 457 | public function get_cc_form( $save = false ) { |
| 458 | 458 | |
| 459 | - ob_start(); |
|
| 459 | + ob_start(); |
|
| 460 | 460 | |
| 461 | 461 | $id_prefix = esc_attr( uniqid( $this->id ) ); |
| 462 | 462 | |
@@ -551,8 +551,8 @@ discard block |
||
| 551 | 551 | 'name' => $this->id . '[cc_cvv2]', |
| 552 | 552 | 'id' => "$id_prefix-cc-cvv2", |
| 553 | 553 | 'label' => __( 'CCV', 'invoicing' ), |
| 554 | - 'label_type' => 'vertical', |
|
| 555 | - 'class' => 'form-control-sm', |
|
| 554 | + 'label_type' => 'vertical', |
|
| 555 | + 'class' => 'form-control-sm', |
|
| 556 | 556 | ) |
| 557 | 557 | ); |
| 558 | 558 | ?> |
@@ -562,175 +562,175 @@ discard block |
||
| 562 | 562 | |
| 563 | 563 | <?php |
| 564 | 564 | |
| 565 | - if ( $save ) { |
|
| 566 | - echo $this->save_payment_method_checkbox(); |
|
| 567 | - } |
|
| 565 | + if ( $save ) { |
|
| 566 | + echo $this->save_payment_method_checkbox(); |
|
| 567 | + } |
|
| 568 | 568 | |
| 569 | - ?> |
|
| 569 | + ?> |
|
| 570 | 570 | </div> |
| 571 | 571 | |
| 572 | 572 | </div> |
| 573 | 573 | <?php |
| 574 | 574 | |
| 575 | - return ob_get_clean(); |
|
| 575 | + return ob_get_clean(); |
|
| 576 | 576 | |
| 577 | 577 | } |
| 578 | 578 | |
| 579 | - /** |
|
| 580 | - * Displays a new payment method entry form. |
|
| 581 | - * |
|
| 582 | - * @since 1.0.19 |
|
| 583 | - */ |
|
| 584 | - public function new_payment_method_entry( $form ) { |
|
| 585 | - echo "<div class='getpaid-new-payment-method-form' style='display:none;'>$form</div>"; |
|
| 586 | - } |
|
| 587 | - |
|
| 588 | - /** |
|
| 589 | - * Grab and display our saved payment methods. |
|
| 590 | - * |
|
| 591 | - * @since 1.0.19 |
|
| 592 | - */ |
|
| 593 | - public function saved_payment_methods() { |
|
| 594 | - $html = '<ul class="getpaid-saved-payment-methods m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">'; |
|
| 595 | - |
|
| 596 | - foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) { |
|
| 597 | - $html .= $this->get_saved_payment_method_option_html( $token ); |
|
| 598 | - } |
|
| 599 | - |
|
| 600 | - $html .= $this->get_new_payment_method_option_html(); |
|
| 601 | - $html .= '</ul>'; |
|
| 602 | - |
|
| 603 | - echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this ); |
|
| 604 | - } |
|
| 605 | - |
|
| 606 | - /** |
|
| 607 | - * Gets saved payment method HTML from a token. |
|
| 608 | - * |
|
| 609 | - * @since 1.0.19 |
|
| 610 | - * @param array $token Payment Token. |
|
| 611 | - * @return string Generated payment method HTML |
|
| 612 | - */ |
|
| 613 | - public function get_saved_payment_method_option_html( $token ) { |
|
| 614 | - |
|
| 615 | - return sprintf( |
|
| 616 | - '<li class="getpaid-payment-method form-group"> |
|
| 579 | + /** |
|
| 580 | + * Displays a new payment method entry form. |
|
| 581 | + * |
|
| 582 | + * @since 1.0.19 |
|
| 583 | + */ |
|
| 584 | + public function new_payment_method_entry( $form ) { |
|
| 585 | + echo "<div class='getpaid-new-payment-method-form' style='display:none;'>$form</div>"; |
|
| 586 | + } |
|
| 587 | + |
|
| 588 | + /** |
|
| 589 | + * Grab and display our saved payment methods. |
|
| 590 | + * |
|
| 591 | + * @since 1.0.19 |
|
| 592 | + */ |
|
| 593 | + public function saved_payment_methods() { |
|
| 594 | + $html = '<ul class="getpaid-saved-payment-methods m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">'; |
|
| 595 | + |
|
| 596 | + foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) { |
|
| 597 | + $html .= $this->get_saved_payment_method_option_html( $token ); |
|
| 598 | + } |
|
| 599 | + |
|
| 600 | + $html .= $this->get_new_payment_method_option_html(); |
|
| 601 | + $html .= '</ul>'; |
|
| 602 | + |
|
| 603 | + echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this ); |
|
| 604 | + } |
|
| 605 | + |
|
| 606 | + /** |
|
| 607 | + * Gets saved payment method HTML from a token. |
|
| 608 | + * |
|
| 609 | + * @since 1.0.19 |
|
| 610 | + * @param array $token Payment Token. |
|
| 611 | + * @return string Generated payment method HTML |
|
| 612 | + */ |
|
| 613 | + public function get_saved_payment_method_option_html( $token ) { |
|
| 614 | + |
|
| 615 | + return sprintf( |
|
| 616 | + '<li class="getpaid-payment-method form-group"> |
|
| 617 | 617 | <label> |
| 618 | 618 | <input name="getpaid-%1$s-payment-method" type="radio" value="%2$s" style="width:auto;" class="getpaid-saved-payment-method-token-input" %4$s /> |
| 619 | 619 | <span>%3$s</span> |
| 620 | 620 | </label> |
| 621 | 621 | </li>', |
| 622 | - esc_attr( $this->id ), |
|
| 623 | - esc_attr( $token['id'] ), |
|
| 624 | - esc_html( $token['name'] ), |
|
| 625 | - checked( empty( $token['default'] ), false, false ) |
|
| 626 | - ); |
|
| 622 | + esc_attr( $this->id ), |
|
| 623 | + esc_attr( $token['id'] ), |
|
| 624 | + esc_html( $token['name'] ), |
|
| 625 | + checked( empty( $token['default'] ), false, false ) |
|
| 626 | + ); |
|
| 627 | 627 | |
| 628 | - } |
|
| 628 | + } |
|
| 629 | 629 | |
| 630 | - /** |
|
| 631 | - * Displays a radio button for entering a new payment method (new CC details) instead of using a saved method. |
|
| 632 | - * |
|
| 633 | - * @since 1.0.19 |
|
| 634 | - */ |
|
| 635 | - public function get_new_payment_method_option_html() { |
|
| 630 | + /** |
|
| 631 | + * Displays a radio button for entering a new payment method (new CC details) instead of using a saved method. |
|
| 632 | + * |
|
| 633 | + * @since 1.0.19 |
|
| 634 | + */ |
|
| 635 | + public function get_new_payment_method_option_html() { |
|
| 636 | 636 | |
| 637 | - $label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this ); |
|
| 637 | + $label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this ); |
|
| 638 | 638 | |
| 639 | - return sprintf( |
|
| 640 | - '<li class="getpaid-new-payment-method"> |
|
| 639 | + return sprintf( |
|
| 640 | + '<li class="getpaid-new-payment-method"> |
|
| 641 | 641 | <label> |
| 642 | 642 | <input name="getpaid-%1$s-payment-method" type="radio" value="new" style="width:auto;" /> |
| 643 | 643 | <span>%2$s</span> |
| 644 | 644 | </label> |
| 645 | 645 | </li>', |
| 646 | - esc_attr( $this->id ), |
|
| 647 | - esc_html( $label ) |
|
| 648 | - ); |
|
| 646 | + esc_attr( $this->id ), |
|
| 647 | + esc_html( $label ) |
|
| 648 | + ); |
|
| 649 | 649 | |
| 650 | - } |
|
| 650 | + } |
|
| 651 | 651 | |
| 652 | - /** |
|
| 653 | - * Outputs a checkbox for saving a new payment method to the database. |
|
| 654 | - * |
|
| 655 | - * @since 1.0.19 |
|
| 656 | - */ |
|
| 657 | - public function save_payment_method_checkbox() { |
|
| 652 | + /** |
|
| 653 | + * Outputs a checkbox for saving a new payment method to the database. |
|
| 654 | + * |
|
| 655 | + * @since 1.0.19 |
|
| 656 | + */ |
|
| 657 | + public function save_payment_method_checkbox() { |
|
| 658 | 658 | |
| 659 | - return sprintf( |
|
| 660 | - '<p class="form-group getpaid-save-payment-method"> |
|
| 659 | + return sprintf( |
|
| 660 | + '<p class="form-group getpaid-save-payment-method"> |
|
| 661 | 661 | <label> |
| 662 | 662 | <input name="getpaid-%1$s-new-payment-method" type="checkbox" value="true" style="width:auto;" /> |
| 663 | 663 | <span>%2$s</span> |
| 664 | 664 | </label> |
| 665 | 665 | </p>', |
| 666 | - esc_attr( $this->id ), |
|
| 667 | - esc_html__( 'Save payment method', 'invoicing' ) |
|
| 668 | - ); |
|
| 666 | + esc_attr( $this->id ), |
|
| 667 | + esc_html__( 'Save payment method', 'invoicing' ) |
|
| 668 | + ); |
|
| 669 | 669 | |
| 670 | - } |
|
| 670 | + } |
|
| 671 | 671 | |
| 672 | - /** |
|
| 673 | - * Registers the gateway. |
|
| 674 | - * |
|
| 675 | - * @return array |
|
| 676 | - */ |
|
| 677 | - public function register_gateway( $gateways ) { |
|
| 672 | + /** |
|
| 673 | + * Registers the gateway. |
|
| 674 | + * |
|
| 675 | + * @return array |
|
| 676 | + */ |
|
| 677 | + public function register_gateway( $gateways ) { |
|
| 678 | 678 | |
| 679 | - $gateways[ $this->id ] = array( |
|
| 679 | + $gateways[ $this->id ] = array( |
|
| 680 | 680 | |
| 681 | - 'admin_label' => $this->method_title, |
|
| 681 | + 'admin_label' => $this->method_title, |
|
| 682 | 682 | 'checkout_label' => $this->title, |
| 683 | - 'ordering' => $this->order, |
|
| 684 | - |
|
| 685 | - ); |
|
| 686 | - |
|
| 687 | - return $gateways; |
|
| 688 | - |
|
| 689 | - } |
|
| 690 | - |
|
| 691 | - /** |
|
| 692 | - * Checks whether or not this is a sandbox request. |
|
| 693 | - * |
|
| 694 | - * @param WPInv_Invoice|null $invoice Invoice object or null. |
|
| 695 | - * @return bool |
|
| 696 | - */ |
|
| 697 | - public function is_sandbox( $invoice = null ) { |
|
| 698 | - |
|
| 699 | - if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) { |
|
| 700 | - return $invoice->get_mode() == 'test'; |
|
| 701 | - } |
|
| 702 | - |
|
| 703 | - return wpinv_is_test_mode( $this->id ); |
|
| 704 | - |
|
| 705 | - } |
|
| 706 | - |
|
| 707 | - /** |
|
| 708 | - * Renames the checkout button |
|
| 709 | - * |
|
| 710 | - * @return string |
|
| 711 | - */ |
|
| 712 | - public function rename_checkout_button() { |
|
| 713 | - return $this->checkout_button_text; |
|
| 714 | - } |
|
| 715 | - |
|
| 716 | - /** |
|
| 717 | - * Validate gateway currency |
|
| 718 | - * |
|
| 719 | - * @return bool |
|
| 720 | - */ |
|
| 721 | - public function validate_currency( $validation, $currency ) { |
|
| 722 | - |
|
| 723 | - // Required currencies. |
|
| 724 | - if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) { |
|
| 725 | - return false; |
|
| 726 | - } |
|
| 727 | - |
|
| 728 | - // Excluded currencies. |
|
| 729 | - if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) { |
|
| 730 | - return false; |
|
| 731 | - } |
|
| 732 | - |
|
| 733 | - return $validation; |
|
| 734 | - } |
|
| 683 | + 'ordering' => $this->order, |
|
| 684 | + |
|
| 685 | + ); |
|
| 686 | + |
|
| 687 | + return $gateways; |
|
| 688 | + |
|
| 689 | + } |
|
| 690 | + |
|
| 691 | + /** |
|
| 692 | + * Checks whether or not this is a sandbox request. |
|
| 693 | + * |
|
| 694 | + * @param WPInv_Invoice|null $invoice Invoice object or null. |
|
| 695 | + * @return bool |
|
| 696 | + */ |
|
| 697 | + public function is_sandbox( $invoice = null ) { |
|
| 698 | + |
|
| 699 | + if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) { |
|
| 700 | + return $invoice->get_mode() == 'test'; |
|
| 701 | + } |
|
| 702 | + |
|
| 703 | + return wpinv_is_test_mode( $this->id ); |
|
| 704 | + |
|
| 705 | + } |
|
| 706 | + |
|
| 707 | + /** |
|
| 708 | + * Renames the checkout button |
|
| 709 | + * |
|
| 710 | + * @return string |
|
| 711 | + */ |
|
| 712 | + public function rename_checkout_button() { |
|
| 713 | + return $this->checkout_button_text; |
|
| 714 | + } |
|
| 715 | + |
|
| 716 | + /** |
|
| 717 | + * Validate gateway currency |
|
| 718 | + * |
|
| 719 | + * @return bool |
|
| 720 | + */ |
|
| 721 | + public function validate_currency( $validation, $currency ) { |
|
| 722 | + |
|
| 723 | + // Required currencies. |
|
| 724 | + if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) { |
|
| 725 | + return false; |
|
| 726 | + } |
|
| 727 | + |
|
| 728 | + // Excluded currencies. |
|
| 729 | + if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) { |
|
| 730 | + return false; |
|
| 731 | + } |
|
| 732 | + |
|
| 733 | + return $validation; |
|
| 734 | + } |
|
| 735 | 735 | |
| 736 | 736 | } |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | -defined( 'ABSPATH' ) || exit; |
|
| 7 | +defined('ABSPATH') || exit; |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Abstaract Payment Gateway class. |
@@ -139,49 +139,49 @@ discard block |
||
| 139 | 139 | public function __construct() { |
| 140 | 140 | |
| 141 | 141 | // Register gateway. |
| 142 | - add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) ); |
|
| 142 | + add_filter('wpinv_payment_gateways', array($this, 'register_gateway')); |
|
| 143 | 143 | |
| 144 | - $this->enabled = wpinv_is_gateway_active( $this->id ); |
|
| 144 | + $this->enabled = wpinv_is_gateway_active($this->id); |
|
| 145 | 145 | |
| 146 | 146 | // Enable Subscriptions. |
| 147 | - if ( $this->supports( 'subscription' ) ) { |
|
| 148 | - add_filter( "wpinv_{$this->id}_support_subscription", '__return_true' ); |
|
| 147 | + if ($this->supports('subscription')) { |
|
| 148 | + add_filter("wpinv_{$this->id}_support_subscription", '__return_true'); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | // Enable sandbox. |
| 152 | - if ( $this->supports( 'sandbox' ) ) { |
|
| 153 | - add_filter( "wpinv_{$this->id}_supports_sandbox", '__return_true' ); |
|
| 152 | + if ($this->supports('sandbox')) { |
|
| 153 | + add_filter("wpinv_{$this->id}_supports_sandbox", '__return_true'); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | // Gateway settings. |
| 157 | - add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) ); |
|
| 157 | + add_filter("wpinv_gateway_settings_{$this->id}", array($this, 'admin_settings')); |
|
| 158 | 158 | |
| 159 | 159 | |
| 160 | 160 | // Gateway checkout fiellds. |
| 161 | - add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 ); |
|
| 161 | + add_action("wpinv_{$this->id}_cc_form", array($this, 'payment_fields'), 10, 2); |
|
| 162 | 162 | |
| 163 | 163 | // Process payment. |
| 164 | - add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 ); |
|
| 164 | + add_action("getpaid_gateway_{$this->id}", array($this, 'process_payment'), 10, 3); |
|
| 165 | 165 | |
| 166 | 166 | // Change the checkout button text. |
| 167 | - if ( ! empty( $this->checkout_button_text ) ) { |
|
| 168 | - add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) ); |
|
| 167 | + if (!empty($this->checkout_button_text)) { |
|
| 168 | + add_filter("getpaid_gateway_{$this->id}_checkout_button_label", array($this, 'rename_checkout_button')); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | // Check if a gateway is valid for a given currency. |
| 172 | - add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 ); |
|
| 172 | + add_filter("getpaid_gateway_{$this->id}_is_valid_for_currency", array($this, 'validate_currency'), 10, 2); |
|
| 173 | 173 | |
| 174 | 174 | // Generate the transaction url. |
| 175 | - add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 ); |
|
| 175 | + add_filter("getpaid_gateway_{$this->id}_transaction_url", array($this, 'filter_transaction_url'), 10, 2); |
|
| 176 | 176 | |
| 177 | 177 | // Generate the subscription url. |
| 178 | - add_filter( "getpaid_gateway_{$this->id}_subscription_url", array( $this, 'filter_subscription_url' ), 10, 2 ); |
|
| 178 | + add_filter("getpaid_gateway_{$this->id}_subscription_url", array($this, 'filter_subscription_url'), 10, 2); |
|
| 179 | 179 | |
| 180 | 180 | // Confirm payments. |
| 181 | - add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 ); |
|
| 181 | + add_filter("wpinv_payment_confirm_{$this->id}", array($this, 'confirm_payment'), 10, 2); |
|
| 182 | 182 | |
| 183 | 183 | // Verify IPNs. |
| 184 | - add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) ); |
|
| 184 | + add_action("wpinv_verify_{$this->id}_ipn", array($this, 'verify_ipn')); |
|
| 185 | 185 | |
| 186 | 186 | } |
| 187 | 187 | |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | * @since 1.0.19 |
| 192 | 192 | * @return bool |
| 193 | 193 | */ |
| 194 | - public function is( $gateway ) { |
|
| 194 | + public function is($gateway) { |
|
| 195 | 195 | return $gateway == $this->id; |
| 196 | 196 | } |
| 197 | 197 | |
@@ -201,23 +201,23 @@ discard block |
||
| 201 | 201 | * @since 1.0.19 |
| 202 | 202 | * @return array |
| 203 | 203 | */ |
| 204 | - public function get_tokens( $sandbox = null ) { |
|
| 204 | + public function get_tokens($sandbox = null) { |
|
| 205 | 205 | |
| 206 | - if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) { |
|
| 207 | - $tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true ); |
|
| 206 | + if (is_user_logged_in() && $this->supports('tokens') && 0 == count($this->tokens)) { |
|
| 207 | + $tokens = get_user_meta(get_current_user_id(), "getpaid_{$this->id}_tokens", true); |
|
| 208 | 208 | |
| 209 | - if ( is_array( $tokens ) ) { |
|
| 209 | + if (is_array($tokens)) { |
|
| 210 | 210 | $this->tokens = $tokens; |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - if ( ! is_bool( $sandbox ) ) { |
|
| 215 | + if (!is_bool($sandbox)) { |
|
| 216 | 216 | return $this->tokens; |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - $args = array( 'type' => $sandbox ? 'sandbox' : 'live' ); |
|
| 220 | - return wp_list_filter( $this->tokens, $args ); |
|
| 219 | + $args = array('type' => $sandbox ? 'sandbox' : 'live'); |
|
| 220 | + return wp_list_filter($this->tokens, $args); |
|
| 221 | 221 | |
| 222 | 222 | } |
| 223 | 223 | |
@@ -226,12 +226,12 @@ discard block |
||
| 226 | 226 | * |
| 227 | 227 | * @since 1.0.19 |
| 228 | 228 | */ |
| 229 | - public function save_token( $token ) { |
|
| 229 | + public function save_token($token) { |
|
| 230 | 230 | |
| 231 | 231 | $tokens = $this->get_tokens(); |
| 232 | 232 | $tokens[] = $token; |
| 233 | 233 | |
| 234 | - update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens ); |
|
| 234 | + update_user_meta(get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens); |
|
| 235 | 235 | |
| 236 | 236 | $this->tokens = $tokens; |
| 237 | 237 | |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | * @return string |
| 244 | 244 | */ |
| 245 | 245 | public function get_method_title() { |
| 246 | - return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this ); |
|
| 246 | + return apply_filters('getpaid_gateway_method_title', $this->method_title, $this); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | /** |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | * @return string |
| 253 | 253 | */ |
| 254 | 254 | public function get_method_description() { |
| 255 | - return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this ); |
|
| 255 | + return apply_filters('getpaid_gateway_method_description', $this->method_description, $this); |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | /** |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | * @param WPInv_Invoice $invoice Invoice object. |
| 262 | 262 | * @return string |
| 263 | 263 | */ |
| 264 | - public function get_return_url( $invoice ) { |
|
| 264 | + public function get_return_url($invoice) { |
|
| 265 | 265 | |
| 266 | 266 | // Payment success url |
| 267 | 267 | $return_url = add_query_arg( |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | wpinv_get_success_page_uri() |
| 274 | 274 | ); |
| 275 | 275 | |
| 276 | - return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this ); |
|
| 276 | + return apply_filters('getpaid_gateway_success_url', $return_url, $invoice, $this); |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | /** |
@@ -282,24 +282,24 @@ discard block |
||
| 282 | 282 | * @param string $content Success page content. |
| 283 | 283 | * @return string |
| 284 | 284 | */ |
| 285 | - public function confirm_payment( $content ) { |
|
| 285 | + public function confirm_payment($content) { |
|
| 286 | 286 | |
| 287 | 287 | // Retrieve the invoice. |
| 288 | 288 | $invoice_id = getpaid_get_current_invoice_id(); |
| 289 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 289 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 290 | 290 | |
| 291 | 291 | // Ensure that it exists and that it is pending payment. |
| 292 | - if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) { |
|
| 292 | + if (empty($invoice_id) || !$invoice->needs_payment()) { |
|
| 293 | 293 | return $content; |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | // Can the user view this invoice?? |
| 297 | - if ( ! wpinv_user_can_view_invoice( $invoice ) ) { |
|
| 297 | + if (!wpinv_user_can_view_invoice($invoice)) { |
|
| 298 | 298 | return $content; |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | // Show payment processing indicator. |
| 302 | - return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) ); |
|
| 302 | + return wpinv_get_template_html('wpinv-payment-processing.php', compact('invoice')); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | /** |
@@ -316,14 +316,14 @@ discard block |
||
| 316 | 316 | * @param WPInv_Invoice $invoice Invoice object. |
| 317 | 317 | * @return string transaction URL, or empty string. |
| 318 | 318 | */ |
| 319 | - public function filter_transaction_url( $transaction_url, $invoice ) { |
|
| 319 | + public function filter_transaction_url($transaction_url, $invoice) { |
|
| 320 | 320 | |
| 321 | - $transaction_id = $invoice->get_transaction_id(); |
|
| 321 | + $transaction_id = $invoice->get_transaction_id(); |
|
| 322 | 322 | |
| 323 | - if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) { |
|
| 324 | - $transaction_url = sprintf( $this->view_transaction_url, $transaction_id ); |
|
| 325 | - $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
| 326 | - $transaction_url = str_replace( '{sandbox}', $replace, $transaction_url ); |
|
| 323 | + if (!empty($this->view_transaction_url) && !empty($transaction_id)) { |
|
| 324 | + $transaction_url = sprintf($this->view_transaction_url, $transaction_id); |
|
| 325 | + $replace = $this->is_sandbox($invoice) ? 'sandbox' : ''; |
|
| 326 | + $transaction_url = str_replace('{sandbox}', $replace, $transaction_url); |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | return $transaction_url; |
@@ -336,15 +336,15 @@ discard block |
||
| 336 | 336 | * @param WPInv_Invoice $invoice Invoice object. |
| 337 | 337 | * @return string subscription URL, or empty string. |
| 338 | 338 | */ |
| 339 | - public function filter_subscription_url( $subscription_url, $invoice ) { |
|
| 339 | + public function filter_subscription_url($subscription_url, $invoice) { |
|
| 340 | 340 | |
| 341 | - $profile_id = $invoice->get_subscription_id(); |
|
| 341 | + $profile_id = $invoice->get_subscription_id(); |
|
| 342 | 342 | |
| 343 | - if ( ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) { |
|
| 343 | + if (!empty($this->view_subscription_url) && !empty($profile_id)) { |
|
| 344 | 344 | |
| 345 | - $subscription_url = sprintf( $this->view_subscription_url, $profile_id ); |
|
| 346 | - $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
| 347 | - $subscription_url = str_replace( '{sandbox}', $replace, $subscription_url ); |
|
| 345 | + $subscription_url = sprintf($this->view_subscription_url, $profile_id); |
|
| 346 | + $replace = $this->is_sandbox($invoice) ? 'sandbox' : ''; |
|
| 347 | + $subscription_url = str_replace('{sandbox}', $replace, $subscription_url); |
|
| 348 | 348 | |
| 349 | 349 | } |
| 350 | 350 | |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | * @return bool |
| 358 | 358 | */ |
| 359 | 359 | public function is_available() { |
| 360 | - return ! empty( $this->enabled ); |
|
| 360 | + return !empty($this->enabled); |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | /** |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | * @return string |
| 367 | 367 | */ |
| 368 | 368 | public function get_title() { |
| 369 | - return apply_filters( 'getpaid_gateway_title', $this->title, $this ); |
|
| 369 | + return apply_filters('getpaid_gateway_title', $this->title, $this); |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | /** |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | * @return string |
| 376 | 376 | */ |
| 377 | 377 | public function get_description() { |
| 378 | - return apply_filters( 'getpaid_gateway_description', $this->description, $this ); |
|
| 378 | + return apply_filters('getpaid_gateway_description', $this->description, $this); |
|
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | /** |
@@ -387,9 +387,9 @@ discard block |
||
| 387 | 387 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
| 388 | 388 | * @return void |
| 389 | 389 | */ |
| 390 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
| 390 | + public function process_payment($invoice, $submission_data, $submission) { |
|
| 391 | 391 | // Process the payment then either redirect to the success page or the gateway. |
| 392 | - do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission ); |
|
| 392 | + do_action('getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission); |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | /** |
@@ -403,8 +403,8 @@ discard block |
||
| 403 | 403 | * @param string $reason Refund reason. |
| 404 | 404 | * @return WP_Error|bool True or false based on success, or a WP_Error object. |
| 405 | 405 | */ |
| 406 | - public function process_refund( $invoice, $amount = null, $reason = '' ) { |
|
| 407 | - return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason ); |
|
| 406 | + public function process_refund($invoice, $amount = null, $reason = '') { |
|
| 407 | + return apply_filters('getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason); |
|
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | /** |
@@ -413,8 +413,8 @@ discard block |
||
| 413 | 413 | * @param int $invoice_id 0 or invoice id. |
| 414 | 414 | * @param GetPaid_Payment_Form $form Current payment form. |
| 415 | 415 | */ |
| 416 | - public function payment_fields( $invoice_id, $form ) { |
|
| 417 | - do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form ); |
|
| 416 | + public function payment_fields($invoice_id, $form) { |
|
| 417 | + do_action('getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form); |
|
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | /** |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | * |
| 423 | 423 | * @param array $admin_settings |
| 424 | 424 | */ |
| 425 | - public function admin_settings( $admin_settings ) { |
|
| 425 | + public function admin_settings($admin_settings) { |
|
| 426 | 426 | return $admin_settings; |
| 427 | 427 | } |
| 428 | 428 | |
@@ -431,8 +431,8 @@ discard block |
||
| 431 | 431 | * |
| 432 | 432 | * @param string $option |
| 433 | 433 | */ |
| 434 | - public function get_option( $option, $default = false ) { |
|
| 435 | - return wpinv_get_option( $this->id . '_' . $option, $default ); |
|
| 434 | + public function get_option($option, $default = false) { |
|
| 435 | + return wpinv_get_option($this->id . '_' . $option, $default); |
|
| 436 | 436 | } |
| 437 | 437 | |
| 438 | 438 | /** |
@@ -445,8 +445,8 @@ discard block |
||
| 445 | 445 | * @return bool True if the gateway supports the feature, false otherwise. |
| 446 | 446 | * @since 1.0.19 |
| 447 | 447 | */ |
| 448 | - public function supports( $feature ) { |
|
| 449 | - return apply_filters( 'getpaid_payment_gateway_supports', in_array( $feature, $this->supports ), $feature, $this ); |
|
| 448 | + public function supports($feature) { |
|
| 449 | + return apply_filters('getpaid_payment_gateway_supports', in_array($feature, $this->supports), $feature, $this); |
|
| 450 | 450 | } |
| 451 | 451 | |
| 452 | 452 | /** |
@@ -454,36 +454,36 @@ discard block |
||
| 454 | 454 | * |
| 455 | 455 | * @param bool $save whether or not to display the save button. |
| 456 | 456 | */ |
| 457 | - public function get_cc_form( $save = false ) { |
|
| 457 | + public function get_cc_form($save = false) { |
|
| 458 | 458 | |
| 459 | 459 | ob_start(); |
| 460 | 460 | |
| 461 | - $id_prefix = esc_attr( uniqid( $this->id ) ); |
|
| 461 | + $id_prefix = esc_attr(uniqid($this->id)); |
|
| 462 | 462 | |
| 463 | 463 | $months = array( |
| 464 | - '01' => __( 'January', 'invoicing' ), |
|
| 465 | - '02' => __( 'February', 'invoicing' ), |
|
| 466 | - '03' => __( 'March', 'invoicing' ), |
|
| 467 | - '04' => __( 'April', 'invoicing' ), |
|
| 468 | - '05' => __( 'May', 'invoicing' ), |
|
| 469 | - '06' => __( 'June', 'invoicing' ), |
|
| 470 | - '07' => __( 'July', 'invoicing' ), |
|
| 471 | - '08' => __( 'August', 'invoicing' ), |
|
| 472 | - '09' => __( 'September', 'invoicing' ), |
|
| 473 | - '10' => __( 'October', 'invoicing' ), |
|
| 474 | - '11' => __( 'November', 'invoicing' ), |
|
| 475 | - '12' => __( 'December', 'invoicing' ), |
|
| 464 | + '01' => __('January', 'invoicing'), |
|
| 465 | + '02' => __('February', 'invoicing'), |
|
| 466 | + '03' => __('March', 'invoicing'), |
|
| 467 | + '04' => __('April', 'invoicing'), |
|
| 468 | + '05' => __('May', 'invoicing'), |
|
| 469 | + '06' => __('June', 'invoicing'), |
|
| 470 | + '07' => __('July', 'invoicing'), |
|
| 471 | + '08' => __('August', 'invoicing'), |
|
| 472 | + '09' => __('September', 'invoicing'), |
|
| 473 | + '10' => __('October', 'invoicing'), |
|
| 474 | + '11' => __('November', 'invoicing'), |
|
| 475 | + '12' => __('December', 'invoicing'), |
|
| 476 | 476 | ); |
| 477 | 477 | |
| 478 | - $year = (int) date( 'Y', current_time( 'timestamp' ) ); |
|
| 478 | + $year = (int) date('Y', current_time('timestamp')); |
|
| 479 | 479 | $years = array(); |
| 480 | 480 | |
| 481 | - for ( $i = 0; $i <= 10; $i++ ) { |
|
| 482 | - $years[ $year + $i ] = $year + $i; |
|
| 481 | + for ($i = 0; $i <= 10; $i++) { |
|
| 482 | + $years[$year + $i] = $year + $i; |
|
| 483 | 483 | } |
| 484 | 484 | |
| 485 | 485 | ?> |
| 486 | - <div class="<?php echo esc_attr( $this->id );?>-cc-form getpaid-cc-form mt-1"> |
|
| 486 | + <div class="<?php echo esc_attr($this->id); ?>-cc-form getpaid-cc-form mt-1"> |
|
| 487 | 487 | |
| 488 | 488 | |
| 489 | 489 | <div class="getpaid-cc-card-inner"> |
@@ -492,14 +492,14 @@ discard block |
||
| 492 | 492 | <div class="col-12"> |
| 493 | 493 | |
| 494 | 494 | <div class="form-group"> |
| 495 | - <label for="<?php echo esc_attr( "$id_prefix-cc-number" ) ?>"><?php _e( 'Card number', 'invoicing' ); ?></label> |
|
| 495 | + <label for="<?php echo esc_attr("$id_prefix-cc-number") ?>"><?php _e('Card number', 'invoicing'); ?></label> |
|
| 496 | 496 | <div class="input-group input-group-sm"> |
| 497 | 497 | <div class="input-group-prepend "> |
| 498 | 498 | <span class="input-group-text"> |
| 499 | 499 | <i class="fa fa-credit-card"></i> |
| 500 | 500 | </span> |
| 501 | 501 | </div> |
| 502 | - <input type="text" name="<?php echo esc_attr( $this->id . '[cc_number]' ) ?>authorizenet[cc_number]" id="<?php echo esc_attr( "$id_prefix-cc-number" ) ?>" class="form-control form-control-sm"> |
|
| 502 | + <input type="text" name="<?php echo esc_attr($this->id . '[cc_number]') ?>authorizenet[cc_number]" id="<?php echo esc_attr("$id_prefix-cc-number") ?>" class="form-control form-control-sm"> |
|
| 503 | 503 | </div> |
| 504 | 504 | </div> |
| 505 | 505 | |
@@ -507,17 +507,17 @@ discard block |
||
| 507 | 507 | |
| 508 | 508 | <div class="col-12"> |
| 509 | 509 | <div class="form-group"> |
| 510 | - <label><?php _e( 'Expiration', 'invoicing' ); ?></label> |
|
| 510 | + <label><?php _e('Expiration', 'invoicing'); ?></label> |
|
| 511 | 511 | <div class="form-row"> |
| 512 | 512 | |
| 513 | 513 | <div class="col"> |
| 514 | - <select class="form-control form-control-sm" name="<?php echo esc_attr( $this->id );?>[cc_expire_month]"> |
|
| 515 | - <option disabled selected="selected"><?php _e( 'MM', 'invoicing' ); ?></option> |
|
| 514 | + <select class="form-control form-control-sm" name="<?php echo esc_attr($this->id); ?>[cc_expire_month]"> |
|
| 515 | + <option disabled selected="selected"><?php _e('MM', 'invoicing'); ?></option> |
|
| 516 | 516 | |
| 517 | 517 | <?php |
| 518 | - foreach ( $months as $key => $month ) { |
|
| 519 | - $key = esc_attr( $key ); |
|
| 520 | - $month = wpinv_clean( $month ); |
|
| 518 | + foreach ($months as $key => $month) { |
|
| 519 | + $key = esc_attr($key); |
|
| 520 | + $month = wpinv_clean($month); |
|
| 521 | 521 | echo "<option value='$key'>$month</option>" . PHP_EOL; |
| 522 | 522 | } |
| 523 | 523 | ?> |
@@ -526,13 +526,13 @@ discard block |
||
| 526 | 526 | </div> |
| 527 | 527 | |
| 528 | 528 | <div class="col"> |
| 529 | - <select class="form-control form-control-sm" name="<?php echo esc_attr( $this->id );?>[cc_expire_year]"> |
|
| 530 | - <option disabled selected="selected"><?php _e( 'YY', 'invoicing' ); ?></option> |
|
| 529 | + <select class="form-control form-control-sm" name="<?php echo esc_attr($this->id); ?>[cc_expire_year]"> |
|
| 530 | + <option disabled selected="selected"><?php _e('YY', 'invoicing'); ?></option> |
|
| 531 | 531 | |
| 532 | 532 | <?php |
| 533 | - foreach ( $years as $key => $year ) { |
|
| 534 | - $key = esc_attr( $key ); |
|
| 535 | - $year = wpinv_clean( $year ); |
|
| 533 | + foreach ($years as $key => $year) { |
|
| 534 | + $key = esc_attr($key); |
|
| 535 | + $year = wpinv_clean($year); |
|
| 536 | 536 | echo "<option value='$key'>$year</option>" . PHP_EOL; |
| 537 | 537 | } |
| 538 | 538 | ?> |
@@ -550,7 +550,7 @@ discard block |
||
| 550 | 550 | array( |
| 551 | 551 | 'name' => $this->id . '[cc_cvv2]', |
| 552 | 552 | 'id' => "$id_prefix-cc-cvv2", |
| 553 | - 'label' => __( 'CCV', 'invoicing' ), |
|
| 553 | + 'label' => __('CCV', 'invoicing'), |
|
| 554 | 554 | 'label_type' => 'vertical', |
| 555 | 555 | 'class' => 'form-control-sm', |
| 556 | 556 | ) |
@@ -562,7 +562,7 @@ discard block |
||
| 562 | 562 | |
| 563 | 563 | <?php |
| 564 | 564 | |
| 565 | - if ( $save ) { |
|
| 565 | + if ($save) { |
|
| 566 | 566 | echo $this->save_payment_method_checkbox(); |
| 567 | 567 | } |
| 568 | 568 | |
@@ -581,7 +581,7 @@ discard block |
||
| 581 | 581 | * |
| 582 | 582 | * @since 1.0.19 |
| 583 | 583 | */ |
| 584 | - public function new_payment_method_entry( $form ) { |
|
| 584 | + public function new_payment_method_entry($form) { |
|
| 585 | 585 | echo "<div class='getpaid-new-payment-method-form' style='display:none;'>$form</div>"; |
| 586 | 586 | } |
| 587 | 587 | |
@@ -591,16 +591,16 @@ discard block |
||
| 591 | 591 | * @since 1.0.19 |
| 592 | 592 | */ |
| 593 | 593 | public function saved_payment_methods() { |
| 594 | - $html = '<ul class="getpaid-saved-payment-methods m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">'; |
|
| 594 | + $html = '<ul class="getpaid-saved-payment-methods m-0 mt-2" data-count="' . esc_attr(count($this->get_tokens($this->is_sandbox()))) . '">'; |
|
| 595 | 595 | |
| 596 | - foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) { |
|
| 597 | - $html .= $this->get_saved_payment_method_option_html( $token ); |
|
| 596 | + foreach ($this->get_tokens($this->is_sandbox()) as $token) { |
|
| 597 | + $html .= $this->get_saved_payment_method_option_html($token); |
|
| 598 | 598 | } |
| 599 | 599 | |
| 600 | 600 | $html .= $this->get_new_payment_method_option_html(); |
| 601 | 601 | $html .= '</ul>'; |
| 602 | 602 | |
| 603 | - echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this ); |
|
| 603 | + echo apply_filters('getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this); |
|
| 604 | 604 | } |
| 605 | 605 | |
| 606 | 606 | /** |
@@ -610,7 +610,7 @@ discard block |
||
| 610 | 610 | * @param array $token Payment Token. |
| 611 | 611 | * @return string Generated payment method HTML |
| 612 | 612 | */ |
| 613 | - public function get_saved_payment_method_option_html( $token ) { |
|
| 613 | + public function get_saved_payment_method_option_html($token) { |
|
| 614 | 614 | |
| 615 | 615 | return sprintf( |
| 616 | 616 | '<li class="getpaid-payment-method form-group"> |
@@ -619,10 +619,10 @@ discard block |
||
| 619 | 619 | <span>%3$s</span> |
| 620 | 620 | </label> |
| 621 | 621 | </li>', |
| 622 | - esc_attr( $this->id ), |
|
| 623 | - esc_attr( $token['id'] ), |
|
| 624 | - esc_html( $token['name'] ), |
|
| 625 | - checked( empty( $token['default'] ), false, false ) |
|
| 622 | + esc_attr($this->id), |
|
| 623 | + esc_attr($token['id']), |
|
| 624 | + esc_html($token['name']), |
|
| 625 | + checked(empty($token['default']), false, false) |
|
| 626 | 626 | ); |
| 627 | 627 | |
| 628 | 628 | } |
@@ -634,7 +634,7 @@ discard block |
||
| 634 | 634 | */ |
| 635 | 635 | public function get_new_payment_method_option_html() { |
| 636 | 636 | |
| 637 | - $label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this ); |
|
| 637 | + $label = apply_filters('getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __('Use a new payment method', 'invoicing'), $this); |
|
| 638 | 638 | |
| 639 | 639 | return sprintf( |
| 640 | 640 | '<li class="getpaid-new-payment-method"> |
@@ -643,8 +643,8 @@ discard block |
||
| 643 | 643 | <span>%2$s</span> |
| 644 | 644 | </label> |
| 645 | 645 | </li>', |
| 646 | - esc_attr( $this->id ), |
|
| 647 | - esc_html( $label ) |
|
| 646 | + esc_attr($this->id), |
|
| 647 | + esc_html($label) |
|
| 648 | 648 | ); |
| 649 | 649 | |
| 650 | 650 | } |
@@ -663,8 +663,8 @@ discard block |
||
| 663 | 663 | <span>%2$s</span> |
| 664 | 664 | </label> |
| 665 | 665 | </p>', |
| 666 | - esc_attr( $this->id ), |
|
| 667 | - esc_html__( 'Save payment method', 'invoicing' ) |
|
| 666 | + esc_attr($this->id), |
|
| 667 | + esc_html__('Save payment method', 'invoicing') |
|
| 668 | 668 | ); |
| 669 | 669 | |
| 670 | 670 | } |
@@ -674,9 +674,9 @@ discard block |
||
| 674 | 674 | * |
| 675 | 675 | * @return array |
| 676 | 676 | */ |
| 677 | - public function register_gateway( $gateways ) { |
|
| 677 | + public function register_gateway($gateways) { |
|
| 678 | 678 | |
| 679 | - $gateways[ $this->id ] = array( |
|
| 679 | + $gateways[$this->id] = array( |
|
| 680 | 680 | |
| 681 | 681 | 'admin_label' => $this->method_title, |
| 682 | 682 | 'checkout_label' => $this->title, |
@@ -694,13 +694,13 @@ discard block |
||
| 694 | 694 | * @param WPInv_Invoice|null $invoice Invoice object or null. |
| 695 | 695 | * @return bool |
| 696 | 696 | */ |
| 697 | - public function is_sandbox( $invoice = null ) { |
|
| 697 | + public function is_sandbox($invoice = null) { |
|
| 698 | 698 | |
| 699 | - if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) { |
|
| 699 | + if (!empty($invoice) && !$invoice->needs_payment()) { |
|
| 700 | 700 | return $invoice->get_mode() == 'test'; |
| 701 | 701 | } |
| 702 | 702 | |
| 703 | - return wpinv_is_test_mode( $this->id ); |
|
| 703 | + return wpinv_is_test_mode($this->id); |
|
| 704 | 704 | |
| 705 | 705 | } |
| 706 | 706 | |
@@ -718,15 +718,15 @@ discard block |
||
| 718 | 718 | * |
| 719 | 719 | * @return bool |
| 720 | 720 | */ |
| 721 | - public function validate_currency( $validation, $currency ) { |
|
| 721 | + public function validate_currency($validation, $currency) { |
|
| 722 | 722 | |
| 723 | 723 | // Required currencies. |
| 724 | - if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) { |
|
| 724 | + if (!empty($this->currencies) && !in_array($currency, $this->currencies)) { |
|
| 725 | 725 | return false; |
| 726 | 726 | } |
| 727 | 727 | |
| 728 | 728 | // Excluded currencies. |
| 729 | - if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) { |
|
| 729 | + if (!empty($this->exclude_currencies) && in_array($currency, $this->exclude_currencies)) { |
|
| 730 | 730 | return false; |
| 731 | 731 | } |
| 732 | 732 | |
@@ -8,18 +8,18 @@ |
||
| 8 | 8 | * @var WPInv_Subscription $object |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -defined( 'ABSPATH' ) || exit; |
|
| 11 | +defined('ABSPATH') || exit; |
|
| 12 | 12 | |
| 13 | 13 | $invoice = $object->get_parent_payment(); |
| 14 | 14 | |
| 15 | 15 | // Print the email header. |
| 16 | -do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
|
| 16 | +do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin); |
|
| 17 | 17 | |
| 18 | 18 | // Generate the custom message body. |
| 19 | 19 | echo $message_body; |
| 20 | 20 | |
| 21 | 21 | // Print the billing details. |
| 22 | -do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin ); |
|
| 22 | +do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin); |
|
| 23 | 23 | |
| 24 | 24 | // Print the email footer. |
| 25 | -do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin ); |
|
| 25 | +do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin); |
|
@@ -8,24 +8,24 @@ |
||
| 8 | 8 | * @var WPInv_Subscription $object |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -defined( 'ABSPATH' ) || exit; |
|
| 11 | +defined('ABSPATH') || exit; |
|
| 12 | 12 | |
| 13 | 13 | $invoice = $object->get_parent_payment(); |
| 14 | 14 | |
| 15 | 15 | // Print the email header. |
| 16 | -do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
|
| 16 | +do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin); |
|
| 17 | 17 | |
| 18 | 18 | // Generate the custom message body. |
| 19 | 19 | echo $message_body; |
| 20 | 20 | |
| 21 | 21 | // Print invoice details. |
| 22 | -do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin ); |
|
| 22 | +do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin); |
|
| 23 | 23 | |
| 24 | 24 | // Print invoice items. |
| 25 | -do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin ); |
|
| 25 | +do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin); |
|
| 26 | 26 | |
| 27 | 27 | // Print the billing details. |
| 28 | -do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin ); |
|
| 28 | +do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin); |
|
| 29 | 29 | |
| 30 | 30 | // Print the email footer. |
| 31 | -do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin ); |
|
| 31 | +do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin); |
|