Added support for Bitcoin

This commit is contained in:
Hillel Coren 2015-04-15 19:35:41 +03:00
parent 868744c696
commit be327fbcbf
30 changed files with 348 additions and 235 deletions

View File

@ -153,7 +153,7 @@ class AccountController extends BaseController
if ($count == 0) {
return Redirect::to('gateways/create');
} else {
return View::make('accounts.payments', ['showAdd' => $count < 2]);
return View::make('accounts.payments', ['showAdd' => $count < 3]);
}
} elseif ($section == ACCOUNT_NOTIFICATIONS) {
$data = [

View File

@ -25,10 +25,11 @@ class AccountGatewayController extends BaseController
->join('gateways', 'gateways.id', '=', 'account_gateways.gateway_id')
->where('account_gateways.deleted_at', '=', null)
->where('account_gateways.account_id', '=', Auth::user()->account_id)
->select('account_gateways.public_id', 'gateways.name', 'account_gateways.deleted_at');
->select('account_gateways.public_id', 'gateways.name', 'account_gateways.deleted_at', 'account_gateways.gateway_id');
return Datatable::query($query)
->addColumn('name', function ($model) { return link_to('gateways/'.$model->public_id.'/edit', $model->name); })
->addColumn('payment_type', function ($model) { return Gateway::getPrettyPaymentType($model->gateway_id); })
->addColumn('dropdown', function ($model) {
$actions = '<div class="btn-group tr-action" style="visibility:hidden;">
<button type="button" class="btn btn-xs btn-default dropdown-toggle" data-toggle="dropdown">
@ -68,6 +69,7 @@ class AccountGatewayController extends BaseController
$data['method'] = 'PUT';
$data['title'] = trans('texts.edit_gateway') . ' - ' . $accountGateway->gateway->name;
$data['config'] = $configFields;
$data['paymentTypeId'] = $accountGateway->getPaymentType();
return View::make('accounts.account_gateway', $data);
}
@ -101,6 +103,17 @@ class AccountGatewayController extends BaseController
$selectedCards = $accountGateway ? $accountGateway->accepted_credit_cards : 0;
$account = Auth::user()->account;
$paymentTypes = [];
foreach ([PAYMENT_TYPE_CREDIT_CARD, PAYMENT_TYPE_PAYPAL, PAYMENT_TYPE_BITCOIN] as $type) {
if ($accountGateway || !$account->getGatewayByType($type)) {
$paymentTypes[$type] = trans('texts.'.strtolower($type));
if ($type == PAYMENT_TYPE_BITCOIN) {
$paymentTypes[$type] .= ' - BitPay';
}
}
}
$creditCardsArray = unserialize(CREDIT_CARDS);
$creditCards = [];
foreach ($creditCardsArray as $card => $name) {
@ -113,25 +126,11 @@ class AccountGatewayController extends BaseController
$account->load('account_gateways');
$currentGateways = $account->account_gateways;
$gateways = Gateway::where('payment_library_id', '=', 1)->orderBy('name');
$onlyPayPal = false;
if (!$accountGateway) {
if (count($currentGateways) > 0) {
$currentGateway = $currentGateways[0];
if ($currentGateway->isPayPal()) {
$gateways->where('id', '!=', GATEWAY_PAYPAL_EXPRESS);
} else {
$gateways->where('id', '=', GATEWAY_PAYPAL_EXPRESS);
$onlyPayPal = true;
}
}
}
$gateways = $gateways->get();
$gateways = Gateway::where('payment_library_id', '=', 1)->orderBy('name')->get();
$selectGateways = Gateway::where('payment_library_id', '=', 1)->where('id', '!=', GATEWAY_PAYPAL_EXPRESS)->where('id', '!=', GATEWAY_PAYPAL_EXPRESS)->orderBy('name')->get();
foreach ($gateways as $gateway) {
$paymentLibrary = $gateway->paymentlibrary;
$gateway->fields = $gateway->getFields();
if ($accountGateway && $accountGateway->gateway_id == $gateway->id) {
$accountGateway->fields = $gateway->fields;
}
@ -143,14 +142,15 @@ class AccountGatewayController extends BaseController
}
return [
'paymentTypes' => $paymentTypes,
'account' => $account,
'accountGateway' => $accountGateway,
'config' => false,
'gateways' => $gateways,
'selectGateways' => $selectGateways,
'creditCardTypes' => $creditCards,
'tokenBillingOptions' => $tokenBillingOptions,
'showBreadcrumbs' => false,
'onlyPayPal' => $onlyPayPal,
'countGateways' => count($currentGateways)
];
}
@ -183,7 +183,6 @@ class AccountGatewayController extends BaseController
}
$gateway = Gateway::findOrFail($gatewayId);
$paymentLibrary = $gateway->paymentlibrary;
$fields = $gateway->getFields();
foreach ($fields as $field => $details) {

View File

@ -176,6 +176,7 @@ class InvoiceController extends BaseController
$invoice->load('user', 'invoice_items', 'invoice_design', 'account.country', 'client.contacts', 'client.country');
$client = $invoice->client;
$account = $client->account;
if (!$client || $client->is_deleted) {
return View::make('invoices.deleted');
@ -188,13 +189,13 @@ class InvoiceController extends BaseController
Session::set($invitationKey, true);
Session::set('invitation_key', $invitationKey);
Session::set('white_label', $client->account->isWhiteLabel());
Session::set('white_label', $account->isWhiteLabel());
$client->account->loadLocalizationSettings();
$account->loadLocalizationSettings();
$invoice->invoice_date = Utils::fromSqlDate($invoice->invoice_date);
$invoice->due_date = Utils::fromSqlDate($invoice->due_date);
$invoice->is_pro = $client->account->isPro();
$invoice->is_pro = $account->isPro();
$contact = $invitation->contact;
$contact->setVisible([
@ -203,16 +204,30 @@ class InvoiceController extends BaseController
'email',
'phone', ]);
// Determine payment options
$paymentTypes = [];
if ($client->getGatewayToken()) {
$paymentTypes[] = [
'url' => URL::to("payment/{$invitation->invitation_key}/".PAYMENT_TYPE_TOKEN), 'label' => trans('texts.use_card_on_file')
];
}
foreach([PAYMENT_TYPE_CREDIT_CARD, PAYMENT_TYPE_PAYPAL, PAYMENT_TYPE_BITCOIN] as $type) {
if ($account->getGatewayByType($type)) {
$paymentTypes[] = [
'url' => URL::to("/payment/{$invitation->invitation_key}/{$type}"), 'label' => trans('texts.'.strtolower($type))
];
}
}
$data = array(
'isConverted' => $invoice->quote_invoice_id ? true : false,
'showBreadcrumbs' => false,
'hideLogo' => $client->account->isWhiteLabel(),
'hideLogo' => $account->isWhiteLabel(),
'invoice' => $invoice->hidePrivateFields(),
'invitation' => $invitation,
'invoiceLabels' => $client->account->getInvoiceLabels(),
'invoiceLabels' => $account->getInvoiceLabels(),
'contact' => $contact,
'hasToken' => $client->getGatewayToken(),
'countGateways' => AccountGateway::scope(false, $client->account->id)->count(),
'paymentTypes' => $paymentTypes
);
return View::make('invoices.view', $data);

View File

@ -3,6 +3,7 @@
use Datatable;
use Input;
use Redirect;
use Request;
use Session;
use Utils;
use View;
@ -11,12 +12,15 @@ use Omnipay;
use CreditCard;
use URL;
use Cache;
use Event;
use App\Models\Invoice;
use App\Models\Invitation;
use App\Models\Client;
use App\Models\PaymentType;
use App\Models\Country;
use App\Models\License;
use App\Models\Payment;
use App\Models\AccountGatewayToken;
use App\Ninja\Repositories\PaymentRepository;
use App\Ninja\Repositories\InvoiceRepository;
use App\Ninja\Repositories\AccountRepository;
@ -244,116 +248,57 @@ class PaymentController extends BaseController
$invoice = $invitation->invoice;
$key = $invoice->invoice_number.'_details';
$gateway = $invoice->client->account->getGatewayByType(Session::get('payment_type'))->gateway;
$paymentLibrary = $gateway->paymentlibrary;
$currencyCode = $invoice->client->currency ? $invoice->client->currency->code : ($invoice->account->currency ? $invoice->account->currency->code : 'USD');
if ($input && $paymentLibrary->id == PAYMENT_LIBRARY_OMNIPAY) {
if ($input) {
$data = self::convertInputForOmnipay($input);
Session::put($key, $data);
} elseif ($input && $paymentLibrary->id == PAYMENT_LIBRARY_PHP_PAYMENTS) {
$input = Input::all();
$data = [
'first_name' => $input['first_name'],
'last_name' => $input['last_name'],
'cc_number' => $input['card_number'],
'cc_exp' => $input['expiration_month'].$input['expiration_year'],
'cc_code' => $input['cvv'],
'street' => $input['address1'],
'street2' => $input['address2'],
'city' => $input['city'],
'state' => $input['state'],
'postal_code' => $input['postal_code'],
'amt' => $invoice->balance,
'ship_to_street' => $input['address1'],
'ship_to_city' => $input['city'],
'ship_to_state' => $input['state'],
'ship_to_postal_code' => $input['postal_code'],
'currency_code' => $currencyCode,
];
switch ($gateway->id) {
case GATEWAY_BEANSTREAM:
$data['phone'] = $input['phone'];
$data['email'] = $input['email'];
$data['country'] = $input['country'];
$data['ship_to_country'] = $input['country'];
break;
case GATEWAY_BRAINTREE:
$data['ship_to_state'] = 'Ohio'; //$input['state'];
break;
}
if (strlen($data['cc_exp']) == 5) {
$data['cc_exp'] = '0'.$data['cc_exp'];
}
Session::put($key, $data);
return $data;
} elseif (Session::get($key)) {
$data = Session::get($key);
} else {
$data = [];
}
if ($paymentLibrary->id == PAYMENT_LIBRARY_OMNIPAY) {
$card = new CreditCard($data);
$card = new CreditCard($data);
return [
'amount' => $invoice->balance,
'card' => $card,
'currency' => $currencyCode,
'returnUrl' => URL::to('complete'),
'cancelUrl' => $invitation->getLink(),
'description' => trans('texts.' . $invoice->getEntityType()) . " {$invoice->invoice_number}",
];
} else {
return $data;
}
return [
'amount' => $invoice->balance,
'card' => $card,
'currency' => $currencyCode,
'returnUrl' => URL::to('complete'),
'cancelUrl' => $invitation->getLink(),
'description' => trans('texts.' . $invoice->getEntityType()) . " {$invoice->invoice_number}",
];
}
public function show_payment($invitationKey)
{
// Handle token billing
if (Input::get('use_token') == 'true') {
return self::do_payment($invitationKey, false, true);
}
public function show_payment($invitationKey, $paymentType = false)
{
$invitation = Invitation::with('invoice.invoice_items', 'invoice.client.currency', 'invoice.client.account.account_gateways.gateway')->where('invitation_key', '=', $invitationKey)->firstOrFail();
$invoice = $invitation->invoice;
$client = $invoice->client;
$account = $client->account;
$useToken = false;
if (Input::has('use_paypal')) {
Session::put('payment_type', Input::get('use_paypal') == 'true' ? PAYMENT_TYPE_PAYPAL : PAYMENT_TYPE_CREDIT_CARD);
} elseif (!Session::has('payment_type')) {
Session::put('payment_type', PAYMENT_TYPE_ANY);
if (!$paymentType) {
$paymentType = $account->account_gateways[0]->getPaymentType();
} else if ($paymentType == PAYMENT_TYPE_TOKEN) {
$useToken = true;
$paymentType = PAYMENT_TYPE_CREDIT_CARD;
}
Session::put('payment_type', $paymentType);
// For PayPal we redirect straight to their site
$usePayPal = false;
if ($usePayPal = Input::get('use_paypal')) {
$usePayPal = $usePayPal == 'true';
} else {
$invitation = Invitation::with('invoice.client.account', 'invoice.client.account.account_gateways.gateway')->where('invitation_key', '=', $invitationKey)->firstOrFail();
$account = $invitation->invoice->client->account;
if (count($account->account_gateways) == 1 && $account->getGatewayByType(PAYMENT_TYPE_PAYPAL)) {
$usePayPal = true;
}
}
if ($usePayPal) {
// Handle offsite payments
if ($useToken || $paymentType != PAYMENT_TYPE_CREDIT_CARD) {
if (Session::has('error')) {
Session::reflash();
return Redirect::to('view/'.$invitationKey);
} else {
return self::do_payment($invitationKey, false);
return self::do_payment($invitationKey, false, $useToken);
}
} else {
Session::put('payment_type', PAYMENT_TYPE_ANY);
}
}
$invitation = Invitation::with('invoice.invoice_items', 'invoice.client.currency', 'invoice.client.account.account_gateways.gateway')->where('invitation_key', '=', $invitationKey)->firstOrFail();
$invoice = $invitation->invoice;
$client = $invoice->client;
$accountGateway = $invoice->client->account->getGatewayByType(Session::get('payment_type'));
$gateway = $invoice->client->account->getGatewayByType(Session::get('payment_type'))->gateway;
$paymentLibrary = $gateway->paymentlibrary;
$accountGateway = $invoice->client->account->getGatewayByType($paymentType);
$gateway = $accountGateway->gateway;
$acceptedCreditCardTypes = $accountGateway->getCreditcardTypes();
$data = [
@ -363,7 +308,6 @@ class PaymentController extends BaseController
'invoiceNumber' => $invoice->invoice_number,
'client' => $client,
'contact' => $invitation->contact,
'paymentLibrary' => $paymentLibrary,
'gateway' => $gateway,
'acceptedCreditCardTypes' => $acceptedCreditCardTypes,
'countries' => Cache::get('countries'),
@ -400,7 +344,6 @@ class PaymentController extends BaseController
$account->load('account_gateways.gateway');
$accountGateway = $account->getGatewayByType(Session::get('payment_type'));
$gateway = $accountGateway->gateway;
$paymentLibrary = $gateway->paymentlibrary;
$acceptedCreditCardTypes = $accountGateway->getCreditcardTypes();
$affiliate = Affiliate::find(Session::get('affiliate_id'));
@ -412,7 +355,6 @@ class PaymentController extends BaseController
'amount' => $affiliate->price,
'client' => false,
'contact' => false,
'paymentLibrary' => $paymentLibrary,
'gateway' => $gateway,
'acceptedCreditCardTypes' => $acceptedCreditCardTypes,
'countries' => Cache::get('countries'),
@ -563,8 +505,7 @@ class PaymentController extends BaseController
$client = $invoice->client;
$account = $client->account;
$accountGateway = $account->getGatewayByType(Session::get('payment_type'));
$paymentLibrary = $accountGateway->gateway->paymentlibrary;
/*
if ($onSite) {
$client->address1 = trim(Input::get('address1'));
@ -577,65 +518,63 @@ class PaymentController extends BaseController
*/
try {
if ($paymentLibrary->id == PAYMENT_LIBRARY_OMNIPAY) {
$gateway = self::createGateway($accountGateway);
$details = self::getPaymentDetails($invitation, $useToken || !$onSite ? false : Input::all());
if ($accountGateway->gateway_id == GATEWAY_STRIPE) {
if ($useToken) {
$details['cardReference'] = $client->getGatewayToken();
} elseif ($account->token_billing_type_id == TOKEN_BILLING_ALWAYS || Input::get('token_billing')) {
$tokenResponse = $gateway->createCard($details)->send();
$cardReference = $tokenResponse->getCardReference();
$details['cardReference'] = $cardReference;
$gateway = self::createGateway($accountGateway);
$details = self::getPaymentDetails($invitation, $useToken || !$onSite ? false : Input::all());
if ($accountGateway->gateway_id == GATEWAY_STRIPE) {
if ($useToken) {
$details['cardReference'] = $client->getGatewayToken();
} elseif ($account->token_billing_type_id == TOKEN_BILLING_ALWAYS || Input::get('token_billing')) {
$tokenResponse = $gateway->createCard($details)->send();
$cardReference = $tokenResponse->getCardReference();
$details['cardReference'] = $cardReference;
$token = AccountGatewayToken::where('client_id', '=', $client->id)
->where('account_gateway_id', '=', $accountGateway->id)->first();
$token = AccountGatewayToken::where('client_id', '=', $client->id)
->where('account_gateway_id', '=', $accountGateway->id)->first();
if (!$token) {
$token = new AccountGatewayToken();
$token->account_id = $account->id;
$token->contact_id = $invitation->contact_id;
$token->account_gateway_id = $accountGateway->id;
$token->client_id = $client->id;
}
$token->token = $cardReference;
$token->save();
if (!$token) {
$token = new AccountGatewayToken();
$token->account_id = $account->id;
$token->contact_id = $invitation->contact_id;
$token->account_gateway_id = $accountGateway->id;
$token->client_id = $client->id;
}
$token->token = $cardReference;
$token->save();
}
}
$response = $gateway->purchase($details)->send();
$ref = $response->getTransactionReference();
if (!$ref) {
$response = $gateway->purchase($details)->send();
$ref = $response->getTransactionReference();
Session::flash('error', $response->getMessage());
if (!$ref) {
Session::flash('error', $response->getMessage());
if ($onSite) {
return Redirect::to('payment/'.$invitationKey)->withInput();
} else {
return Redirect::to('view/'.$invitationKey);
}
}
if ($response->isSuccessful()) {
$payment = self::createPayment($invitation, $ref);
Session::flash('message', trans('texts.applied_payment'));
return Redirect::to('view/'.$payment->invitation->invitation_key);
} elseif ($response->isRedirect()) {
$invitation->transaction_reference = $ref;
$invitation->save();
Session::save();
$response->redirect();
if ($onSite) {
return Redirect::to('payment/'.$invitationKey)->withInput();
} else {
Session::flash('error', $response->getMessage());
return Utils::fatalError('Sorry, there was an error processing your payment. Please try again later.<p>', $response->getMessage());
return Redirect::to('view/'.$invitationKey);
}
}
if ($response->isSuccessful()) {
$payment = self::createPayment($invitation, $ref);
Session::flash('message', trans('texts.applied_payment'));
return Redirect::to('view/'.$payment->invitation->invitation_key);
} elseif ($response->isRedirect()) {
$invitation->transaction_reference = $ref;
$invitation->save();
Session::save();
$response->redirect();
} else {
Session::flash('error', $response->getMessage());
return Utils::fatalError('Sorry, there was an error processing your payment. Please try again later.<p>', $response->getMessage());
}
} catch (\Exception $e) {
$errorMessage = trans('texts.payment_error');
Session::flash('error', $errorMessage."<p>".$e->getMessage());

View File

@ -10,7 +10,7 @@ use Cache;
use Session;
use Event;
use App\Models\Language;
use App\Events\UserSettingsChanged;
class StartupCheck
{

View File

@ -36,7 +36,7 @@ Route::post('get_started', 'AccountController@getStarted');
// Client visible pages
Route::get('view/{invitation_key}', 'InvoiceController@view');
Route::get('approve/{invitation_key}', 'QuoteController@approve');
Route::get('payment/{invitation_key}', 'PaymentController@show_payment');
Route::get('payment/{invitation_key}/{payment_type?}', 'PaymentController@show_payment');
Route::post('payment/{invitation_key}', 'PaymentController@do_payment');
Route::get('complete', 'PaymentController@offsite_payment');
Route::get('client/quotes', 'QuoteController@clientIndex');
@ -336,6 +336,7 @@ define('GATEWAY_TWO_CHECKOUT', 27);
define('GATEWAY_BEANSTREAM', 29);
define('GATEWAY_PSIGATE', 30);
define('GATEWAY_MOOLAH', 31);
define('GATEWAY_BITPAY', 42);
define('EVENT_CREATE_CLIENT', 1);
define('EVENT_CREATE_INVOICE', 2);
@ -378,6 +379,8 @@ define('TOKEN_BILLING_ALWAYS', 4);
define('PAYMENT_TYPE_PAYPAL', 'PAYMENT_TYPE_PAYPAL');
define('PAYMENT_TYPE_CREDIT_CARD', 'PAYMENT_TYPE_CREDIT_CARD');
define('PAYMENT_TYPE_BITCOIN', 'PAYMENT_TYPE_BITCOIN');
define('PAYMENT_TYPE_TOKEN', 'PAYMENT_TYPE_TOKEN');
define('PAYMENT_TYPE_ANY', 'PAYMENT_TYPE_ANY');
/*

View File

@ -31,8 +31,10 @@ class HandleInvoicePaid {
*/
public function handle(InvoicePaid $event)
{
$this->contactMailer->sendPaymentConfirmation($payment);
$payment = $event->payment;
$invoice = $payment->invoice;
$this->contactMailer->sendPaymentConfirmation($payment);
foreach ($invoice->account->users as $user)
{

View File

@ -113,9 +113,7 @@ class Account extends Eloquent
foreach ($this->account_gateways as $gateway) {
if (!$type || $type == PAYMENT_TYPE_ANY) {
return $gateway;
} elseif ($gateway->isPayPal() && $type == PAYMENT_TYPE_PAYPAL) {
return $gateway;
} elseif (!$gateway->isPayPal() && $type == PAYMENT_TYPE_CREDIT_CARD) {
} elseif ($gateway->isPaymentType($type)) {
return $gateway;
}
}

View File

@ -1,5 +1,6 @@
<?php namespace App\Models;
use App\Models\Gateway;
use Illuminate\Database\Eloquent\SoftDeletes;
class AccountGateway extends EntityModel
@ -26,8 +27,12 @@ class AccountGateway extends EntityModel
return $arrayOfImages;
}
public function isPayPal() {
return $this->gateway_id == GATEWAY_PAYPAL_EXPRESS;
public function getPaymentType() {
return Gateway::getPaymentType($this->gateway_id);
}
public function isPaymentType($type) {
return $this->getPaymentType() == $type;
}
}

View File

@ -7,11 +7,6 @@ class Gateway extends Eloquent
{
public $timestamps = true;
public function paymentlibrary()
{
return $this->belongsTo('\App\Models\PaymentLibrary', 'payment_library_id');
}
public function getLogoUrl()
{
return '/images/gateways/logo_'.$this->provider.'.png';
@ -37,18 +32,20 @@ class Gateway extends Eloquent
public function getFields()
{
$paymentLibrary = $this->paymentlibrary;
return Omnipay::create($this->provider)->getDefaultParameters();
}
if ($paymentLibrary->id == PAYMENT_LIBRARY_OMNIPAY) {
$fields = Omnipay::create($this->provider)->getDefaultParameters();
public static function getPaymentType($gatewayId) {
if ($gatewayId == GATEWAY_PAYPAL_EXPRESS) {
return PAYMENT_TYPE_PAYPAL;
} else if ($gatewayId == GATEWAY_BITPAY) {
return PAYMENT_TYPE_BITCOIN;
} else {
$fields = Payment_Utility::load('config', 'drivers/'.strtolower($this->provider));
return PAYMENT_TYPE_CREDIT_CARD;
}
}
if ($fields == null) {
$fields = array();
}
return $fields;
public static function getPrettyPaymentType($gatewayId) {
return trans('texts.' . strtolower(Gateway::getPaymentType($gatewayId)));
}
}

View File

@ -33,7 +33,8 @@
"coatesap/omnipay-realex": "~2.0",
"fruitcakestudio/omnipay-sisow": "~2.0",
"alfaproject/omnipay-skrill": "dev-master",
"illuminate/html": "5.*"
"illuminate/html": "5.*",
"omnipay/bitpay": "dev-master"
},
"require-dev": {
"phpunit/phpunit": "~4.0",

73
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "f464570c808999ffcb0fa78193b13229",
"hash": "4093891914bbd46ffab78737da36898a",
"packages": [
{
"name": "alfaproject/omnipay-neteller",
@ -2346,6 +2346,64 @@
],
"time": "2015-01-19 19:06:04"
},
{
"name": "omnipay/bitpay",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/omnipay-bitpay.git",
"reference": "e659f0e993c586cb36acafaf50835570b4a16eb2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/omnipay-bitpay/zipball/e659f0e993c586cb36acafaf50835570b4a16eb2",
"reference": "e659f0e993c586cb36acafaf50835570b4a16eb2",
"shasum": ""
},
"require": {
"omnipay/common": "~2.0"
},
"require-dev": {
"omnipay/tests": "~2.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Omnipay\\BitPay\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Adrian Macneil",
"email": "adrian@adrianmacneil.com"
},
{
"name": "Omnipay Contributors",
"homepage": "https://github.com/thephpleague/omnipay-bitpay/contributors"
}
],
"description": "BitPay driver for the Omnipay payment processing library",
"homepage": "https://github.com/thephpleague/omnipay-bitpay",
"keywords": [
"bitcoin",
"bitpay",
"gateway",
"merchant",
"omnipay",
"pay",
"payment"
],
"time": "2015-03-23 14:18:26"
},
{
"name": "omnipay/buckaroo",
"version": "v2.0.1",
@ -3730,16 +3788,16 @@
},
{
"name": "omnipay/stripe",
"version": "v2.2.0",
"version": "v2.2.1",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/omnipay-stripe.git",
"reference": "b3ed1028bb72837905012311fa74259d9ed8ba3c"
"reference": "906377e50045dc2ba9c612aa1f6924157e1f750e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/omnipay-stripe/zipball/b3ed1028bb72837905012311fa74259d9ed8ba3c",
"reference": "b3ed1028bb72837905012311fa74259d9ed8ba3c",
"url": "https://api.github.com/repos/thephpleague/omnipay-stripe/zipball/906377e50045dc2ba9c612aa1f6924157e1f750e",
"reference": "906377e50045dc2ba9c612aa1f6924157e1f750e",
"shasum": ""
},
"require": {
@ -3783,7 +3841,7 @@
"payment",
"stripe"
],
"time": "2015-03-16 19:24:07"
"time": "2015-04-14 18:55:56"
},
{
"name": "omnipay/targetpay",
@ -6115,7 +6173,8 @@
"webpatser/laravel-countries": 20,
"lokielse/omnipay-alipay": 20,
"alfaproject/omnipay-neteller": 20,
"alfaproject/omnipay-skrill": 20
"alfaproject/omnipay-skrill": 20,
"omnipay/bitpay": 20
},
"prefer-stable": false,
"prefer-lowest": false,

View File

@ -22,7 +22,8 @@ class PaymentLibrariesSeeder extends Seeder
['name' => 'PaymentSense', 'provider' => 'PaymentSense', 'payment_library_id' => 1],
['name' => 'Realex', 'provider' => 'Realex_Remote', 'payment_library_id' => 1],
['name' => 'Sisow', 'provider' => 'Sisow', 'payment_library_id' => 1],
['name' => 'Skrill', 'provider' => 'Skrill', 'payment_library_id' => 1]
['name' => 'Skrill', 'provider' => 'Skrill', 'payment_library_id' => 1],
['name' => 'BitPay', 'provider' => 'BitPay', 'payment_library_id' => 1],
];
foreach ($gateways as $gateway)

View File

@ -586,5 +586,10 @@ return array(
'notification_quote_approved' => 'The following client :client approved Quote :invoice for :amount.',
'resend_confirmation' => 'Resend confirmation email',
'confirmation_resent' => 'The confirmation email was resent',
'gateway_help_42' => 'Note: use a BitPay Legacy API Key, not an API token.',
'payment_type_credit_card' => 'Credit card',
'payment_type_paypal' => 'PayPal',
'payment_type_bitcoin' => 'Bitcoin',
);

View File

@ -577,4 +577,11 @@ return array(
'notification_quote_approved' => 'Der folgende Kunde :client nahm das Angebot :invoice über :amount an.',
'resend_confirmation' => 'Bestätigungsmail erneut senden',
'confirmation_resent' => 'Bestätigungsemail wurde erneut gesendet',
'gateway_help_42' => 'Note: use a BitPay Legacy API Key, not an API token.',
'payment_type_credit_card' => 'Credit card',
'payment_type_paypal' => 'PayPal',
'payment_type_bitcoin' => 'Bitcoin',
);

View File

@ -173,7 +173,7 @@ return array(
'are_you_sure' => 'Are you sure?',
// payment pages
'payment_type_id' => 'Payment type',
'payment_type_id' => 'Payment Type',
'amount' => 'Amount',
// account/company pages
@ -187,7 +187,7 @@ return array(
'remove_logo' => 'Remove logo',
'logo_help' => 'Supported: JPEG, GIF and PNG. Recommended size: 200px width by 120px height',
'payment_gateway' => 'Payment Gateway',
'gateway_id' => 'Provider',
'gateway_id' => 'Gateway',
'email_notifications' => 'Email Notifications',
'email_sent' => 'Email me when an invoice is <b>sent</b>',
'email_viewed' => 'Email me when an invoice is <b>viewed</b>',
@ -585,5 +585,9 @@ return array(
'resend_confirmation' => 'Resend confirmation email',
'confirmation_resent' => 'The confirmation email was resent',
'gateway_help_42' => 'Note: use a BitPay Legacy API Key, not an API token.',
'payment_type_credit_card' => 'Credit card',
'payment_type_paypal' => 'PayPal',
'payment_type_bitcoin' => 'Bitcoin',
);

View File

@ -556,7 +556,12 @@ return array(
'notification_quote_approved' => 'The following client :client approved Quote :invoice for :amount.',
'resend_confirmation' => 'Resend confirmation email',
'confirmation_resent' => 'The confirmation email was resent',
'gateway_help_42' => 'Note: use a BitPay Legacy API Key, not an API token.',
'payment_type_credit_card' => 'Credit card',
'payment_type_paypal' => 'PayPal',
'payment_type_bitcoin' => 'Bitcoin',
);

View File

@ -580,5 +580,16 @@ return array(
'Whoops, looks like something went wrong.' => 'Vaya, parece que algo salió mal',
'Sorry, the page you are looking for could not be found.' => 'Lo sentimos, la página que está buscando no se pudo encontrar.',
'email_approved' => 'Email me when a quote is <b>approved</b>',
'notification_quote_approved_subject' => 'Quote :invoice was approved by :client',
'notification_quote_approved' => 'The following client :client approved Quote :invoice for :amount.',
'resend_confirmation' => 'Resend confirmation email',
'confirmation_resent' => 'The confirmation email was resent',
'gateway_help_42' => 'Note: use a BitPay Legacy API Key, not an API token.',
'payment_type_credit_card' => 'Credit card',
'payment_type_paypal' => 'PayPal',
'payment_type_bitcoin' => 'Bitcoin',
);

View File

@ -578,5 +578,10 @@ return array(
'resend_confirmation' => 'Resend confirmation email',
'confirmation_resent' => 'The confirmation email was resent',
'gateway_help_42' => 'Note: use a BitPay Legacy API Key, not an API token.',
'payment_type_credit_card' => 'Credit card',
'payment_type_paypal' => 'PayPal',
'payment_type_bitcoin' => 'Bitcoin',
);

View File

@ -580,5 +580,10 @@ return array(
'resend_confirmation' => 'Resend confirmation email',
'confirmation_resent' => 'The confirmation email was resent',
'gateway_help_42' => 'Note: use a BitPay Legacy API Key, not an API token.',
'payment_type_credit_card' => 'Credit card',
'payment_type_paypal' => 'PayPal',
'payment_type_bitcoin' => 'Bitcoin',
);

View File

@ -587,6 +587,11 @@ return array(
'notification_quote_approved' => 'The following client :client approved Quote :invoice for :amount.',
'resend_confirmation' => 'Resend confirmation email',
'confirmation_resent' => 'The confirmation email was resent',
'gateway_help_42' => 'Note: use a BitPay Legacy API Key, not an API token.',
'payment_type_credit_card' => 'Credit card',
'payment_type_paypal' => 'PayPal',
'payment_type_bitcoin' => 'Bitcoin',

View File

@ -586,5 +586,10 @@ return array(
'resend_confirmation' => 'Resend confirmation email',
'confirmation_resent' => 'The confirmation email was resent',
'gateway_help_42' => 'Note: use a BitPay Legacy API Key, not an API token.',
'payment_type_credit_card' => 'Credit card',
'payment_type_paypal' => 'PayPal',
'payment_type_bitcoin' => 'Bitcoin',
);

View File

@ -580,6 +580,11 @@ return array(
'notification_quote_approved' => 'The following client :client approved Quote :invoice for :amount.',
'resend_confirmation' => 'Resend confirmation email',
'confirmation_resent' => 'The confirmation email was resent',
'gateway_help_42' => 'Note: use a BitPay Legacy API Key, not an API token.',
'payment_type_credit_card' => 'Credit card',
'payment_type_paypal' => 'PayPal',
'payment_type_bitcoin' => 'Bitcoin',

View File

@ -580,6 +580,11 @@ return array(
'notification_quote_approved' => 'The following client :client approved Quote :invoice for :amount.',
'resend_confirmation' => 'Resend confirmation email',
'confirmation_resent' => 'The confirmation email was resent',
'gateway_help_42' => 'Note: use a BitPay Legacy API Key, not an API token.',
'payment_type_credit_card' => 'Credit card',
'payment_type_paypal' => 'PayPal',
'payment_type_bitcoin' => 'Bitcoin',
);

View File

@ -583,6 +583,11 @@ return array(
'notification_quote_approved' => 'The following client :client approved Quote :invoice for :amount.',
'resend_confirmation' => 'Resend confirmation email',
'confirmation_resent' => 'The confirmation email was resent',
'gateway_help_42' => 'Note: use a BitPay Legacy API Key, not an API token.',
'payment_type_credit_card' => 'Credit card',
'payment_type_paypal' => 'PayPal',
'payment_type_bitcoin' => 'Bitcoin',
);

View File

@ -9,8 +9,9 @@
{!! Former::legend($title) !!}
@if ($accountGateway)
{!! Former::populateField('payment_type_id', $paymentTypeId) !!}
{!! Former::populateField('gateway_id', $accountGateway->gateway_id) !!}
{!! Former::populateField('recommendedGateway_id', $accountGateway->gateway_id) !!}
{!! Former::populateField('recommendedGateway_id', $accountGateway->gateway_id) !!}
@if ($config)
@foreach ($accountGateway->fields as $field => $junk)
@if (in_array($field, ['solutionType', 'landingPage', 'headerImageUrl', 'brandName']))
@ -21,12 +22,17 @@
@endforeach
@endif
@endif
{!! Former::select('gateway_id')->label('Select Gateway')->addOption('', '')
{!! Former::select('payment_type_id')
->options($paymentTypes)
->addGroupClass('payment-type-option')
->onchange('setPaymentType()') !!}
{!! Former::select('gateway_id')->addOption('', '')
->dataClass('gateway-dropdown')
->fromQuery($gateways, 'name', 'id')
->onchange('setFieldsShown()'); !!}
->addGroupClass('gateway-option')
->fromQuery($selectGateways, 'name', 'id')
->onchange('setFieldsShown()') !!}
@foreach ($gateways as $gateway)
@ -61,8 +67,11 @@
@endforeach
{!! Former::checkboxes('creditCardTypes[]')->label('Accepted Credit Cards')
->checkboxes($creditCardTypes)->class('creditcard-types')
{!! Former::checkboxes('creditCardTypes[]')
->label('Accepted Credit Cards')
->checkboxes($creditCardTypes)
->class('creditcard-types')
->addGroupClass('gateway-option')
!!}
@ -76,8 +85,27 @@
<script type="text/javascript">
function setFieldsShown() {
var val = $('#gateway_id').val();
function setPaymentType() {
var val = $('#payment_type_id').val();
if (val == 'PAYMENT_TYPE_CREDIT_CARD') {
$('.gateway-option').show();
setFieldsShown();
} else {
$('.gateway-option').hide();
if (val == 'PAYMENT_TYPE_PAYPAL') {
setFieldsShown({{ GATEWAY_PAYPAL_EXPRESS }});
} else {
setFieldsShown({{ GATEWAY_BITPAY }});
}
}
}
function setFieldsShown(val) {
if (!val) {
val = $('#gateway_id').val();
}
$('.gateway-fields').hide();
$('#gateway_' + val + '_div').show();
}
@ -89,6 +117,13 @@
}
}
$(function() {
setPaymentType();
@if ($accountGateway)
$('.payment-type-option').hide();
@endif
})
</script>
@stop

View File

@ -16,20 +16,20 @@
{!! Button::success(trans('texts.add_gateway'))
->asLinkTo('/gateways/create')
->withAttributes(['class' => 'pull-right'])
->appendIcon(Icon::create('plus-sign'))
->large() !!}
->appendIcon(Icon::create('plus-sign')) !!}
@endif
{!! Datatable::table()
->addColumn(
trans('texts.name'),
trans('texts.payment_type_id'),
trans('texts.action'))
->setUrl(url('api/gateways/'))
->setOptions('sPaginationType', 'bootstrap')
->setOptions('bFilter', false)
->setOptions('bAutoWidth', false)
->setOptions('aoColumns', [[ "sWidth"=> "80%" ], ["sWidth"=> "20%"]])
->setOptions('aoColumnDefs', [['bSortable'=>false, 'aTargets'=>[1]]])
->setOptions('aoColumns', [[ "sWidth"=> "50%" ], [ "sWidth"=> "30%" ], ["sWidth"=> "20%"]])
->setOptions('aoColumnDefs', [['bSortable'=>false, 'aTargets'=>[2]]])
->render('datatable') !!}
<script>

View File

@ -28,19 +28,11 @@
@endif
@elseif ($invoice->client->account->isGatewayConfigured() && !$invoice->isPaid() && !$invoice->is_recurring)
{!! Button::normal(trans('texts.download_pdf'))->withAttributes(['onclick' => 'onDownloadClick()'])->large() !!}&nbsp;&nbsp;
@if ($hasToken)
{!! DropdownButton::success_lg(trans('texts.pay_now'), [
['url' => URL::to("payment/{$invitation->invitation_key}?use_token=true&use_paypal=false"), 'label' => trans('texts.use_card_on_file')],
['url' => URL::to("payment/{$invitation->invitation_key}?use_paypal=false"), 'label' => trans('texts.edit_payment_details')]
])->addClass('btn-lg') !!}
@elseif ($countGateways == 2)
{!! DropdownButton::success_lg(trans('texts.pay_now'), [
['url' => URL::to("payment/{$invitation->invitation_key}?use_paypal=true"), 'label' => trans('texts.pay_with_paypal')],
['url' => URL::to("payment/{$invitation->invitation_key}?use_paypal=false"), 'label' => trans('texts.pay_with_card')]
])->addClass('btn-lg') !!}
@if (count($paymentTypes) > 1)
{!! DropdownButton::success(trans('texts.pay_now'))->withContents($paymentTypes)->large() !!}
@else
{!! Button::success(trans('texts.pay_now'))->asLinkTo('/payment/' . $invitation->invitation_key)->large() !!}
@endif
{!! Button::success(trans('texts.pay_now'))->asLinkTo('/payment/' . $invitation->invitation_key)->large() !!}
@endif
@else
{!! Button::normal('Download PDF')->withAttributes(['onclick' => 'onDownloadClick()'])->large() !!}
@endif

View File

@ -262,7 +262,7 @@ header h3 em {
@if ($client && $account->showTokenCheckbox())
<input id="token_billing" type="checkbox" name="token_billing" {{ $account->selectTokenCheckbox() ? 'CHECKED' : '' }} value="1" style="margin-left:0px; vertical-align:top">
<label for="token_billing" class="checkbox" style="display: inline;">{{ trans('texts.token_billing') }}</label>
<span class="help-block" style="font-size:15px">{{ trans('texts.token_billing_secure', ['stripe_link' => link_to('https://stripe.com/', 'Stripe.com', ['target' => '_blank'])]) }}</span>
<span class="help-block" style="font-size:15px">{!! trans('texts.token_billing_secure', ['stripe_link' => link_to('https://stripe.com/', 'Stripe.com', ['target' => '_blank'])]) !!}</span>
@endif
</div>

View File

@ -192,15 +192,15 @@ table.table thead .sorting_desc_disabled:after { content: '' !important }
<div class="container">
@if (Session::has('warning'))
<div class="alert alert-warning">{{ Session::get('warning') }}</div>
<div class="alert alert-warning">{!! Session::get('warning') !!}</div>
@endif
@if (Session::has('message'))
<div class="alert alert-info">{{ Session::get('message') }}</div>
<div class="alert alert-info">{!! Session::get('message') !!}</div>
@endif
@if (Session::has('error'))
<div class="alert alert-danger">{{ Session::get('error') }}</div>
<div class="alert alert-danger">{!! Session::get('error') !!}</div>
@endif
</div>