Fix refunds; support using stored card; change proPlanModel link

This commit is contained in:
Joshua Dwire 2016-04-20 16:53:56 -04:00
parent 71b6b6eb87
commit 9d27b68fb6
3 changed files with 15 additions and 12 deletions

View File

@ -165,7 +165,7 @@ class AccountController extends BaseController
$account->company->save(); $account->company->save();
Session::flash('message', trans('texts.updated_plan')); Session::flash('message', trans('texts.updated_plan'));
} }
} else { } elseif (!empty($planDetails['started'])) {
// Downgrade // Downgrade
$refund_deadline = clone $planDetails['started']; $refund_deadline = clone $planDetails['started'];
$refund_deadline->modify('+30 days'); $refund_deadline->modify('+30 days');
@ -186,7 +186,7 @@ class AccountController extends BaseController
$gateway = $this->paymentService->createGateway($payment->account_gateway); $gateway = $this->paymentService->createGateway($payment->account_gateway);
$refund = $gateway->refund(array( $refund = $gateway->refund(array(
'transactionReference' => $payment->transaction_reference, 'transactionReference' => $payment->transaction_reference,
'amount' => $payment->amount * 100 'amount' => $payment->amount
)); ));
$refund->send(); $refund->send();
$payment->delete(); $payment->delete();
@ -238,7 +238,7 @@ class AccountController extends BaseController
if (!empty($new_plan)) { if (!empty($new_plan)) {
$invitation = $this->accountRepo->enablePlan($new_plan['plan'], $new_plan['term'], $credit, !empty($pending_monthly)); $invitation = $this->accountRepo->enablePlan($new_plan['plan'], $new_plan['term'], $credit, !empty($pending_monthly));
return Redirect::to('payment/'.$invitation->invitation_key); return Redirect::to('view/'.$invitation->invitation_key);
} }
return Redirect::to('/settings/'.ACCOUNT_MANAGEMENT, 301); return Redirect::to('/settings/'.ACCOUNT_MANAGEMENT, 301);

View File

@ -220,6 +220,11 @@
} }
$('#plan_term, #plan').change(updatePlanModal); $('#plan_term, #plan').change(updatePlanModal);
updatePlanModal(); updatePlanModal();
if(window.location.hash) {
var hash = window.location.hash;
$(hash).modal('toggle');
}
}); });
</script> </script>
@stop @stop

View File

@ -190,14 +190,12 @@
fbq('track', 'AddPaymentInfo'); fbq('track', 'AddPaymentInfo');
trackEvent('/account', '/submit_pro_plan/' + NINJA.proPlanFeature); trackEvent('/account', '/submit_pro_plan/' + NINJA.proPlanFeature);
if (NINJA.isRegistered) { if (NINJA.isRegistered) {
$.ajax({ if (window.showChangePlan) {
type: 'POST', $('#proPlanModal').modal('hide');
url: '{{ URL::to('account/go_pro') }}', showChangePlan();
success: function(result) { } else {
NINJA.formIsChanged = false; window.location = '/settings/account_management#changePlanModel';
window.location = '/payment/' + result; }
}
});
} else { } else {
$('#proPlanModal').modal('hide'); $('#proPlanModal').modal('hide');
$('#go_pro').val('true'); $('#go_pro').val('true');