When a user clicks on the proceed to payment
button, it redirects to the redirectPayment.html
page with target=_blank
for payment operations. After triggering the payment, a flag called creditsRefresh
is set to Yes
using local storage. Upon successful payment, the user is redirected to a success JSP page. However, I want to refresh the amount after payment and bring the user back to the original tab where the payment was initiated. To achieve this, I need to call a function when the user clicks on the window if creditsRefresh
is set to yes
. My attempts with using onFocus
or onBlur
have been unsuccessful.
Code snippet from payment.html:
<button class="btn btn-primary" ng-click="initiatePayment(CreditDetails);">Proceed to pay</button>
Snippet from Paymentcontroller.js:
$scope.initiatePayment = function(){
$window.localStorage.setItem('creditsRefresh','yes');
$window.open('/redirectPayment','_blank');
}
After a successful payment, the $scope.myCredits
function will be used to refresh the amount.
$scope.focusOnPageCall = function(){
if ($window.localStorage.getItem('creditsRefresh') == 'yes'){
$scope.myCredits();
$window.localStorage.setItem('creditsRefresh' ,'no');
}}
$window.onfocus = $scope.focusOnPageCall();