mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Added Paymill
This commit is contained in:
parent
395ce6303b
commit
5c5dd7a27e
@ -301,6 +301,7 @@ if (! defined('APP_NAME')) {
|
||||
define('GATEWAY_BRAINTREE', 61);
|
||||
define('GATEWAY_CUSTOM', 62);
|
||||
define('GATEWAY_GOCARDLESS', 64);
|
||||
define('GATEWAY_PAYMILL', 66);
|
||||
|
||||
// The customer exists, but only as a local concept
|
||||
// The remote gateway doesn't understand the concept of customers
|
||||
|
@ -473,7 +473,7 @@ class AccountController extends BaseController
|
||||
$trashedCount = AccountGateway::scope()->withTrashed()->count();
|
||||
|
||||
if ($accountGateway = $account->getGatewayConfig(GATEWAY_STRIPE)) {
|
||||
if (! $accountGateway->getPublishableStripeKey()) {
|
||||
if (! $accountGateway->getPublishableKey()) {
|
||||
Session::now('warning', trans('texts.missing_publishable_key'));
|
||||
}
|
||||
}
|
||||
|
@ -183,6 +183,8 @@ class AccountGatewayController extends BaseController
|
||||
|
||||
if ($gatewayId == GATEWAY_DWOLLA) {
|
||||
$optional = array_merge($optional, ['key', 'secret']);
|
||||
} elseif ($gatewayId == GATEWAY_PAYMILL) {
|
||||
$rules['publishable_key'] = 'required';
|
||||
} elseif ($gatewayId == GATEWAY_STRIPE) {
|
||||
if (Utils::isNinjaDev()) {
|
||||
// do nothing - we're unable to acceptance test with StripeJS
|
||||
|
@ -71,7 +71,7 @@ class HandleUserLoggedIn
|
||||
|
||||
// if they're using Stripe make sure they're using Stripe.js
|
||||
$accountGateway = $account->getGatewayConfig(GATEWAY_STRIPE);
|
||||
if ($accountGateway && ! $accountGateway->getPublishableStripeKey()) {
|
||||
if ($accountGateway && ! $accountGateway->getPublishableKey()) {
|
||||
Session::flash('warning', trans('texts.missing_publishable_key'));
|
||||
} elseif ($account->isLogoTooLarge()) {
|
||||
Session::flash('warning', trans('texts.logo_too_large', ['size' => $account->getLogoSize() . 'KB']));
|
||||
|
@ -95,8 +95,17 @@ class AccountGateway extends EntityModel
|
||||
*/
|
||||
public function isGateway($gatewayId)
|
||||
{
|
||||
if (is_array($gatewayId)) {
|
||||
foreach ($gatewayId as $id) {
|
||||
if ($this->gateway_id == $id) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return $this->gateway_id == $gatewayId;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $config
|
||||
@ -127,9 +136,9 @@ class AccountGateway extends EntityModel
|
||||
/**
|
||||
* @return bool|mixed
|
||||
*/
|
||||
public function getPublishableStripeKey()
|
||||
public function getPublishableKey()
|
||||
{
|
||||
if (! $this->isGateway(GATEWAY_STRIPE)) {
|
||||
if (! $this->isGateway([GATEWAY_STRIPE, GATEWAY_PAYMILL])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -254,7 +263,7 @@ class AccountGateway extends EntityModel
|
||||
return null;
|
||||
}
|
||||
|
||||
$stripe_key = $this->getPublishableStripeKey();
|
||||
$stripe_key = $this->getPublishableKey();
|
||||
|
||||
return substr(trim($stripe_key), 0, 8) == 'pk_test_' ? 'tartan' : 'production';
|
||||
}
|
||||
@ -272,7 +281,7 @@ class AccountGateway extends EntityModel
|
||||
public function isTestMode()
|
||||
{
|
||||
if ($this->isGateway(GATEWAY_STRIPE)) {
|
||||
return strpos($this->getPublishableStripeKey(), 'test') !== false;
|
||||
return strpos($this->getPublishableKey(), 'test') !== false;
|
||||
} else {
|
||||
return $this->getConfigField('testMode');
|
||||
}
|
||||
|
27
app/Ninja/PaymentDrivers/PaymillPaymentDriver.php
Normal file
27
app/Ninja/PaymentDrivers/PaymillPaymentDriver.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\PaymentDrivers;
|
||||
|
||||
class PaymillPaymentDriver extends BasePaymentDriver
|
||||
{
|
||||
public function tokenize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function paymentDetails($paymentMethod = false)
|
||||
{
|
||||
$data = parent::paymentDetails($paymentMethod);
|
||||
|
||||
if ($paymentMethod) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
if (! empty($this->input['sourceToken'])) {
|
||||
$data['token'] = $this->input['sourceToken'];
|
||||
unset($data['card']);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
@ -63,7 +63,7 @@ class StripePaymentDriver extends BasePaymentDriver
|
||||
|
||||
public function tokenize()
|
||||
{
|
||||
return $this->accountGateway->getPublishableStripeKey();
|
||||
return $this->accountGateway->getPublishableKey();
|
||||
}
|
||||
|
||||
public function rules()
|
||||
|
@ -36,7 +36,7 @@
|
||||
"google/apiclient": "^2.0",
|
||||
"guzzlehttp/guzzle": "~6.0",
|
||||
"intervention/image": "dev-master",
|
||||
"invoiceninja/omnipay-collection": "0.6@dev",
|
||||
"invoiceninja/omnipay-collection": "0.7@dev",
|
||||
"jaybizzle/laravel-crawler-detect": "1.*",
|
||||
"jlapp/swaggervel": "master-dev",
|
||||
"jonnyw/php-phantomjs": "dev-fixes",
|
||||
|
63
composer.lock
generated
63
composer.lock
generated
@ -4,8 +4,8 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"hash": "8c61bb54d84a6fcf49038e56aa706561",
|
||||
"content-hash": "189d617b1ea403a147b9fe61c0b2185b",
|
||||
"hash": "7ee707d4d8d5e695a06f09148055a914",
|
||||
"content-hash": "6d17fba6edb89baff674e8d4a89e00e5",
|
||||
"packages": [
|
||||
{
|
||||
"name": "abdala/omnipay-pagseguro",
|
||||
@ -838,6 +838,50 @@
|
||||
"description": "Braintree PHP Client Library",
|
||||
"time": "2018-02-27 22:51:38"
|
||||
},
|
||||
{
|
||||
"name": "bramdevries/omnipay-paymill",
|
||||
"version": "1.0.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/bramdevries/omnipay-paymill.git",
|
||||
"reference": "df264a980b4b6005899f659d55b24d5c125d7e2e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/bramdevries/omnipay-paymill/zipball/df264a980b4b6005899f659d55b24d5c125d7e2e",
|
||||
"reference": "df264a980b4b6005899f659d55b24d5c125d7e2e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"omnipay/common": "~2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"omnipay/tests": "~2.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Omnipay\\Paymill\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Bram Devries",
|
||||
"email": "bramdevries93@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "Paymill driver for the Omnipay payment processing library",
|
||||
"keywords": [
|
||||
"gateway",
|
||||
"merchant",
|
||||
"omnipay",
|
||||
"pay",
|
||||
"payment",
|
||||
"paymill"
|
||||
],
|
||||
"time": "2014-12-14 17:00:43"
|
||||
},
|
||||
{
|
||||
"name": "cardgate/omnipay-cardgate",
|
||||
"version": "v2.0.0",
|
||||
@ -3493,16 +3537,16 @@
|
||||
},
|
||||
{
|
||||
"name": "invoiceninja/omnipay-collection",
|
||||
"version": "v0.6",
|
||||
"version": "v0.7",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/invoiceninja/omnipay-collection.git",
|
||||
"reference": "2ca215e97e3b436b26b0b8f52e865ed94eb61408"
|
||||
"reference": "12d9c8d40d62301e2226db63d1e5534747f660fe"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/invoiceninja/omnipay-collection/zipball/2ca215e97e3b436b26b0b8f52e865ed94eb61408",
|
||||
"reference": "2ca215e97e3b436b26b0b8f52e865ed94eb61408",
|
||||
"url": "https://api.github.com/repos/invoiceninja/omnipay-collection/zipball/12d9c8d40d62301e2226db63d1e5534747f660fe",
|
||||
"reference": "12d9c8d40d62301e2226db63d1e5534747f660fe",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -3510,6 +3554,7 @@
|
||||
"agmscode/omnipay-agms": "~1.0",
|
||||
"alfaproject/omnipay-skrill": "dev-master",
|
||||
"andreas22/omnipay-fasapay": "1.*",
|
||||
"bramdevries/omnipay-paymill": "^1.0",
|
||||
"cardgate/omnipay-cardgate": "~2.0",
|
||||
"delatbabel/omnipay-fatzebra": "dev-master",
|
||||
"dercoder/omnipay-ecopayz": "~1.0",
|
||||
@ -3549,7 +3594,7 @@
|
||||
}
|
||||
],
|
||||
"description": "Collection of Omnipay drivers",
|
||||
"time": "2018-01-17 13:51:24"
|
||||
"time": "2018-03-07 13:26:16"
|
||||
},
|
||||
{
|
||||
"name": "jakoch/phantomjs-installer",
|
||||
@ -9243,7 +9288,7 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony/event-dispatcher",
|
||||
"version": "v2.8.35",
|
||||
"version": "v2.8.36",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/event-dispatcher.git",
|
||||
@ -9401,7 +9446,7 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony/http-foundation",
|
||||
"version": "v3.4.5",
|
||||
"version": "v3.4.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/http-foundation.git",
|
||||
|
@ -74,6 +74,7 @@ class PaymentLibrariesSeeder extends Seeder
|
||||
['name' => 'FirstData Payeezy', 'provider' => 'FirstData_Payeezy'],
|
||||
['name' => 'GoCardless', 'provider' => 'GoCardlessV2\Redirect', 'sort_order' => 9, 'is_offsite' => true],
|
||||
['name' => 'PagSeguro', 'provider' => 'PagSeguro'],
|
||||
['name' => 'PAYMILL', 'provider' => 'Paymill'],
|
||||
];
|
||||
|
||||
foreach ($gateways as $gateway) {
|
||||
|
@ -34,7 +34,7 @@
|
||||
{!! Former::populateField('show_address', intval($accountGateway->show_address)) !!}
|
||||
{!! Former::populateField('show_shipping_address', intval($accountGateway->show_shipping_address)) !!}
|
||||
{!! Former::populateField('update_address', intval($accountGateway->update_address)) !!}
|
||||
{!! Former::populateField('publishable_key', $accountGateway->getPublishableStripeKey() ? str_repeat('*', strlen($accountGateway->getPublishableStripeKey())) : '') !!}
|
||||
{!! Former::populateField('publishable_key', $accountGateway->getPublishableKey() ? str_repeat('*', strlen($accountGateway->getPublishableKey())) : '') !!}
|
||||
{!! Former::populateField('enable_ach', $accountGateway->getAchEnabled() ? 1 : 0) !!}
|
||||
{!! Former::populateField('enable_apple_pay', $accountGateway->getApplePayEnabled() ? 1 : 0) !!}
|
||||
{!! Former::populateField('enable_sofort', $accountGateway->getSofortEnabled() ? 1 : 0) !!}
|
||||
@ -84,13 +84,12 @@
|
||||
@endif
|
||||
@endif
|
||||
|
||||
@foreach ($gateways as $gateway)
|
||||
|
||||
<div id="gateway_{{ $gateway->id }}_div" class='gateway-fields' style="display: none">
|
||||
@if ($gateway->id == GATEWAY_STRIPE)
|
||||
<span id="publishableKey" style="display: none">
|
||||
{!! Former::text('publishable_key') !!}
|
||||
@endif
|
||||
</span>
|
||||
|
||||
@foreach ($gateways as $gateway)
|
||||
<div id="gateway_{{ $gateway->id }}_div" class='gateway-fields' style="display: none">
|
||||
@foreach ($gateway->fields as $field => $details)
|
||||
|
||||
@if ($details && (!$accountGateway || !$accountGateway->getConfigField($field)) && !is_array($details) && !is_bool($details))
|
||||
@ -321,6 +320,8 @@
|
||||
} else {
|
||||
$('.stripe-ach').hide();
|
||||
}
|
||||
|
||||
$('#publishableKey').toggle([{{ GATEWAY_STRIPE }}, {{ GATEWAY_PAYMILL }}].indexOf(gateway.id) >= 0);
|
||||
}
|
||||
|
||||
function gatewayLink(url) {
|
||||
|
@ -118,7 +118,7 @@
|
||||
<script type="text/javascript" src="https://js.stripe.com/v3/"></script>
|
||||
<script type="text/javascript">
|
||||
// https://stripe.com/docs/stripe-js/elements/payment-request-button
|
||||
var stripe = Stripe('{{ $accountGateway->getPublishableStripeKey() }}');
|
||||
var stripe = Stripe('{{ $accountGateway->getPublishableKey() }}');
|
||||
var paymentRequest = stripe.paymentRequest({
|
||||
country: '{{ $invoice->client->getCountryCode() }}',
|
||||
currency: '{{ strtolower($invoice->client->getCurrencyCode()) }}',
|
||||
|
@ -6,7 +6,7 @@
|
||||
<script type="text/javascript" src="https://js.stripe.com/v3/"></script>
|
||||
<script type="text/javascript">
|
||||
// https://stripe.com/docs/stripe-js/elements/payment-request-button
|
||||
var stripe = Stripe('{{ $accountGateway->getPublishableStripeKey() }}');
|
||||
var stripe = Stripe('{{ $accountGateway->getPublishableKey() }}');
|
||||
var paymentRequest = stripe.paymentRequest({
|
||||
country: '{{ $client->getCountryCode() }}',
|
||||
currency: '{{ strtolower($client->getCurrencyCode()) }}',
|
||||
|
@ -77,6 +77,7 @@
|
||||
});
|
||||
|
||||
@if ($accountGateway->gateway_id != GATEWAY_BRAINTREE)
|
||||
if ($('#card_number').length) {
|
||||
var card = new Card({
|
||||
form: 'form#payment-form', // *required*
|
||||
container: '.card-wrapper', // *required*
|
||||
@ -110,7 +111,7 @@
|
||||
},
|
||||
debug: true,
|
||||
});
|
||||
|
||||
}
|
||||
@endif
|
||||
});
|
||||
</script>
|
||||
@ -337,6 +338,13 @@
|
||||
</h3>
|
||||
<hr class="form-legend"/>
|
||||
</div>
|
||||
|
||||
@if ($accountGateway->isGateway(GATEWAY_PAYMILL))
|
||||
<div class="paymill-form">
|
||||
<div id="paymillCardFields"></div>
|
||||
<input id="sourceToken" name="sourceToken" type="hidden"/>
|
||||
</div>
|
||||
@else
|
||||
<div class="col-lg-{{ ($accountGateway->gateway_id == GATEWAY_BRAINTREE) ? 12 : 8 }}">
|
||||
|
||||
<div class="row">
|
||||
@ -426,6 +434,7 @@
|
||||
<div class="col-lg-4" style="padding-top: 12px; padding-left: 0px;">
|
||||
<div class='card-wrapper'></div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
|
||||
|
83
resources/views/payments/paymill/credit_card.blade.php
Normal file
83
resources/views/payments/paymill/credit_card.blade.php
Normal file
@ -0,0 +1,83 @@
|
||||
@extends('payments.credit_card')
|
||||
|
||||
@section('head')
|
||||
@parent
|
||||
|
||||
<style type="text/css">
|
||||
.paymill-form {
|
||||
margin-left: 16px;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
var PAYMILL_PUBLIC_KEY = '{{ $accountGateway->getPublishableKey() }}';
|
||||
</script>
|
||||
|
||||
<script type="text/javascript" src = "https://bridge.paymill.com/"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
$(function() {
|
||||
var options = {
|
||||
lang: '{{ App::getLocale() }}',
|
||||
resize: false,
|
||||
};
|
||||
|
||||
var callback = function(error){
|
||||
if (error){
|
||||
console.log(error.apierror, error.message);
|
||||
} else {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
paymill.embedFrame('paymillCardFields', options, callback);
|
||||
|
||||
$('.payment-form').unbind('submit').submit(function(event) {
|
||||
if ($('#sourceToken').val()) {
|
||||
// do nothing
|
||||
} else {
|
||||
event.preventDefault();
|
||||
|
||||
var data = {
|
||||
amount_int: {{ $invitation->invoice->getRequestedAmount() * 100 }},
|
||||
currency: '{{ $invitation->invoice->getCurrencyCode() }}',
|
||||
email: '{{ $contact->email }}',
|
||||
};
|
||||
|
||||
var callback = function(error, result) {
|
||||
if (error) {
|
||||
if (error.apierror == 'field_invalid_card_number') {
|
||||
var message = "{{ trans('texts.invalid_card_number') }}";
|
||||
} else {
|
||||
var message = error.apierror;
|
||||
if (error.message) {
|
||||
message += ': ' + error.message;
|
||||
}
|
||||
}
|
||||
$('.payment-form').find('button').prop('disabled', false);
|
||||
NINJA.formIsSubmitted = false;
|
||||
$('#js-error-message').html(message).fadeIn();
|
||||
} else {
|
||||
$('#sourceToken').val(result.token);
|
||||
$('.payment-form').submit();
|
||||
}
|
||||
}
|
||||
|
||||
if (NINJA.formIsSubmitted) {
|
||||
return false;
|
||||
}
|
||||
NINJA.formIsSubmitted = true;
|
||||
|
||||
// Disable the submit button to prevent repeated clicks
|
||||
$('.payment-form').find('button').prop('disabled', true);
|
||||
$('#js-error-message').hide();
|
||||
|
||||
paymill.createTokenViaFrame(data, callback);
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
@stop
|
@ -5,7 +5,7 @@
|
||||
|
||||
<script type="text/javascript" src="https://js.stripe.com/v2/"></script>
|
||||
<script type="text/javascript">
|
||||
Stripe.setPublishableKey('{{ $accountGateway->getPublishableStripeKey() }}');
|
||||
Stripe.setPublishableKey('{{ $accountGateway->getPublishableKey() }}');
|
||||
$(function() {
|
||||
var countries = {!! Cache::get('countries')->pluck('iso_3166_2','id') !!};
|
||||
$('.payment-form').submit(function(event) {
|
||||
|
@ -3,10 +3,10 @@
|
||||
@section('head')
|
||||
@parent
|
||||
|
||||
@if ($accountGateway->getPublishableStripeKey())
|
||||
@if ($accountGateway->getPublishableKey())
|
||||
<script type="text/javascript" src="https://js.stripe.com/v2/"></script>
|
||||
<script type="text/javascript">
|
||||
Stripe.setPublishableKey('{{ $accountGateway->getPublishableStripeKey() }}');
|
||||
Stripe.setPublishableKey('{{ $accountGateway->getPublishableKey() }}');
|
||||
$(function() {
|
||||
$('.payment-form').unbind('submit').submit(function(event) {
|
||||
event.preventDefault();
|
||||
|
@ -8,7 +8,7 @@
|
||||
$(function() {
|
||||
$('.payment-form').submit(function(event) {
|
||||
// https://stripe.com/docs/sources/sepa-debit
|
||||
var stripe = Stripe('{{ $accountGateway->getPublishableStripeKey() }}');
|
||||
var stripe = Stripe('{{ $accountGateway->getPublishableKey() }}');
|
||||
stripe.createSource({
|
||||
type: 'sepa_debit',
|
||||
sepa_debit: {
|
||||
|
Loading…
x
Reference in New Issue
Block a user