Drupal: PayPal placilo

This commit is contained in:
Robert 2020-10-06 00:09:00 +02:00
parent 21944ac871
commit d55bee3bd7
5 changed files with 112 additions and 32 deletions

View File

@ -18,8 +18,8 @@ function nakupovanje_1ka_menu()
];
$items['narocilo/paypal'] = [
'title' => 'Avtorizacija podatkov', //page title
'description' => 'Preverjam naročilo, če je res plačano preko PayPala',
'title' => 'Uspešno plačilo preko PayPala', //page title
'description' => 'Plačilo je bilo opravljeno preko PayPal-a',
'page callback' => 'nakupovanje_1ka_paypal_return', //callback function which is invoked when menu item is called.
'access callback' => true, //any user can access this page
'page arguments' => [
@ -27,6 +27,17 @@ function nakupovanje_1ka_menu()
],
];
$items['narocilo/paypal-cancel'] = [
'title' => 'Preklicano plačilo preko PayPala', //page title
'description' => 'Uporabnik je preklical plačilo',
'page callback' => 'nakupovanje_1ka_paypal_cancel', //callback function which is invoked when menu item is called.
'access callback' => true, //any user can access this page
'page arguments' => [
1,
],
];
$items['narocilo-pregled/%/pdf'] = [
'title' => 'Uspešno opravljen nakup', //page title
'description' => 'Pridobimo PDF pred/računa',
@ -168,9 +179,15 @@ function nakupovanje_1ka_pdf()
function nakupovanje_1ka_paypal_return()
{
return theme('nalupovanje_1ka_paypal');
return theme('nakupovanje_1ka_paypal_return');
}
function nakupovanje_1ka_paypal_cancel()
{
return theme('nakupovanje_1ka_paypal_cancel');
}
function cenik_paketov_1ka_zasebni_uporabniki()
{
return theme('nakupovanje_1ka_cenik_paketov_zasebni_uporabniki');
@ -209,11 +226,16 @@ function nakupovanje_1ka_theme($existing, $type, $theme, $path)
'path' => $path_to_theme.'/templates/',
];
$themes['nalupovanje_1ka_paypal'] = [
$themes['nakupovanje_1ka_paypal_return'] = [
'template' => 'nakupovanje-1ka-paypal-return',
'path' => $path_to_theme.'/templates/',
];
$themes['nakupovanje_1ka_paypal_cancel'] = [
'template' => 'nakupovanje-1ka-paypal-cancel',
'path' => $path_to_theme.'/templates/',
];
$themes['nakupovanje_1ka_cenik_paketov_zasebni_uporabniki'] = [
'template' => 'nakupovanje-1ka-cenik-zasebni-uporabniki',
'path' => $path_to_theme.'/templates/',

View File

@ -789,23 +789,33 @@
}
}
if (window.location.pathname.indexOf('/narocilo/paypal') > -1) {
jQuery.post('/frontend/payments/api.php?action=check_paypal').done(function (val) {
if (window.location.pathname.indexOf('/narocilo/paypal-cancel?narocilo_id') > -1 && location.search.split('narocilo_id=').length > 1) {
var narocilo = location.search.split('narocilo_id=')[1];
jQuery.post('/frontend/payments/api.php?action=capture_narocilo_paypal', {
narocilo_id: narocilo
}).done(function (val) {
val = JSON.parse(val);
if (val.error) {
return jQuery('.procesiram-narocilo').text(val.error);
}
//TODO: SUtrezno dopolni ko je pay pal zaključen
// Glede na jezik preusmerimo na slovensko oz. angleško verzijo
var urlRedirect = "/d/narocilo-pregled/racun/pdf";
if (lang() == 'en') {
urlRedirect = "/d/en/purchase/invoice/pdf";
});
}
if (window.location.href.indexOf('/narocilo/paypal?narocilo_id') > -1 && location.search.split('narocilo_id=').length > 1) {
var narocilo = location.search.split('narocilo_id=')[1];
jQuery.post('/frontend/payments/api.php?action=cancel_narocilo_paypal', {
narocilo_id: narocilo
}).done(function (val) {
val = JSON.parse(val);
if (val.error) {
return jQuery('.procesiram-narocilo').text(val.error);
}
window.location = urlRedirect;
});
}

View File

@ -526,17 +526,17 @@
</label>
</span>
<!-- <input type="radio" id="paymentMethod2" name="payment_method" value="2" required="required">-->
<!-- <span class="paket vrsta-placila">-->
<!-- <label for="paymentMethod2">-->
<!-- --><?php //if ($language->language == 'sl'): ?>
<!-- Plačilo preko PayPal računa-->
<!-- --><?php //else: ?>
<!-- Payment via PayPal account-->
<!-- --><?php //endif; ?>
<!-- </label>-->
<!-- <img src="/d/sites/all/themes/pro1ka/img/paypal_logo.png" class="logo">-->
<!-- </span>-->
<input type="radio" id="paymentMethod2" name="payment_method" value="2" required="required">
<span class="paket vrsta-placila">
<label for="paymentMethod2">
<?php if ($language->language == 'sl'): ?>
Plačilo preko PayPal računa
<?php else: ?>
Payment via PayPal account
<?php endif; ?>
</label>
<img src="/d/sites/all/themes/pro1ka/img/paypal_logo.png" class="logo">
</span>
<input type="radio" id="paymentMethod3" name="payment_method" value="3" required="required">
<span class="paket vrsta-placila">

View File

@ -0,0 +1,25 @@
<?php global $language; ?>
<div id="narocilo-1ka-cancel-paypal">
<div style="padding: 2rem 0;">
<p>
<?php if ($language->language == 'sl'): ?>
Zahvaljujemo se vam za vaš nakup preko PayPal računa. Vaš novi paket je aktiven in ga lahko pričnete uporabljati.
<?php else: ?>
Thank you for your purchase using PayPal! Your new package is now active and you can use it.
<?php endif; ?>
</p>
</div>
<div class="w-clearfix bottom-buttons">
<div class="col" style="float: left;">
<?php if ($language->language == 'sl'): ?>
<a href="/" class="w-link-button">Vrni se na naslovno stran</a>
<?php else: ?>
<a href="/d/en" class="w-link-button">Return to home page</a>
<?php endif; ?>
</div>
</div>
</div>

View File

@ -1,11 +1,34 @@
<?php global $language ?>
<?php global $language; ?>
<div id="paypal-return-link" class="nakup-1ka">
<div class="w-clearfix procesiram-narocilo">
<div id="narocilo-1ka-return-paypal">
<div style="padding: 2rem 0;">
<p>
<?php if ($language->language == 'sl'): ?>
Naročilo se obdeluje. Prosimo počakajte trenutek
Zahvaljujemo se vam za vaš nakup preko PayPal računa. Vaš novi paket je aktiven in ga lahko pričnete uporabljati.
<?php else: ?>
The order is being processed. Please wait a moment
Thank you for your purchase using PayPal! Your new package is now active and you can use it.
<?php endif; ?>
</p>
</div>
<div class="w-clearfix bottom-buttons">
<div class="col" style="float: right;">
<?php if ($language->language == 'sl'): ?>
<a href="/admin/survey" class="submit-btn w-button">Ustvari anketo</a>
<?php else: ?>
<a href="/admin/survey/index.php?lang=en" class="submit-btn w-button">Create a survey</a>
<?php endif; ?>
</div>
<div class="col" style="float: left;">
<?php if ($language->language == 'sl'): ?>
<a href="/" class="w-link-button">Vrni se na naslovno stran</a>
<?php else: ?>
<a href="/d/en" class="w-link-button">Return to home page</a>
<?php endif; ?>
</div>
</div>
</div>