Skip to content

Commit

Permalink
intitial commit with code
Browse files Browse the repository at this point in the history
  • Loading branch information
shan008 committed Aug 21, 2024
1 parent 3d2a151 commit 594922b
Show file tree
Hide file tree
Showing 10 changed files with 1,740 additions and 0 deletions.
Binary file added assets/img/logo-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/logo_back.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
103 changes: 103 additions & 0 deletions class-wc-tap-blocks-support.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?php
use Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType;
use Automattic\WooCommerce\Blocks\Assets\Api;

defined( 'ABSPATH' ) || exit;

/**
* WC_Tap_Blocks_Support class.
*
* @extends AbstractPaymentMethodType
*/
final class WC_Tap_Blocks_Support extends AbstractPaymentMethodType {
/**
* Payment method name defined by payment methods extending this class.
*
* @var string
*/
protected $name = 'tap';

/**
* An instance of the Asset Api
*
* @var Api
*/
private $asset_api;

/**
* Constructor
*
* @param Api $asset_api An instance of Api.
*/
public function __construct( Api $asset_api ) {
$this->asset_api = $asset_api;
}

/**
* Initializes the payment method type.
*/
public function initialize() {
$this->settings = get_option( 'woocommerce_tap_settings', [] );
}

/**
* Returns if this payment method should be active. If false, the scripts will not be enqueued.
*
* @return boolean
*/
public function is_active() {
return filter_var( $this->get_setting( 'enabled', false ), FILTER_VALIDATE_BOOLEAN );
}

/**
* Returns an array of scripts/handles to be registered for this payment method.
*
* @return array
*/
public function get_payment_method_script_handles() {
$dependencies = [];
wp_register_script( 'woocommerce_wc_payment_method_tap',
plugins_url('wc-payment-method-tap.js', __FILE__ ),
array_merge([], $dependencies ),
'',
true
);
return ['woocommerce_wc_payment_method_tap'];
}

/**
* Returns an array of key=>value pairs of data made available to the payment methods script.
*
* @return array
*/
public function get_payment_method_data() {
return [
'title' => $this->get_setting( 'title' ),
'description' => $this->get_setting( 'description' ),
'supports' => $this->get_supported_features(),
];
}

/**
* Returns an array of supported features.
*
* @return string[]
*/
public function get_supported_features() {
$gateway = new WC_Tap_Gateway();
$features = array_filter( $gateway->supports, array( $gateway, 'supports' ) );

/**
* Filter to control what features are available for each payment gateway.
*
* @since 4.4.0
*
* @example See docs/examples/payment-gateways-features-list.md
*
* @param array $features List of supported features.
* @param string $name Gateway name.
* @return array Updated list of supported features.
*/
return apply_filters( '__experimental_woocommerce_blocks_payment_gateway_features_list', $features, $this->get_name() );
}
}
174 changes: 174 additions & 0 deletions taap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
jQuery(document).ready(function(){
var live_public_key = jQuery("#live_public_key").val();
var testmode = jQuery("#testmode").val();
if (testmode == true) {
var active_pk = jQuery("#test_public_key").val();
}else{
var active_pk = jQuery("#publishable_key").val();
}

var tmode = jQuery("#payment_mode").val();
var amount = jQuery("#amount").val();
var save_card = jQuery("#save_card").val()
var Ui_language = jQuery("#ui_language").val();
if( Ui_language == 'english'){
Ui_language_val = 'en';
}else{
Ui_language_val = 'ar';
}

if( save_card == 'no') {
save_card_val = false;
}else {
save_card_val = true;
}

var currency = jQuery("#currency").val();
var billing_first_name = jQuery("#billing_first_name").val();
var customer_user_id = jQuery("#customer_user_id").val();
var billing_last_name = jQuery("#billing_last_name").val();
var billing_email = jQuery("#billing_email").val();
var billing_phone = jQuery("#billing_phone").val();
var country_code = jQuery("#countrycode").val();

console.log(country_code);

var items_values = [];

jQuery('input[class$="items_bulk"]').each(function() {
items_values.push({
'id': jQuery(this).attr('data-item-product-id'),
'name': jQuery(this).attr('data-name'),
'description': '',
'quantity': jQuery(this).attr('data-quantity'),
'amount_per_unit': jQuery(this).attr('data-sale-price'),
'discount': {
'type': 'P',
'value': '10%'
},
'total_amount': jQuery(this).attr('data-product-total-amount')
});
});

if (tmode == 'authorize') {
var transaction_mode = {
mode: 'authorize',
authorize:{
auto:{
type:'VOID',
time: 100
},
saveCard: save_card_val,
threeDSecure: true,
description: "description",
statement_descriptor:"statement_descriptor",
reference:{
transaction: '',
order: jQuery("#order_id").val()
},
hashstring:jQuery("#hashstring").val(),
metadata:{},
receipt:{
email: false,
sms: true
},
redirect: jQuery('#tap_end_url').val(),
post: jQuery('#post_url').val()
}
}
}

if (tmode == 'charge') {
var transaction_mode = {
mode: 'charge',
charge:{
saveCard: save_card_val,
threeDSecure: true,
description: "Test Description",
statement_descriptor: "Sample",
reference:{
transaction: '',
order: jQuery("#order_id").val()
},
hashstring:jQuery("#hashstring").val(),
metadata:{},
receipt:{
email: false,
sms: true
},
redirect: jQuery('#tap_end_url').val(),
post: jQuery('#post_url').val()
}
}
}

var config = {
gateway:{
publicKey:active_pk,
language:Ui_language_val,
contactInfo:true,
supportedCurrencies:"all",
supportedPaymentMethods: "all",
saveCardOption:false,
customerCards: true,
notifications:'standard',
callback: (response) => {
console.log("response", response);
},
labels:{
cardNumber:"Card Number",
expirationDate:"MM/YY",
cvv:"CVV",
cardHolder:"Name on Card",
actionButton:"Pay"
},
style: {
base: {
color: '#535353',
lineHeight: '18px',
fontFamily: 'sans-serif',
fontSmoothing: 'antialiased',
fontSize: '16px',
'::placeholder': {
color: 'rgba(0, 0, 0, 0.26)',
fontSize:'15px'
}
},
invalid: {
color: 'red',
iconColor: '#fa755a '
}
}
},
customer:{
id: '',
first_name: billing_first_name,
middle_name: "Middle Name",
last_name: billing_last_name,
email: billing_email,
phone: {
country_code: country_code,
number: billing_phone
}
},
order:{
amount: amount,
currency:currency,
items:items_values,
shipping:null,
taxes: null
},
transaction:transaction_mode
}

console.log(config);
if ( active_pk ) {
goSell.config(config);
}
});

var chg = jQuery("#chg").val();
jQuery(function($){
var checkout_form = jQuery( 'form.woocommerce-checkout' );
checkout_form.on( 'checkout_place_order', chg);
});
26 changes: 26 additions & 0 deletions tap-payment.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*.gosell-gateway-list-container {
border:1px solid red !important;
}
#gosell-gateway-side-menu > .gosell-gateway-row >img{
border:1px solid red !important;
}
.gosell-gateway-row > img {
border:1px solid red !important;
padding:0px !important;
}
.gosell-gateway-row-icon > img {
padding: 0 !important;
margin-top: 3px !important;
margin-left:20px !important;
}*/
/**{
box-sizing: unset !important;
-webkit-box-sizing: unset !important;
-moz-box-sizing: unset !important;
box-sizing: unset !important;
}*/
.wc_payment_method>label:first-of-type img{
float: revert;
}
Loading

0 comments on commit 594922b

Please sign in to comment.