mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-12 22:22:32 +01:00
Merge pull request #854 from joshuadwire/payments-changes
Payments bug fixes - Part 2
This commit is contained in:
commit
b5a03915e2
@ -87,6 +87,7 @@ class AccountGatewayController extends BaseController
|
||||
->where('id', '!=', GATEWAY_GOCARDLESS)
|
||||
->where('id', '!=', GATEWAY_DWOLLA)
|
||||
->where('id', '!=', GATEWAY_STRIPE)
|
||||
->where('id', '!=', GATEWAY_WEPAY)
|
||||
->orderBy('name')->get();
|
||||
$data['hiddenFields'] = Gateway::$hiddenFields;
|
||||
|
||||
|
@ -400,7 +400,7 @@ class PaymentController extends BaseController
|
||||
}
|
||||
|
||||
public static function processPaymentClientDetails($client, $accountGateway, $paymentType, $onSite = true){
|
||||
$rules = [
|
||||
$rules = $paymentType == PAYMENT_TYPE_STRIPE_ACH ? [] : [
|
||||
'first_name' => 'required',
|
||||
'last_name' => 'required',
|
||||
];
|
||||
@ -433,9 +433,7 @@ class PaymentController extends BaseController
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return Redirect::to('payment/'.$invitationKey)
|
||||
->withErrors($validator)
|
||||
->withInput(Request::except('cvv'));
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($requireAddress && $accountGateway->update_address) {
|
||||
@ -475,9 +473,10 @@ class PaymentController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
$result = static::processPaymentClientDetails($client, $accountGateway, $paymentType, $onSite);
|
||||
if ($result !== true) {
|
||||
return $result;
|
||||
if (!static::processPaymentClientDetails($client, $accountGateway, $paymentType, $onSite)) {
|
||||
return Redirect::to('payment/'.$invitationKey)
|
||||
->withErrors($validator)
|
||||
->withInput(Request::except('cvv'));
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -884,9 +884,8 @@ class PublicClientController extends BaseController
|
||||
$accountGateway = $account->getGatewayByType($paymentType);
|
||||
$sourceToken = $accountGateway->gateway_id == GATEWAY_STRIPE ? Input::get('stripeToken'):Input::get('payment_method_nonce');
|
||||
|
||||
$result = PaymentController::processPaymentClientDetails($client, $accountGateway, $paymentType);
|
||||
if ($result !== true) {
|
||||
return $result;
|
||||
if (!PaymentController::processPaymentClientDetails($client, $accountGateway, $paymentType)) {
|
||||
return Redirect::to('client/paymentmethods/add/' . $typeLink)->withInput(Request::except('cvv'));
|
||||
}
|
||||
|
||||
if ($sourceToken) {
|
||||
|
@ -191,7 +191,8 @@ class PaymentService extends BaseService
|
||||
}
|
||||
|
||||
$data = $response->getData();
|
||||
$sources = isset($data['sources']) ? $data['sources']['data'] : $data['cards']['data'];
|
||||
$sources_list = isset($data['sources']) ? $data['sources'] : $data['cards'];
|
||||
$sources = isset($sources_list['data'])?$sources_list['data']:$sources_list;
|
||||
|
||||
// Load
|
||||
$accountGatewayToken->payment_methods();
|
||||
@ -459,8 +460,11 @@ class PaymentService extends BaseService
|
||||
public function createPaymentMethodFromGatewayResponse($gatewayResponse, $accountGateway, $accountGatewayToken = null, $contactId = null) {
|
||||
if ($accountGateway->gateway_id == GATEWAY_STRIPE) {
|
||||
$data = $gatewayResponse->getData();
|
||||
if(!empty($data['object']) && ($data['object'] == 'card' || $data['object'] == 'bank_account')) {
|
||||
if (!empty($data['object']) && ($data['object'] == 'card' || $data['object'] == 'bank_account')) {
|
||||
$source = $data;
|
||||
} elseif (!empty($data['object']) && $data['object'] == 'customer') {
|
||||
$sources = !empty($data['sources']) ? $data['sources'] : $data['cards'];
|
||||
$source = reset($sources);
|
||||
} else {
|
||||
$source = !empty($data['source']) ? $data['source'] : $data['card'];
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ class PaymentsChanges extends Migration
|
||||
$table->unsignedInteger('default_payment_method_id')->nullable();
|
||||
$table->foreign('default_payment_method_id')->references('id')->on('payment_methods');
|
||||
|
||||
$table->boolean('uses_local_payment_methods')->defalut(true);
|
||||
$table->boolean('uses_local_payment_methods')->default(true);
|
||||
});
|
||||
|
||||
\DB::table('account_gateway_tokens')->update(array('uses_local_payment_methods' => false));
|
||||
|
@ -59,8 +59,8 @@
|
||||
<span class="payment_method_number">•••••{{$paymentMethod->last4}}</span>
|
||||
@endif
|
||||
@if($paymentMethod->payment_type_id == PAYMENT_TYPE_ACH)
|
||||
@if($paymentMethod->bank())
|
||||
{{ $paymentMethod->bank()->name }}
|
||||
@if($paymentMethod->bank_data)
|
||||
{{ $paymentMethod->bank_data }}
|
||||
@endif
|
||||
@if($paymentMethod->status == PAYMENT_METHOD_STATUS_NEW)
|
||||
<a href="javasript::void" onclick="completeVerification('{{$paymentMethod->public_id}}','{{$paymentMethod->currency->symbol}}')">({{trans('texts.complete_verification')}})</a>
|
||||
|
Loading…
Reference in New Issue
Block a user