Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TS-65 Add apple pay button style in admin #21

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion assets/frontend/js/globalpayments-applepay.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@

var self = this
var paymentButton = document.createElement( 'div' );
paymentButton.className = 'apple-pay-button apple-pay-button-white-with-line';

paymentButton.className = 'apple-pay-button apple-pay-button-' + this.gatewayOptions.button_color;
paymentButton.title = 'Pay with Apple Pay';
paymentButton.alt = 'Pay with Apple Pay';
paymentButton.id = self.id;
Expand Down
44 changes: 32 additions & 12 deletions src/Gateways/ApplePayGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ class ApplePayGateway extends AbstractGateway {
*/
public $payment_action;

/**
* Button color
*
* @var string
*/
public $button_color;

public function __construct() {
parent::__construct();

Expand All @@ -107,7 +114,8 @@ public function get_frontend_gateway_options() {
'cc_types' => $this->cc_types,
'country_code' => wc_get_base_location()['country'],
'validate_merchant_url' => WC()->api_request_url( 'globalpayments_validate_merchant' ),
'googlepay_gateway_id' => GooglePayGateway::GATEWAY_ID
'googlepay_gateway_id' => GooglePayGateway::GATEWAY_ID,
'button_color' => $this->button_color
);
}

Expand Down Expand Up @@ -163,8 +171,20 @@ public function get_gateway_form_fields() {
'AMEX' => 'AMEX',
'DISCOVER' => 'Discover',
),
'default' => array( 'VISA' , 'MASTERCARD' , 'AMEX' , 'DISCOVER' )
)
'default' => array( 'VISA', 'MASTERCARD', 'AMEX', 'DISCOVER' )
),
'button_color' => array(
'title' => __( 'Apple button color', 'globalpayments-gateway-provider-for-woocommerce' ),
'type' => 'select',
'description' => __( 'Button styling at checkout', 'globalpayments-gateway-provider-for-woocommerce' ),
'default' => 'apple-pay-button-white',
'desc_tip' => true,
'options' => array(
'black' => __( 'Black', 'globalpayments-gateway-provider-for-woocommerce' ),
'white' => __( 'White', 'globalpayments-gateway-provider-for-woocommerce' ),
'white-with-line' => __( 'White with line', 'globalpayments-gateway-provider-for-woocommerce' ),
),
),
);
}

Expand Down Expand Up @@ -211,11 +231,11 @@ public function payment_fields() {
}

public function validate_merchant() {
$responseValidationUrl = json_decode( file_get_contents( 'php://input' ) );
if ( empty($responseValidationUrl) ) {
return null;
}
$validationUrl = $responseValidationUrl->validationUrl;
$responseValidationUrl = json_decode( file_get_contents( 'php://input' ) );
if ( empty( $responseValidationUrl ) ) {
return null;
}
$validationUrl = $responseValidationUrl->validationUrl;

if (
! $this->apple_merchant_id ||
Expand All @@ -226,8 +246,8 @@ public function validate_merchant() {
) {
return null;
}
$pemCrtPath = ABSPATH . $this->apple_merchant_cert_path;
$pemKeyPath = ABSPATH . $this->apple_merchant_key_path;
$pemCrtPath = ABSPATH . $this->apple_merchant_cert_path;
$pemKeyPath = ABSPATH . $this->apple_merchant_key_path;

$validationPayload = array();
$validationPayload['merchantIdentifier'] = $this->apple_merchant_id;
Expand Down Expand Up @@ -298,8 +318,8 @@ public function tokenization_script() {
array(
'orderInfoUrl' => WC()->api_request_url( 'globalpayments_order_info' ),
'order' => array(
'amount' => $this->get_session_amount(),
'currency' => get_woocommerce_currency(),
'amount' => $this->get_session_amount(),
'currency' => get_woocommerce_currency(),
)
)
);
Expand Down