@@ 316-334 (lines=19) @@ | ||
313 | * @param array $payment_meta associative array of meta data required for automatic payments |
|
314 | * @return array |
|
315 | */ |
|
316 | public function validate_subscription_payment_meta( $payment_method_id, $payment_meta ) { |
|
317 | if ( $this->id === $payment_method_id ) { |
|
318 | ||
319 | if ( ! isset( $payment_meta['post_meta']['_stripe_customer_id']['value'] ) || empty( $payment_meta['post_meta']['_stripe_customer_id']['value'] ) ) { |
|
320 | throw new Exception( __( 'A "Stripe Customer ID" value is required.', 'woocommerce-gateway-stripe' ) ); |
|
321 | } elseif ( 0 !== strpos( $payment_meta['post_meta']['_stripe_customer_id']['value'], 'cus_' ) ) { |
|
322 | throw new Exception( __( 'Invalid customer ID. A valid "Stripe Customer ID" must begin with "cus_".', 'woocommerce-gateway-stripe' ) ); |
|
323 | } |
|
324 | ||
325 | if ( |
|
326 | ( ! empty( $payment_meta['post_meta']['_stripe_source_id']['value'] ) |
|
327 | && 0 !== strpos( $payment_meta['post_meta']['_stripe_source_id']['value'], 'card_' ) ) |
|
328 | && ( ! empty( $payment_meta['post_meta']['_stripe_source_id']['value'] ) |
|
329 | && 0 !== strpos( $payment_meta['post_meta']['_stripe_source_id']['value'], 'src_' ) ) ) { |
|
330 | ||
331 | throw new Exception( __( 'Invalid source ID. A valid source "Stripe Source ID" must begin with "src_" or "card_".', 'woocommerce-gateway-stripe' ) ); |
|
332 | } |
|
333 | } |
|
334 | } |
|
335 | ||
336 | /** |
|
337 | * Render the payment method used for a subscription in the "My Subscriptions" table |
@@ 386-404 (lines=19) @@ | ||
383 | * @param array $payment_meta associative array of meta data required for automatic payments |
|
384 | * @return array |
|
385 | */ |
|
386 | public function validate_subscription_payment_meta( $payment_method_id, $payment_meta ) { |
|
387 | if ( $this->id === $payment_method_id ) { |
|
388 | ||
389 | if ( ! isset( $payment_meta['post_meta']['_stripe_customer_id']['value'] ) || empty( $payment_meta['post_meta']['_stripe_customer_id']['value'] ) ) { |
|
390 | throw new Exception( __( 'A "Stripe Customer ID" value is required.', 'woocommerce-gateway-stripe' ) ); |
|
391 | } elseif ( 0 !== strpos( $payment_meta['post_meta']['_stripe_customer_id']['value'], 'cus_' ) ) { |
|
392 | throw new Exception( __( 'Invalid customer ID. A valid "Stripe Customer ID" must begin with "cus_".', 'woocommerce-gateway-stripe' ) ); |
|
393 | } |
|
394 | ||
395 | if ( |
|
396 | ( ! empty( $payment_meta['post_meta']['_stripe_source_id']['value'] ) |
|
397 | && 0 !== strpos( $payment_meta['post_meta']['_stripe_source_id']['value'], 'card_' ) ) |
|
398 | && ( ! empty( $payment_meta['post_meta']['_stripe_source_id']['value'] ) |
|
399 | && 0 !== strpos( $payment_meta['post_meta']['_stripe_source_id']['value'], 'src_' ) ) ) { |
|
400 | ||
401 | throw new Exception( __( 'Invalid source ID. A valid source "Stripe Source ID" must begin with "src_" or "card_".', 'woocommerce-gateway-stripe' ) ); |
|
402 | } |
|
403 | } |
|
404 | } |
|
405 | ||
406 | /** |
|
407 | * Render the payment method used for a subscription in the "My Subscriptions" table |