Code Duplication    Length = 29-29 lines in 2 locations

includes/class-wc-gateway-stripe.php 1 location

@@ 228-256 (lines=29) @@
225
	 *
226
	 * @return float|int
227
	 */
228
	public function get_stripe_amount( $total, $currency = '' ) {
229
		if ( ! $currency ) {
230
			$currency = get_woocommerce_currency();
231
		}
232
		switch ( strtoupper( $currency ) ) {
233
			// Zero decimal currencies.
234
			case 'BIF' :
235
			case 'CLP' :
236
			case 'DJF' :
237
			case 'GNF' :
238
			case 'JPY' :
239
			case 'KMF' :
240
			case 'KRW' :
241
			case 'MGA' :
242
			case 'PYG' :
243
			case 'RWF' :
244
			case 'VND' :
245
			case 'VUV' :
246
			case 'XAF' :
247
			case 'XOF' :
248
			case 'XPF' :
249
				$total = absint( $total );
250
				break;
251
			default :
252
				$total = round( $total, 2 ) * 100; // In cents.
253
				break;
254
		}
255
		return $total;
256
	}
257
258
	/**
259
	 * Initializes Apple Pay process on settings page.

includes/legacy/class-wc-gateway-stripe.php 1 location

@@ 109-137 (lines=29) @@
106
	 * Get Stripe amount to pay
107
	 * @return float
108
	 */
109
	public function get_stripe_amount( $total, $currency = '' ) {
110
		if ( ! $currency ) {
111
			$currency = get_woocommerce_currency();
112
		}
113
		switch ( strtoupper( $currency ) ) {
114
			// Zero decimal currencies
115
			case 'BIF' :
116
			case 'CLP' :
117
			case 'DJF' :
118
			case 'GNF' :
119
			case 'JPY' :
120
			case 'KMF' :
121
			case 'KRW' :
122
			case 'MGA' :
123
			case 'PYG' :
124
			case 'RWF' :
125
			case 'VND' :
126
			case 'VUV' :
127
			case 'XAF' :
128
			case 'XOF' :
129
			case 'XPF' :
130
				$total = absint( $total );
131
				break;
132
			default :
133
				$total = round( $total, 2 ) * 100; // In cents
134
				break;
135
		}
136
		return $total;
137
	}
138
139
	/**
140
	 * Check if SSL is enabled and notify the user