1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-09 20:52:56 +01:00

Merge pull request #134 from aggepagge/master

Added functionality to display credit card types for user
This commit is contained in:
Hillel Coren 2014-06-18 12:28:31 +03:00
commit d2760c42f2
12 changed files with 776 additions and 672 deletions

View File

@ -228,7 +228,9 @@ class PaymentController extends \BaseController
return $data; return $data;
} }
} }
/** HÄR SKALL DET HÄMTAS UT BILDER!!!!! **/
public function show_payment($invitationKey) public function show_payment($invitationKey)
{ {
// For PayPal Express we redirect straight to their site // For PayPal Express we redirect straight to their site
@ -246,13 +248,16 @@ class PaymentController extends \BaseController
{ {
return self::do_payment($invitationKey, false); return self::do_payment($invitationKey, false);
} }
} }
$invitation = Invitation::with('invoice.invoice_items', 'invoice.client.currency', 'invoice.client.account.account_gateways.gateway')->where('invitation_key', '=', $invitationKey)->firstOrFail(); $invitation = Invitation::with('invoice.invoice_items', 'invoice.client.currency', 'invoice.client.account.account_gateways.gateway')->where('invitation_key', '=', $invitationKey)->firstOrFail();
$invoice = $invitation->invoice; $invoice = $invitation->invoice;
$client = $invoice->client; $client = $invoice->client;
$gateway = $invoice->client->account->account_gateways[0]->gateway; $gateway = $invoice->client->account->account_gateways[0]->gateway;
$paymentLibrary = $gateway->paymentlibrary; $paymentLibrary = $gateway->paymentlibrary;
$mask = $invoice->client->account->account_gateways[0]->accepted_credit_cards;
$acceptedCreditCardTypes = Utils::getCreditcardTypes($mask);
$data = [ $data = [
'showBreadcrumbs' => false, 'showBreadcrumbs' => false,
@ -261,8 +266,9 @@ class PaymentController extends \BaseController
'invoice' => $invoice, 'invoice' => $invoice,
'client' => $client, 'client' => $client,
'contact' => $invitation->contact, 'contact' => $invitation->contact,
'paymentLibrary' => $paymentLibrary , 'paymentLibrary' => $paymentLibrary,
'gateway' => $gateway, 'gateway' => $gateway,
'acceptedCreditCardTypes' => $acceptedCreditCardTypes,
'countries' => Country::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'countries' => Country::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
]; ];

View File

@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddAcceptedCreditCardsToAccountGateways extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('account_gateways', function($table)
{
$table->unsignedInteger('accepted_credit_cards')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('account_gateways', function($table)
{
$table->dropColumn('accepted_credit_cards');
});
}
}

View File

@ -0,0 +1,110 @@
<?php
/**
* Adds data to invitation for a user/client so that the
* public/payment/{aaabbb} page is accessable (aaabbb is the invitation_key)
**/
class SecurePaymentFormSeeder extends Seeder
{
public function run()
{
Eloquent::unguard();
//Delete table content
DB::table('invitations')->delete();
DB::table('invoices')->delete();
DB::table('contacts')->delete();
DB::table('clients')->delete();
DB::table('account_gateways')->delete();
//To reset the auto increment
$statement = "
ALTER TABLE invitations AUTO_INCREMENT = 1;
ALTER TABLE invoices AUTO_INCREMENT = 1;
ALTER TABLE contacts AUTO_INCREMENT = 1;
ALTER TABLE clients AUTO_INCREMENT = 1;
ALTER TABLE account_gateways AUTO_INCREMENT = 1;
";
DB::unprepared($statement);
$firstName = 'Oscar';
$lastName = 'Thompson';
$user = AccountGateway::create(array(
'account_id' => 1,
'user_id' => 1,
'gateway_id' => 4,
'config' => 'bla bla bla bla bla bla bla',
'public_id' => 1,
'accepted_credit_cards' => 18
));
$client = Client::create(array(
'user_id' => 1,
'account_id' => 1,
'currency_id' => 1,
'name' => $firstName.' '.$lastName,
'address1' => '2119 Howe Course',
'address2' => '2118 Howe Course',
'city' => 'West Chazport',
'state' => 'Utah',
'postal_code' => '31572',
'country_id' => 752,
'work_phone' => '012-345678',
'private_notes' => 'bla bla bla bla bla bla bla',
'balance' => 10.4,
'paid_to_date' => 10.2,
'website' => 'awebsite.com',
'industry_id' => 8,
'is_deleted' => 0,
'payment_terms' => 2,
'public_id' => 1,
'custom_value1' => $firstName,
'custom_value2' => $firstName
));
$contact = Contact::create(array(
'account_id' => 1,
'user_id' => 1,
'client_id' => 1,
'is_primary' => 0,
'send_invoice' => 0,
'first_name' => $firstName,
'last_name' => $lastName,
'email' => 'an@email.com',
'phone' => '012-345678',
'public_id' => 1
));
$invoice = Invoice::create(array(
'client_id' => 1,
'user_id' => 1,
'account_id' => 1,
'invoice_number' => 1,
'discount' => 0.4,
'po_number' => $firstName,
'terms' => 'bla bla bla bla bla bla bla',
'public_notes' => 'bla bla bla bla bla bla bla',
'is_deleted' => 0,
'is_recurring' => 0,
'frequency_id' => 1,
'tax_name' => 'moms',
'tax_rate' => 33.0,
'amount' => 10.0,
'balance' => 8.0,
'public_id' => 1,
'is_quote' => 0
));
$invitation = Invitation::create(array(
'account_id' => 1,
'user_id' => 1,
'contact_id' => 1,
'invoice_id' => 1,
'invitation_key' => 'aaabbb',
'transaction_reference' => 'bla bla bla bla bla bla bla',
'public_id' => 1
));
}
}

View File

@ -440,5 +440,41 @@ class Utils
} }
return $message; return $message;
} }
public static function getCreditcardTypes($mask)
{
$arrayOfImages = [];
$flags = [
CREDIT_CARD_VISA => ['card' => 'Visa', 'text' => 'Visa'],
CREDIT_CARD_MASTER_CARD => ['card' => 'MasterCard', 'text' => 'Master Card'],
CREDIT_CARD_AMERICAN_EXPRESS => ['card' => 'AmericanExpress', 'text' => 'American Express'],
CREDIT_CARD_DINERS => ['card' => 'Diners', 'text' => 'Diners'],
CREDIT_CARD_DISCOVER => ['card' => 'Discover', 'text' => 'Discover']
];
foreach ($flags as $card => $name)
{
if (($mask & $card) == $card)
$arrayOfImages[] = ['source' => asset('images/Test-'.$name['card'].'-Icon.png'), 'alt' => $name['text']];
}
//if($mask & CREDIT_CARD_VISA)
// array_push($arrayOfImages, ['source' => asset('images/Test-Visa-Icon.png'), 'alt' => 'Visa']);
//
// if($mask & CREDIT_CARD_MASTER_CARD)
// array_push($arrayOfImages, ['source' => asset('images/Test-MasterCard-Icon.png'), 'alt' => 'Master Card']);
//
// if($mask & CREDIT_CARD_AMERICAN_EXPRESS)
// array_push($arrayOfImages, ['source' => asset('images/Test-AmericanExpress-Icon.png'), 'alt' => 'American Express']);
//
// if($mask & CREDIT_CARD_DINERS)
// array_push($arrayOfImages, ['source' => asset('images/Test-Diners-Icon.png'), 'alt' => 'Diners']);
//
// if($mask & CREDIT_CARD_DISCOVER)
// array_push($arrayOfImages, ['source' => asset('images/Test-Discover-Icon.png'), 'alt' => 'Discover']);
return $arrayOfImages;
}
} }

View File

@ -229,6 +229,12 @@ define('GATEWAY_GOOGLE', 33);
define('GATEWAY_QUICKBOOKS', 35); define('GATEWAY_QUICKBOOKS', 35);
*/ */
/** TEST VALUES FOR THE CREDIT CARDS **/
define('CREDIT_CARD_VISA', 1);
define('CREDIT_CARD_MASTER_CARD', 2);
define('CREDIT_CARD_AMERICAN_EXPRESS', 4);
define('CREDIT_CARD_DINERS', 8);
define('CREDIT_CARD_DISCOVER', 16);
HTML::macro('nav_link', function($url, $text, $url2 = '', $extra = '') { HTML::macro('nav_link', function($url, $text, $url2 = '', $extra = '') {

View File

@ -41,6 +41,17 @@
</div> </div>
</section> </section>
<!-- Only set with inline style CHANGE THIS -->
<section class="accepted-card-types" style="padding: 10px 0 10px 0; margin-top: 40px;">
<div class="container">
@if(isset($acceptedCreditCardTypes))
@foreach ($acceptedCreditCardTypes as $card)
<img src="{{ $card['source'] }}" alt="{{ $card['alt'] }}" style="width: 100px; display: inline; margin-right: 20px;"/>
@endforeach
@endif
</div>
</section>
<section class="secure"> <section class="secure">
<div class="container"> <div class="container">
<div id="secure-form" class="row"> <div id="secure-form" class="row">

1233
composer.lock generated

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB