Simplify commerce hosted payments feature

This commit is contained in:
Claudio Sanches 2015-01-13 13:40:43 -02:00
commit 22da603567
3 changed files with 349 additions and 58 deletions

View File

@ -444,6 +444,52 @@ abstract class WC_Settings_API {
return $this->generate_text_html( $key, $data );
}
/**
* Generate Color Picker Input HTML.
*
* @param mixed $key
* @param mixed $data
* @since 2.3.0
* @return string
*/
public function generate_color_html( $key, $data ) {
$field = $this->plugin_id . $this->id . '_' . $key;
$defaults = array(
'title' => '',
'disabled' => false,
'class' => '',
'css' => '',
'placeholder' => '',
'desc_tip' => false,
'description' => '',
'custom_attributes' => array()
);
$data = wp_parse_args( $data, $defaults );
ob_start();
?>
<tr valign="top">
<th scope="row" class="titledesc">
<label for="<?php echo esc_attr( $field ); ?>"><?php echo wp_kses_post( $data['title'] ); ?></label>
<?php echo $this->get_tooltip_html( $data ); ?>
</th>
<td class="forminp">
<fieldset>
<legend class="screen-reader-text"><span><?php echo wp_kses_post( $data['title'] ); ?></span></legend>
<div class="color_box">
<input class="colorpick <?php echo esc_attr( $data['class'] ); ?>" type="text" name="<?php echo esc_attr( $field ); ?>" id="<?php echo esc_attr( $field ); ?>" style="<?php echo esc_attr( $data['css'] ); ?>" value="<?php echo esc_attr( $this->get_option( $key ) ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ); ?>" <?php disabled( $data['disabled'], true ); ?> <?php echo $this->get_custom_attribute_html( $data ); ?> />
<div id="colorPickerDiv_<?php echo esc_attr( $field ); ?>" class="colorpickdiv" style="z-index: 100; background: #eee; border: 1px solid #ccc; position: absolute; display: none;"></div>
</div>
<?php echo $this->get_description_html( $data ); ?>
</fieldset>
</td>
</tr>
<?php
return ob_get_clean();
}
/**
* Generate Textarea HTML.
*

View File

@ -31,20 +31,62 @@ class WC_Addons_Gateway_Simplify_Commerce extends WC_Gateway_Simplify_Commerce {
if ( class_exists( 'WC_Pre_Orders_Order' ) ) {
add_action( 'wc_pre_orders_process_pre_order_completion_payment_' . $this->id, array( $this, 'process_pre_order_release_payment' ) );
}
add_filter( 'woocommerce_simplify_commerce_hosted_args', array( $this, 'hosted_payment_args' ), 10, 2 );
add_action( 'woocommerce_api_wc_addons_gateway_simplify_commerce', array( $this, 'return_handler' ) );
}
/**
* Hosted payment args
*
* @param array $args
* @param int $order_id
*
* @return array
*/
public function hosted_payment_args( $args, $order_id ) {
if ( ( $this->order_contains_subscription( $order_id ) ) || ( $this->order_contains_pre_order( $order_id ) && WC_Pre_Orders_Order::order_requires_payment_tokenization( $order_id ) ) ) {
$args['operation'] = 'create.token';
}
$args['redirect-url'] = WC()->api_request_url( 'WC_Addons_Gateway_Simplify_Commerce' );
return $args;
}
/**
* Check if order contains subscriptions.
*
* @param int $order_id
*
* @return bool
*/
protected function order_contains_subscription( $order_id ) {
return class_exists( 'WC_Subscriptions_Order' ) && WC_Subscriptions_Order::order_contains_subscription( $order_id );
}
/**
* Check if order contains pre-orders.
*
* @param int $order_id
*
* @return bool
*/
protected function order_contains_pre_order( $order_id ) {
return class_exists( 'WC_Pre_Orders_Order' ) && WC_Pre_Orders_Order::order_contains_pre_order( $order_id );
}
/**
* Process the subscription
*
* @param int $order_id
* @param WC_Order $order
* @param string $cart_token
*
* @return array
*/
public function process_subscription( $order_id ) {
$order = wc_get_order( $order_id );
$token = isset( $_POST['simplify_token'] ) ? wc_clean( $_POST['simplify_token'] ) : '';
protected function process_subscription( $order, $cart_token = '' ) {
try {
if ( empty( $token ) ) {
if ( empty( $cart_token ) ) {
$error_msg = __( 'Please make sure your card details have been entered correctly and that your browser supports JavaScript.', 'woocommerce' );
if ( 'yes' == $this->sandbox ) {
@ -56,7 +98,7 @@ class WC_Addons_Gateway_Simplify_Commerce extends WC_Gateway_Simplify_Commerce {
// Create customer
$customer = Simplify_Customer::createCustomer( array(
'token' => $token,
'token' => $cart_token,
'email' => $order->billing_email,
'name' => trim( $order->billing_first_name . ' ' . $order->billing_last_name ),
'reference' => $order->id
@ -66,7 +108,7 @@ class WC_Addons_Gateway_Simplify_Commerce extends WC_Gateway_Simplify_Commerce {
$customer_id = wc_clean( $customer->id );
// Store the customer ID in the order
update_post_meta( $order_id, '_simplify_customer_id', $customer_id );
update_post_meta( $order->id, '_simplify_customer_id', $customer_id );
} else {
$error_msg = __( 'Error creating user in Simplify Commerce.', 'woocommerce' );
@ -113,13 +155,13 @@ class WC_Addons_Gateway_Simplify_Commerce extends WC_Gateway_Simplify_Commerce {
/**
* Process the pre-order
*
* @param int $order_id
* @param WC_Order $order
* @param string $cart_token
*
* @return array
*/
public function process_pre_order( $order_id ) {
if ( WC_Pre_Orders_Order::order_requires_payment_tokenization( $order_id ) ) {
$order = wc_get_order( $order_id );
$token = isset( $_POST['simplify_token'] ) ? wc_clean( $_POST['simplify_token'] ) : '';
protected function process_pre_order( $order, $cart_token = '' ) {
if ( WC_Pre_Orders_Order::order_requires_payment_tokenization( $order->id ) ) {
try {
if ( $order->order_total * 100 < 50 ) {
@ -128,7 +170,7 @@ class WC_Addons_Gateway_Simplify_Commerce extends WC_Gateway_Simplify_Commerce {
throw new Simplify_ApiException( $error_msg );
}
if ( empty( $token ) ) {
if ( empty( $cart_token ) ) {
$error_msg = __( 'Please make sure your card details have been entered correctly and that your browser supports JavaScript.', 'woocommerce' );
if ( 'yes' == $this->sandbox ) {
@ -140,7 +182,7 @@ class WC_Addons_Gateway_Simplify_Commerce extends WC_Gateway_Simplify_Commerce {
// Create customer
$customer = Simplify_Customer::createCustomer( array(
'token' => $token,
'token' => $cart_token,
'email' => $order->billing_email,
'name' => trim( $order->billing_first_name . ' ' . $order->billing_last_name ),
'reference' => $order->id
@ -150,7 +192,7 @@ class WC_Addons_Gateway_Simplify_Commerce extends WC_Gateway_Simplify_Commerce {
$customer_id = wc_clean( $customer->id );
// Store the customer ID in the order
update_post_meta( $order_id, '_simplify_customer_id', $customer_id );
update_post_meta( $order->id, '_simplify_customer_id', $customer_id );
} else {
$error_msg = __( 'Error creating user in Simplify Commerce.', 'woocommerce' );
@ -188,7 +230,7 @@ class WC_Addons_Gateway_Simplify_Commerce extends WC_Gateway_Simplify_Commerce {
}
} else {
return parent::process_payment( $order_id );
return parent::process_standard_payments( $order, $cart_token );
}
}
@ -199,13 +241,16 @@ class WC_Addons_Gateway_Simplify_Commerce extends WC_Gateway_Simplify_Commerce {
* @return array
*/
public function process_payment( $order_id ) {
$cart_token = isset( $_POST['simplify_token'] ) ? wc_clean( $_POST['simplify_token'] ) : '';
$order = wc_get_order( $order_id );
// Processing subscription
if ( class_exists( 'WC_Subscriptions_Order' ) && WC_Subscriptions_Order::order_contains_subscription( $order_id ) ) {
return $this->process_subscription( $order_id );
if ( 'standard' == $this->mode && $this->order_contains_subscription( $order->id ) ) {
return $this->process_subscription( $order, $cart_token );
// Processing pre-order
} elseif ( class_exists( 'WC_Pre_Orders_Order' ) && WC_Pre_Orders_Order::order_contains_pre_order( $order_id ) ) {
return $this->process_pre_order( $order_id );
} elseif ( 'standard' == $this->mode && $this->order_contains_pre_order( $order->id ) ) {
return $this->process_pre_order( $order, $cart_token );
// Processing regular product
} else {
@ -370,4 +415,48 @@ class WC_Addons_Gateway_Simplify_Commerce extends WC_Gateway_Simplify_Commerce {
}
}
}
/**
* Return handler for Hosted Payments
*/
public function return_handler() {
if ( ! isset( $_REQUEST['cardToken'] ) ) {
parent::return_handler();
}
@ob_clean();
header( 'HTTP/1.1 200 OK' );
$redirect_url = get_permalink( wc_get_page_id( 'cart' ) );
if ( isset( $_REQUEST['reference'] ) && isset( $_REQUEST['amount'] ) ) {
$cart_token = $_REQUEST['cardToken'];
$amount = absint( $_REQUEST['amount'] );
$order_id = absint( $_REQUEST['reference'] );
$order = wc_get_order( $order_id );
$order_total = absint( $order->order_total * 100 );
if ( $amount === $order_total ) {
if ( $this->order_contains_subscription( $order->id ) ) {
$response = $this->process_subscription( $order, $cart_token );
} elseif ( $this->order_contains_pre_order( $order->id ) ) {
$response = $this->process_pre_order( $order, $cart_token );
} else {
$response = parent::process_standard_payments( $order, $cart_token );
}
if ( 'success' == $response['result'] ) {
$redirect_url = $response['redirect'];
} else {
$order->update_status( 'failed', __( 'Payment was declined by Simplify Commerce.', 'woocommerce' ) );
}
wp_redirect( $redirect_url );
exit();
}
}
wp_redirect( $redirect_url );
exit();
}
}

View File

@ -46,12 +46,14 @@ class WC_Gateway_Simplify_Commerce extends WC_Payment_Gateway {
$this->init_settings();
// Get setting values
$this->title = $this->get_option( 'title' );
$this->description = $this->get_option( 'description' );
$this->enabled = $this->get_option( 'enabled' );
$this->sandbox = $this->get_option( 'sandbox' );
$this->private_key = $this->sandbox == 'no' ? $this->get_option( 'private_key' ) : $this->get_option( 'sandbox_private_key' );
$this->public_key = $this->sandbox == 'no' ? $this->get_option( 'public_key' ) : $this->get_option( 'sandbox_public_key' );
$this->title = $this->get_option( 'title' );
$this->description = $this->get_option( 'description' );
$this->enabled = $this->get_option( 'enabled' );
$this->mode = $this->get_option( 'mode', 'standard' );
$this->modal_color = $this->get_option( 'modal_color', '#a46497' );
$this->sandbox = $this->get_option( 'sandbox' );
$this->public_key = $this->sandbox == 'no' ? $this->get_option( 'public_key' ) : $this->get_option( 'sandbox_public_key' );
$this->private_key = $this->sandbox == 'no' ? $this->get_option( 'private_key' ) : $this->get_option( 'sandbox_private_key' );
$this->init_simplify_sdk();
@ -59,6 +61,8 @@ class WC_Gateway_Simplify_Commerce extends WC_Payment_Gateway {
add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) );
add_action( 'admin_notices', array( $this, 'checks' ) );
add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
add_action( 'woocommerce_receipt_' . $this->id, array( $this, 'receipt_page' ) );
add_action( 'woocommerce_api_wc_gateway_simplify_commerce', array( $this, 'return_handler' ) );
}
/**
@ -82,7 +86,7 @@ class WC_Gateway_Simplify_Commerce extends WC_Payment_Gateway {
* @access public
* @return void
*/
public function admin_options() {
public function admin_options() {
?>
<h3><?php _e( 'Simplify Commerce by Mastercard', 'woocommerce' ); ?></h3>
@ -102,7 +106,7 @@ class WC_Gateway_Simplify_Commerce extends WC_Payment_Gateway {
<table class="form-table">
<?php $this->generate_settings_html(); ?>
<script type="text/javascript">
jQuery( '#woocommerce_simplify_commerce_sandbox' ).change( function () {
jQuery( '#woocommerce_simplify_commerce_sandbox' ).on( 'change', function() {
var sandbox = jQuery( '#woocommerce_simplify_commerce_sandbox_public_key, #woocommerce_simplify_commerce_sandbox_private_key' ).closest( 'tr' ),
production = jQuery( '#woocommerce_simplify_commerce_public_key, #woocommerce_simplify_commerce_private_key' ).closest( 'tr' );
@ -114,16 +118,26 @@ class WC_Gateway_Simplify_Commerce extends WC_Payment_Gateway {
production.show();
}
}).change();
jQuery( '#woocommerce_simplify_commerce_mode' ).on( 'change', function() {
var color = jQuery( '#woocommerce_simplify_commerce_modal_color' ).closest( 'tr' );
if ( 'standard' == jQuery( this ).val() ) {
color.hide();
} else {
color.show();
}
}).change();
</script>
</table>
<?php
}
}
/**
* Check if SSL is enabled and notify the user
*/
public function checks() {
if ( $this->enabled == 'no' ) {
if ( 'no' == $this->enabled ) {
return;
}
@ -137,8 +151,8 @@ class WC_Gateway_Simplify_Commerce extends WC_Payment_Gateway {
echo '<div class="error"><p>' . __( 'Simplify Commerce Error: Please enter your public and private keys', 'woocommerce' ) . '</p></div>';
}
// Show message if enabled and FORCE SSL is disabled and WordpressHTTPS plugin is not detected
elseif ( 'no' == get_option( 'woocommerce_force_ssl_checkout' ) && ! class_exists( 'WordPressHTTPS' ) ) {
// Show message when using standard mode and no SSL on the checkout page
elseif ( 'standard' == $this->mode && 'no' == get_option( 'woocommerce_force_ssl_checkout' ) && ! class_exists( 'WordPressHTTPS' ) ) {
echo '<div class="error"><p>' . sprintf( __( 'Simplify Commerce is enabled, but the <a href="%s">force SSL option</a> is disabled; your checkout may not be secure! Please enable SSL and ensure your server has a valid SSL certificate - Simplify Commerce will only work in sandbox mode.', 'woocommerce'), admin_url( 'admin.php?page=wc-settings&tab=checkout' ) ) . '</p></div>';
}
}
@ -151,7 +165,7 @@ class WC_Gateway_Simplify_Commerce extends WC_Payment_Gateway {
return false;
}
if ( ! is_ssl() && 'yes' != $this->sandbox ) {
if ( 'standard' == $this->mode && ! is_ssl() && 'yes' != $this->sandbox ) {
return false;
}
@ -188,6 +202,24 @@ class WC_Gateway_Simplify_Commerce extends WC_Payment_Gateway {
'default' => 'Pay with your credit card via Simplify Commerce by Mastercard.',
'desc_tip' => true
),
'mode' => array(
'title' => __( 'Payment Mode', 'woocommerce' ),
'label' => __( 'Enable Hosted Payments', 'woocommerce' ),
'type' => 'select',
'description' => sprintf( __( 'Standard will display the credit card fields on your store (SSL required). %1$s Hosted Payments will display a Simplify Commerce modal dialog on your store (if SSL) or will redirect the customer to Simplify Commerce hosted page (if not SSL). %1$s Note: Hosted Payments need a new API Key pair with the hosted payments flag selected. %2$sFor more details check the Simplify Commerce docs%3$s.', 'woocommerce' ), '<br />', '<a href="https://simplify.desk.com/customer/portal/articles/1792405-how-do-i-enable-hosted-payments" target="_blank">', '</a>' ),
'default' => 'hosted',
'options' => array(
'standard' => __( 'Standard', 'woocommerce' ),
'hosted' => __( 'Hosted Payments', 'woocommerce' )
)
),
'modal_color' => array(
'title' => __( 'Modal Color', 'woocommerce' ),
'type' => 'color',
'description' => __( 'Set the color of the buttons and titles on the modal dialog.', 'woocommerce' ),
'default' => '#a46497',
'desc_tip' => true
),
'sandbox' => array(
'title' => __( 'Sandbox', 'woocommerce' ),
'label' => __( 'Enable Sandbox Mode', 'woocommerce' ),
@ -240,7 +272,9 @@ class WC_Gateway_Simplify_Commerce extends WC_Payment_Gateway {
echo wpautop( wptexturize( trim( $description ) ) );
}
$this->credit_card_form( array( 'fields_have_names' => false ) );
if ( 'standard' == $this->mode ) {
$this->credit_card_form( array( 'fields_have_names' => false ) );
}
}
/**
@ -262,21 +296,24 @@ class WC_Gateway_Simplify_Commerce extends WC_Payment_Gateway {
'card.number' => __( 'Card Number', 'woocommerce' ),
'card.expMonth' => __( 'Expiry Month', 'woocommerce' ),
'card.expYear' => __( 'Expiry Year', 'woocommerce' ),
'is_invalid' => __( 'is invalid', 'woocommerce' )
'is_invalid' => __( 'is invalid', 'woocommerce' ),
'mode' => $this->mode,
'is_ssl' => is_ssl()
) );
}
/**
* Process the payment
* @param integer $order_id
* Process standard payments
*
* @param WC_Order $order
* @param string $cart_token
*
* @return array
*/
public function process_payment( $order_id ) {
$order = wc_get_order( $order_id );
$token = isset( $_POST['simplify_token'] ) ? wc_clean( $_POST['simplify_token'] ) : '';
protected function process_standard_payments( $order, $cart_token = '' ) {
try {
if ( empty( $token ) ) {
if ( empty( $cart_token ) ) {
$error_msg = __( 'Please make sure your card details have been entered correctly and that your browser supports JavaScript.', 'woocommerce' );
if ( 'yes' == $this->sandbox ) {
@ -288,7 +325,7 @@ class WC_Gateway_Simplify_Commerce extends WC_Payment_Gateway {
$payment = Simplify_Payment::createPayment( array(
'amount' => $order->order_total * 100, // In cents
'token' => $token,
'token' => $cart_token,
'description' => sprintf( __( '%s - Order #%s', 'woocommerce' ), esc_html( get_bloginfo( 'name' ) ), $order->get_order_number() ),
'currency' => strtoupper( get_woocommerce_currency() ),
'reference' => $order->id,
@ -300,16 +337,9 @@ class WC_Gateway_Simplify_Commerce extends WC_Payment_Gateway {
'card.addressZip' => $order->billing_postcode
) );
if ( 'APPROVED' == $payment->paymentStatus ) {
// Payment complete
$order->payment_complete( $payment->id );
// Add order note
$order->add_order_note( sprintf( __( 'Simplify payment approved (ID: %s, Auth Code: %s)', 'woocommerce' ), $payment->id, $payment->authCode ) );
// Remove cart
WC()->cart->empty_cart();
$order_complete = $this->process_order_status( $order, $payment->id, $payment->paymentStatus, $payment->authCode );
if ( $order_complete ) {
// Return thank you page redirect
return array(
'result' => 'success',
@ -337,6 +367,132 @@ class WC_Gateway_Simplify_Commerce extends WC_Payment_Gateway {
}
}
/**
* Process standard payments
*
* @return array
*/
protected function process_hosted_payments( $order ) {
return array(
'result' => 'success',
'redirect' => $order->get_checkout_payment_url( true )
);
}
/**
* Process the payment
*
* @param integer $order_id
*/
public function process_payment( $order_id ) {
$cart_token = isset( $_POST['simplify_token'] ) ? wc_clean( $_POST['simplify_token'] ) : '';
$order = wc_get_order( $order_id );
if ( 'hosted' == $this->mode ) {
return $this->process_hosted_payments( $order );
} else {
return $this->process_standard_payments( $order, $cart_token );
}
}
/**
* Hosted payment args.
*
* @param WC_Order $order
*
* @return array
*/
protected function get_hosted_payments_args( $order ) {
$args = apply_filters( 'woocommerce_simplify_commerce_hosted_args', array(
'sc-key' => $this->public_key,
'amount' => $order->order_total * 100,
'reference' => $order->id,
'name' => esc_html( get_bloginfo( 'name' ) ),
'description' => sprintf( __( 'Order #%s', 'woocommerce' ), $order->get_order_number() ),
'receipt' => 'false',
'color' => $this->modal_color,
'redirect-url' => WC()->api_request_url( 'WC_Gateway_Simplify_Commerce' )
), $order->id );
return $args;
}
/**
* Receipt page
*
* @param int $order_id
*/
public function receipt_page( $order_id ) {
$order = wc_get_order( $order_id );
echo '<p>' . __( 'Thank you for your order, please click the button below to pay with credit card using Simplify Commerce by MasterCard.', 'woocommerce' ) . '</p>';
$args = $this->get_hosted_payments_args( $order );
$button_args = array();
foreach ( $args as $key => $value ) {
$button_args[] = 'data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
}
echo '<script type="text/javascript" src="https://www.simplify.com/commerce/simplify.pay.js"></script>
<button class="button alt" id="simplify-payment-button" ' . implode( ' ', $button_args ) . '>' . __( 'Pay Now', 'woocommerce' ) . '</button> <a class="button cancel" href="' . esc_url( $order->get_cancel_order_url() ) . '">' . __( 'Cancel order &amp; restore cart', 'woocommerce' ) . '</a>
';
}
/**
* Return handler for Hosted Payments
*/
public function return_handler() {
@ob_clean();
header( 'HTTP/1.1 200 OK' );
if ( isset( $_REQUEST['reference'] ) && isset( $_REQUEST['paymentId'] ) && isset( $_REQUEST['signature'] ) ) {
$signature = strtoupper( md5( $_REQUEST['amount'] . $_REQUEST['reference'] . $_REQUEST['paymentId'] . $_REQUEST['paymentDate'] . $_REQUEST['paymentStatus'] . $this->private_key ) );
$order_id = absint( $_REQUEST['reference'] );
$order = wc_get_order( $order_id );
if ( $signature === $_REQUEST['signature'] ) {
$order_complete = $this->process_order_status( $order, $_REQUEST['paymentId'], $_REQUEST['paymentStatus'], $_REQUEST['paymentDate'] );
if ( ! $order_complete ) {
$order->update_status( 'failed', __( 'Payment was declined by Simplify Commerce.', 'woocommerce' ) );
}
wp_redirect( $this->get_return_url( $order ) );
exit();
}
}
wp_redirect( get_permalink( wc_get_page_id( 'cart' ) ) );
exit();
}
/**
* Process the order status
*
* @param WC_Order $order
* @param string $payment_id
* @param string $status
* @param string $auth_code
*
* @return bool
*/
public function process_order_status( $order, $payment_id, $status, $auth_code ) {
if ( 'APPROVED' == $status ) {
// Payment complete
$order->payment_complete( $payment_id );
// Add order note
$order->add_order_note( sprintf( __( 'Simplify payment approved (ID: %s, Auth Code: %s)', 'woocommerce' ), $payment_id, $auth_code ) );
// Remove cart
WC()->cart->empty_cart();
return true;
}
return false;
}
/**
* Process refunds
* WooCommerce 2.2 or later
@ -383,11 +539,11 @@ class WC_Gateway_Simplify_Commerce extends WC_Payment_Gateway {
* @return string
*/
public function get_icon() {
$icon = '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/visa.png' ) . '" alt="Visa" />';
$icon .= '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/mastercard.png' ) . '" alt="Mastercard" />';
$icon .= '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/discover.png' ) . '" alt="Discover" />';
$icon .= '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/amex.png' ) . '" alt="Amex" />';
$icon .= '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/jcb.png' ) . '" alt="JCB" />';
$icon = '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/visa.png' ) . '" alt="Visa" />';
$icon .= '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/mastercard.png' ) . '" alt="Mastercard" />';
$icon .= '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/discover.png' ) . '" alt="Discover" />';
$icon .= '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/amex.png' ) . '" alt="Amex" />';
$icon .= '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/jcb.png' ) . '" alt="JCB" />';
return apply_filters( 'woocommerce_gateway_icon', $icon, $this->id );
}