Merge pull request #854 from joshuadwire/payments-changes

Payments bug fixes - Part 2
This commit is contained in:
Hillel Coren 2016-05-11 19:55:36 +03:00
commit b5a03915e2
6 changed files with 18 additions and 15 deletions

View File

@ -87,6 +87,7 @@ class AccountGatewayController extends BaseController
->where('id', '!=', GATEWAY_GOCARDLESS) ->where('id', '!=', GATEWAY_GOCARDLESS)
->where('id', '!=', GATEWAY_DWOLLA) ->where('id', '!=', GATEWAY_DWOLLA)
->where('id', '!=', GATEWAY_STRIPE) ->where('id', '!=', GATEWAY_STRIPE)
->where('id', '!=', GATEWAY_WEPAY)
->orderBy('name')->get(); ->orderBy('name')->get();
$data['hiddenFields'] = Gateway::$hiddenFields; $data['hiddenFields'] = Gateway::$hiddenFields;

View File

@ -400,7 +400,7 @@ class PaymentController extends BaseController
} }
public static function processPaymentClientDetails($client, $accountGateway, $paymentType, $onSite = true){ public static function processPaymentClientDetails($client, $accountGateway, $paymentType, $onSite = true){
$rules = [ $rules = $paymentType == PAYMENT_TYPE_STRIPE_ACH ? [] : [
'first_name' => 'required', 'first_name' => 'required',
'last_name' => 'required', 'last_name' => 'required',
]; ];
@ -433,9 +433,7 @@ class PaymentController extends BaseController
$validator = Validator::make(Input::all(), $rules); $validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) { if ($validator->fails()) {
return Redirect::to('payment/'.$invitationKey) return false;
->withErrors($validator)
->withInput(Request::except('cvv'));
} }
if ($requireAddress && $accountGateway->update_address) { if ($requireAddress && $accountGateway->update_address) {
@ -475,9 +473,10 @@ class PaymentController extends BaseController
} }
} }
$result = static::processPaymentClientDetails($client, $accountGateway, $paymentType, $onSite); if (!static::processPaymentClientDetails($client, $accountGateway, $paymentType, $onSite)) {
if ($result !== true) { return Redirect::to('payment/'.$invitationKey)
return $result; ->withErrors($validator)
->withInput(Request::except('cvv'));
} }
try { try {

View File

@ -884,9 +884,8 @@ class PublicClientController extends BaseController
$accountGateway = $account->getGatewayByType($paymentType); $accountGateway = $account->getGatewayByType($paymentType);
$sourceToken = $accountGateway->gateway_id == GATEWAY_STRIPE ? Input::get('stripeToken'):Input::get('payment_method_nonce'); $sourceToken = $accountGateway->gateway_id == GATEWAY_STRIPE ? Input::get('stripeToken'):Input::get('payment_method_nonce');
$result = PaymentController::processPaymentClientDetails($client, $accountGateway, $paymentType); if (!PaymentController::processPaymentClientDetails($client, $accountGateway, $paymentType)) {
if ($result !== true) { return Redirect::to('client/paymentmethods/add/' . $typeLink)->withInput(Request::except('cvv'));
return $result;
} }
if ($sourceToken) { if ($sourceToken) {

View File

@ -191,7 +191,8 @@ class PaymentService extends BaseService
} }
$data = $response->getData(); $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 // Load
$accountGatewayToken->payment_methods(); $accountGatewayToken->payment_methods();
@ -459,8 +460,11 @@ class PaymentService extends BaseService
public function createPaymentMethodFromGatewayResponse($gatewayResponse, $accountGateway, $accountGatewayToken = null, $contactId = null) { public function createPaymentMethodFromGatewayResponse($gatewayResponse, $accountGateway, $accountGatewayToken = null, $contactId = null) {
if ($accountGateway->gateway_id == GATEWAY_STRIPE) { if ($accountGateway->gateway_id == GATEWAY_STRIPE) {
$data = $gatewayResponse->getData(); $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; $source = $data;
} elseif (!empty($data['object']) && $data['object'] == 'customer') {
$sources = !empty($data['sources']) ? $data['sources'] : $data['cards'];
$source = reset($sources);
} else { } else {
$source = !empty($data['source']) ? $data['source'] : $data['card']; $source = !empty($data['source']) ? $data['source'] : $data['card'];
} }

View File

@ -84,7 +84,7 @@ class PaymentsChanges extends Migration
$table->unsignedInteger('default_payment_method_id')->nullable(); $table->unsignedInteger('default_payment_method_id')->nullable();
$table->foreign('default_payment_method_id')->references('id')->on('payment_methods'); $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)); \DB::table('account_gateway_tokens')->update(array('uses_local_payment_methods' => false));

View File

@ -59,8 +59,8 @@
<span class="payment_method_number">&bull;&bull;&bull;&bull;&bull;{{$paymentMethod->last4}}</span> <span class="payment_method_number">&bull;&bull;&bull;&bull;&bull;{{$paymentMethod->last4}}</span>
@endif @endif
@if($paymentMethod->payment_type_id == PAYMENT_TYPE_ACH) @if($paymentMethod->payment_type_id == PAYMENT_TYPE_ACH)
@if($paymentMethod->bank()) @if($paymentMethod->bank_data)
{{ $paymentMethod->bank()->name }} {{ $paymentMethod->bank_data }}
@endif @endif
@if($paymentMethod->status == PAYMENT_METHOD_STATUS_NEW) @if($paymentMethod->status == PAYMENT_METHOD_STATUS_NEW)
<a href="javasript::void" onclick="completeVerification('{{$paymentMethod->public_id}}','{{$paymentMethod->currency->symbol}}')">({{trans('texts.complete_verification')}})</a> <a href="javasript::void" onclick="completeVerification('{{$paymentMethod->public_id}}','{{$paymentMethod->currency->symbol}}')">({{trans('texts.complete_verification')}})</a>