%PDF- %PDF- 403WebShell
403Webshell
Server IP : 37.220.80.31  /  Your IP : 18.188.3.236
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux 3051455-guretool.twc1.net 5.15.0-107-generic #117-Ubuntu SMP Fri Apr 26 12:26:49 UTC 2024 x86_64
User : www-root ( 1010)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /var/www/www-root/data/www/dev.artlot24.ru/bitrix/js/sale/handlers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/www-root/data/www/dev.artlot24.ru/bitrix/js/sale/handlers/applepay.js
BX.namespace('BX.Sale.PaymentApplePay');

(function() {
	'use strict';

	BX.Sale.PaymentApplePay = {
		STATUS_SUCCESS: 'success',
		STATUS_FAILURE: 'fail',

		init: function(parameters)
		{
			this.ajaxUrl = parameters.ajaxUrl;
			this.salePaySystemWrapperNode = BX(parameters.salePaySystemWrapperId);
			this.paymentButtonNode = BX(parameters.paymentButtonId);
			this.paymentButtonWrapperNode = BX(parameters.paymentButtonWrapperId);

			this.params = parameters.params;
			this.message = parameters.message;

			if (this.isApplePayAvailable())
			{
				this.showApplePayButton();
				this.initApplePayPayment();
			}
			else
			{
				this.showNotAvailableMessage();
			}
		},

		bindEvents: function()
		{
			BX.bind(this.paymentButtonNode, 'click', BX.proxy(this.makePayment, this));
		},

		createPaymentRequest: function()
		{
			var methodData = [{
				supportedMethods: [this.params.SUPPORTED_METHOD],
				data: {
					version: 3,
					merchantIdentifier: this.params.MERCHANT_ID,
					merchantCapabilities: this.params.MERCHANT_CAPABILITIES,
					supportedNetworks: ["amex", "discover", "masterCard", "visa"],
					countryCode: this.params.COUNTRY_CODE,
					currencyCode: this.params.CURRENCY
				}
			}];

			var paymentDetails = {
				total: {
					label: this.params.DISPLAY_NAME,
					amount: { value: this.params.TOTAL_SUM, currency: this.params.CURRENCY },
				},
				displayItems: [
					{
						label:  this.message.ORDER_TITLE + ' ' + this.params.ORDER_ID,
						amount: { value: this.params.TOTAL_SUM, currency: this.params.CURRENCY },
					}
				]
			};

			var paymentOptions = {
				requestPayerName: false,
				requestPayerEmail: false,
				requestPayerPhone: false,
				requestShipping: false
			};

			return new PaymentRequest(methodData, paymentDetails, paymentOptions);
		},

		isApplePayAvailable: function()
		{
			return !!(window.PaymentRequest && window.ApplePaySession && ApplePaySession.canMakePayments());
		},

		initApplePayPayment: function ()
		{
			var request;

			if (!window.PaymentRequest)
				return;

			request = this.createPaymentRequest();
			request.canMakePayment()
				.then(function(result) {
					if (result || this.isApplePayAvailable()) {
						this.bindEvents();
					}
				}.bind(this))
				.catch(function() {
					this.showNotAvailableMessage();
				}.bind(this));
		},

		showApplePayButton: function()
		{
			this.paymentButtonNode.style.display = 'inline-block';
		},

		showNotAvailableMessage: function()
		{
			var messageNode = document.createElement('div');
			messageNode.innerHTML = this.message.PAY_SYSTEM_NOT_AVAILABLE;
			messageNode.classList.add("alert");
			messageNode.classList.add("alert-danger");
			this.paymentButtonWrapperNode.appendChild(messageNode);
		},

		makePayment: function()
		{
			var request = this.createPaymentRequest();

			request.onmerchantvalidation = function (event) {
				var sessionPromise = this.fetchPaymentSession(event.validationURL);
				event.complete(sessionPromise);
			}.bind(this);

			try {
				request.show().then(function(response) {
					this.processPayment(response);
				}.bind(this));
			}
			catch (err)
			{
				alert(this.message.ERROR_MESSAGE);
			}
		},

		fetchPaymentSession: function(validationURL)
		{
			var postData = {
				PAYMENT_ID: this.params.PAYMENT_ID,
				PAYSYSTEM_ID: this.params.PAYSYSTEM_ID,
				action: this.params.GET_SESSION_ACTION,
				url: validationURL,
				merchantIdentifier: this.params.MERCHANT_ID,
				displayName: this.params.DISPLAY_NAME,
				initiativeContext: this.params.DOMAIN_NAME
			};

			return this.send(postData);
		},

		processPayment: function(response)
		{
			var postData = {
				PAYMENT_ID: this.params.PAYMENT_ID,
				PAYSYSTEM_ID: this.params.PAYSYSTEM_ID,
				action: this.params.MAKE_PAYMENT_ACTION,
				paymentData: JSON.stringify(response.details.token.paymentData)
			};

			this.send(postData)
				.then(function() {
					response.complete(this.STATUS_SUCCESS);
					this.showSuccessfulTemplate();
				}.bind(this))
				.catch(function (error) {
					response.complete(this.STATUS_FAILURE);
					this.showErrorTemplate(error.message);
				}.bind(this));
		},

		send: function (postData)
		{
			return new Promise(function (resolve, reject) {
				BX.ajax({
					method: 'POST',
					dataType: 'json',
					url: this.ajaxUrl,
					data: postData,
					onsuccess: BX.proxy(function(result) {
						if (result.status === 'success')
						{
							resolve(result.data);
						}
						else if (result.status === 'error')
						{
							reject(new Error(result.errors.join("<br>")));
						}
					}),
					onfailure: BX.proxy(function() {
						reject(new Error(this.message.ERROR_MESSAGE));
					})
				});
			}.bind(this));
		},

		showSuccessfulTemplate: function()
		{
			var successfulBlock = document.createElement('div');
			successfulBlock.innerHTML = this.message.PAYMENT_APPROVED;
			successfulBlock.innerHTML = successfulBlock.innerHTML + "<br>";
			successfulBlock.innerHTML = successfulBlock.innerHTML + this.message.PAID_MESSAGE;
			successfulBlock.classList.add("alert");
			successfulBlock.classList.add("alert-success");
			this.salePaySystemWrapperNode.innerHTML = '';
			this.salePaySystemWrapperNode.appendChild(successfulBlock);
		},

		showErrorTemplate: function(errorMessage)
		{
			var errorBlock = document.createElement('div');
			errorBlock.innerHTML = errorMessage;
			errorBlock.classList.add("alert");
			errorBlock.classList.add("alert-danger");
			this.salePaySystemWrapperNode.innerHTML = '';
			this.salePaySystemWrapperNode.appendChild(errorBlock);
		},
	};
})();

Youez - 2016 - github.com/yon3zu
LinuXploit