Skip to content

Commit

Permalink
WIP: TakeOver Vaulting
Browse files Browse the repository at this point in the history
  • Loading branch information
mariolorenz committed Jan 16, 2025
1 parent e61a321 commit f617e3d
Show file tree
Hide file tree
Showing 17 changed files with 343 additions and 221 deletions.
4 changes: 2 additions & 2 deletions metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@
'@osc_paypal/frontend/shared/applepay.tpl' => 'views/smarty/frontend/shared/applepay.tpl',

//PSPAYPAL-680 Vaulting
'@osc_paypal/frontend/shared/account_vaulting_paypal.tpl' => 'views/smarty/frontend/shared/page/account/account_vaulting_paypal.tpl',
'@osc_paypal/frontend/shared/account_vaulting_card.tpl' => 'views/smarty/frontend/shared/page/account/account_vaulting_card.tpl',
'@osc_paypal/frontend/account_vaulting_paypal.tpl' => 'views/smarty/frontend/shared/page/account/account_vaulting_paypal.tpl',
'@osc_paypal/frontend/account_vaulting_card.tpl' => 'views/smarty/frontend/shared/page/account/account_vaulting_card.tpl',
'@osc_paypal/frontend/shared/vaultedpaymentsources.tpl' => 'views/smarty/frontend/shared/vaultedpaymentsources.tpl',
'@osc_paypal/frontend/flow/vaultedpaymentsources.tpl' => 'views/smarty/frontend/flow/vaulting/vaultedpaymentsources.tpl',
'@osc_paypal/frontend/wave/vaultedpaymentsources.tpl' => 'views/smarty/frontend/wave/vaulting/vaultedpaymentsources.tpl',
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/PayPalVaultingCardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function render()
$this->_aViewData['vaultingUserId'] = oxNew(Config::class)->getUserIdForVaulting();
$moduleSettings = $this->getServiceFromContainer(ModuleSettings::class);
if ($moduleSettings->isVaultingAllowedForACDC()) {
$this->_sThisTemplate = '@osc_paypal/frontend/shared/account_vaulting_card';
$this->_sThisTemplate = '@osc_paypal/frontend/account_vaulting_card';
}

return parent::render();
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/PayPalVaultingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function render()
$this->_aViewData['vaultingUserId'] = oxNew(Config::class)->getUserIdForVaulting();
$moduleSettings = $this->getServiceFromContainer(ModuleSettings::class);
if ($moduleSettings->isVaultingAllowedForPayPal()) {
$this->_sThisTemplate = '@osc_paypal/frontend/shared/account_vaulting_paypal';
$this->_sThisTemplate = '@osc_paypal/frontend/account_vaulting_paypal';
}

return parent::render();
Expand Down
102 changes: 0 additions & 102 deletions views/smarty/frontend/blocks/page/account/account_vaulting_card.tpl

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,34 @@
<script>
window.onload = function () {
paypal.Buttons({
createVaultSetupToken: async () => {
const result = await fetch(
"[{oxgetseourl ident=$oViewConf->getGenerateSetupTokenLink()}]",
{ method: "POST"
})
const { id } = await result.json();
return id;
},
onApprove: async ({ vaultSetupToken }) => {
const result = await fetch(
"[{oxgetseourl ident=$oViewConf->getGeneratePaymentTokenLink()}]"+vaultSetupToken,
{method: 'POST'
})
const status = await result.json();
createVaultSetupToken: async () => {
const result = await fetch(
"[{oxgetseourl ident=$oViewConf->getGenerateSetupTokenLink()}]",
{ method: "POST"
})
const { id } = await result.json();
return id;
},
onApprove: async ({ vaultSetupToken }) => {
const result = await fetch(
"[{oxgetseourl ident=$oViewConf->getGeneratePaymentTokenLink()}]"+vaultSetupToken,
{method: 'POST'
})
const status = await result.json();
if(status.state === "SUCCESS") {
showSuccessMessage();
}else {
showFailureMessage();
}
},
onError: (error) => {
//TODO
},
style: {
label: 'checkout'
}
}).render("#PayPalButtonVaulting");
if(status.state === "SUCCESS") {
showSuccessMessage();
}else {
showFailureMessage();
}
},
onError: (error) => {
//TODO
},
style: {
label: 'checkout'
}
}).render("#PayPalButtonVaulting");
function showSuccessMessage() {
$('#PayPalButtonVaulting').hide();
Expand Down
14 changes: 7 additions & 7 deletions views/smarty/frontend/shared/page/checkout/acdc.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@
let downloadableProductAgreement = (document.getElementById('oxdownloadableproductsagreement') && document.getElementById('oxdownloadableproductsagreement').checked) ? 1 : 0;
let serviceProductAgreement = (document.getElementById('oxserviceproductsagreement') && document.getElementById('oxserviceproductsagreement').checked) ? 1 : 0;
let vaultPayment = document.getElementById("oscPayPalVaultPaymentCheckbox")?.checked ?? false;
let url = '[{$sSelfLink}]' + "cl=order&fnc=createAcdcOrder&ord_agb="+
ordAgb+"&oxdownloadableproductsagreement=" +downloadableProductAgreement
+ "&oxserviceproductsagreement="+serviceProductAgreement
+ "&stoken=" + '[{$oViewConf->getSessionChallengeToken()}]'
+ '&sDeliveryAddressMD5=' + '[{$oView->getDeliveryAddressMD5()}]'
+ '&vaultPayment=' + vaultPayment
+ '&oscPayPalPaymentTypeForVaulting=' + 'oscpaypal_acdc'
let url = "[{$sSelfLink}]cl=order&fnc=createAcdcOrder&ord_agb=" + ordAgb
+ "&oxdownloadableproductsagreement=" + downloadableProductAgreement
+ "&oxserviceproductsagreement="+ serviceProductAgreement
+ "&stoken=" + "[{$oViewConf->getSessionChallengeToken()}]"
+ "&sDeliveryAddressMD5=" + "[{$oView->getDeliveryAddressMD5()}]"
+ "&vaultPayment=" + vaultPayment
+ "&oscPayPalPaymentTypeForVaulting=oscpaypal_acdc"
;
return fetch(url, {
method: 'post',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{% extends "page/account/dashboard.html.twig" %}

{% block account_dashboard_col1 %}
{{ parent() }}
{% if oViewConf.getIsVaultingActive() %}
{% if oViewConf.isVaultingAllowedForPayPal() %}
<div class="col mb-3">
<div class="card card-lg h-100">
<h4 class="card-header card-title">{{ translate({ ident: "OSC_PAYPAL_VAULTING_MENU" }) }}</h4>
<div class="card-body">
<a class="btn btn-outline-primary stretched-link" href="{{ seo_url({ ident: oViewConf.getSelfLink() ~ "cl=oscaccountvault" }) }}">
{{ translate({ ident: "MORE" }) }}
</a>
</div>
</div>
</div>
{% endif %}
{% if oViewConf.isAcdcEligibility() and oViewConf.isVaultingAllowedForACDC() %}
<div class="col mb-3">
<div class="card card-lg h-100">
<h4 class="card-header card-title">{{ translate({ ident: "OSC_PAYPAL_VAULTING_MENU_CARD" }) }}</h4>
<div class="card-body">
<a class="btn btn-outline-primary stretched-link" href="{{ seo_url({ ident: oViewConf.getSelfLink() ~ "cl=oscaccountvaultcard" }) }}">
{{ translate({ ident: "MORE" }) }}
</a>
</div>
</div>
</div>
{% endif %}
{% endif %}
{% endblock %}

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% extends "page/account/inc/account_menu.html.twig" %}

{% block account_menu %}
{{ parent() }}
{% if oViewConf.getIsVaultingActive() %}
{% if oViewConf.isVaultingAllowedForPayPal() %}
<a class="dropdown-item{% if active_link == "oscPayPalVaulting" %} active{% endif %}" href="{{ seo_url({ ident: oViewConf.getSslSelfLink() ~ "cl=oscaccountvault" }) }}" title="{{ translate({ ident: "OSC_PAYPAL_VAULTING_MENU" }) }}">{{ translate({ ident: "OSC_PAYPAL_VAULTING_MENU" }) }}</a>
{% endif %}
{% if oViewConf.isAcdcEligibility() and oViewConf.isVaultingAllowedForACDC() %}
<a class="dropdown-item{% if active_link == "oscPayPalVaultingCard" %} active{% endif %}" href="{{ seo_url({ ident: oViewConf.getSslSelfLink() ~ "cl=oscaccountvaultcard" }) }}" title="{{ translate({ ident: "OSC_PAYPAL_VAULTING_MENU_CARD" }) }}">{{ translate({ ident: "OSC_PAYPAL_VAULTING_MENU_CARD" }) }}</a>
{% endif %}
{% endif %}
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{% block shippingAndPayment %}
{% set payment = oView.getPayment() %}
{% if payment.getId() == "oscpaypal_acdc" or payment.getId() == "oscpaypal_pui" %}
{% if payment.getId() in ['oscpaypal_acdc', 'oscpaypal_pui', 'oscpaypal'] or vaultedPaymentDescription %}
{% set sPaymentID = payment.getId() %}
<form action="{{ oViewConf.getSslSelfLink()|replace({'&amp;': '&'})|raw }}" method="post"
id="orderShipping">
Expand Down Expand Up @@ -40,12 +40,16 @@
</form>
<div class="card-body">
{% set payment = oView.getPayment() %}
{{ payment.oxpayments__oxdesc.value }}
{% if not oscpaypal_executing_order %}
{% if vaultedPaymentDescription %}
{{ vaultedPaymentDescription }}
{% elseif not oscpaypal_executing_order %}
{{ payment.oxpayments__oxdesc.value }}
{% if sPaymentID == "oscpaypal_acdc" %}
{% include "@osc_paypal/frontend/acdc.html.twig" %}
{% elseif sPaymentID == "oscpaypal_pui" %}
{% include "@osc_paypal/frontend/pui_flow.html.twig" %}
{% include "@osc_paypal/frontend/pui.html.twig" %}
{% elseif sPaymentID == "oscpaypal" %}
{% include "@osc_paypal/frontend/paypal.html.twig" %}
{% endif %}
{% endif %}
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% extends "page/checkout/thankyou.html.twig" %}

{% block checkout_thankyou_info %}
{{ parent() }}

{% set vaultSuccess = viewConf.getSessionVaultSuccess() %}

{% if vaultSuccess is not null %}
{% if vaultSuccess %}
<p class="alert alert-success">
{{ translate({ ident: "OSC_PAYPAL_VAULTING_SUCCESS" }) }}
</p>
{% else %}
<p class="alert alert-danger">
{{ translate({ ident: "OSC_PAYPAL_VAULTING_ERROR" }) }}
</p>
{% endif %}
{% endif %}
{% endblock %}
Loading

0 comments on commit f617e3d

Please sign in to comment.