mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-30 23:34:33 -04:00
Working on eWay
This commit is contained in:
parent
b5697966b5
commit
437bb735d6
@ -68,7 +68,7 @@ class SystemLog extends Model
|
||||
const TYPE_BRAINTREE = 307;
|
||||
const TYPE_WEPAY = 309;
|
||||
const TYPE_PAYFAST = 310;
|
||||
|
||||
const TYPE_EWAY = 311;
|
||||
|
||||
const TYPE_QUOTA_EXCEEDED = 400;
|
||||
const TYPE_UPSTREAM_FAILURE = 401;
|
||||
|
@ -29,21 +29,42 @@ use Illuminate\Support\Str;
|
||||
class CreditCard
|
||||
{
|
||||
|
||||
public $eway;
|
||||
public $eway_driver;
|
||||
|
||||
public function __construct(EwayPaymentDriver $eway)
|
||||
public function __construct(EwayPaymentDriver $eway_driver)
|
||||
{
|
||||
$this->eway = $eway;
|
||||
$this->eway_driver = $eway_driver;
|
||||
}
|
||||
|
||||
public function authorizeView($data)
|
||||
{
|
||||
|
||||
$data['gateway'] = $this->eway_driver;
|
||||
$data['api_key'] = $this->eway_driver->company_gateway->getConfigField('apiKey');
|
||||
$data['public_api_key'] = 'epk-8C1675E6-8E07-4C86-8946-71B3DE390F44';
|
||||
|
||||
return render('gateways.eway.authorize', $data);
|
||||
|
||||
}
|
||||
|
||||
public function authorizeRequest($request)
|
||||
{
|
||||
|
||||
$transaction = [
|
||||
'Title' => 'Mr.',
|
||||
'FirstName' => 'John',
|
||||
'LastName' => 'Smith',
|
||||
'Country' => 'au',
|
||||
'Payment' => [
|
||||
'TotalAmount' => 0,
|
||||
],
|
||||
'TransactionType' => \Eway\Rapid\Enum\TransactionType::PURCHASE,
|
||||
'Method' => \Eway\Rapid\Enum\PaymentMethod::CREATE_TOKEN_CUSTOMER,
|
||||
'SecuredCardData' => $request->input('SecuredCardData'),
|
||||
];
|
||||
|
||||
$response = $client->createTransaction(\Eway\Rapid\Enum\ApiMethod::DIRECT, $transaction);
|
||||
|
||||
}
|
||||
|
||||
public function paymentView($data)
|
||||
|
@ -38,7 +38,7 @@ class EwayPaymentDriver extends BaseDriver
|
||||
GatewayType::CREDIT_CARD => CreditCard::class, //maps GatewayType => Implementation class
|
||||
];
|
||||
|
||||
const SYSTEM_LOG_TYPE = SystemLog::TYPE_STRIPE; //define a constant for your gateway ie TYPE_YOUR_CUSTOM_GATEWAY - set the const in the SystemLog model
|
||||
const SYSTEM_LOG_TYPE = SystemLog::TYPE_EWAY; //define a constant for your gateway ie TYPE_YOUR_CUSTOM_GATEWAY - set the const in the SystemLog model
|
||||
|
||||
public function init()
|
||||
{
|
||||
|
@ -18,6 +18,11 @@ class ActivateEwayPaymentDriver extends Migration
|
||||
{
|
||||
$eway->visible = true;
|
||||
$eway->provider = 'Eway';
|
||||
|
||||
$fields = json_decode($eway->fields);
|
||||
$fields->publicApiKey = '';
|
||||
$eway->fields = json_encode($fields);
|
||||
|
||||
$eway->save();
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ class PaymentLibrariesSeeder extends Seeder
|
||||
'],
|
||||
['id' => 2, 'name' => 'CardSave', 'provider' => 'CardSave', 'key' => '46c5c1fed2c43acf4f379bae9c8b9f76', 'fields' => '{"merchantId":"","password":""}
|
||||
'],
|
||||
['id' => 3, 'name' => 'Eway Rapid', 'provider' => 'Eway', 'is_offsite' => true, 'key' => '944c20175bbe6b9972c05bcfe294c2c7', 'fields' => '{"apiKey":"","password":"","testMode":false}'],
|
||||
['id' => 3, 'name' => 'Eway Rapid', 'provider' => 'Eway', 'is_offsite' => true, 'key' => '944c20175bbe6b9972c05bcfe294c2c7', 'fields' => '{"apiKey":"","password":"","publicApiKey":"",testMode":false}'],
|
||||
['id' => 4, 'name' => 'FirstData Connect', 'provider' => 'FirstData_Connect', 'key' => '4e0ed0d34552e6cb433506d1ac03a418', 'fields' => '{"storeId":"","sharedSecret":"","testMode":false}'],
|
||||
['id' => 5, 'name' => 'Migs ThreeParty', 'provider' => 'Migs_ThreeParty', 'key' => '513cdc81444c87c4b07258bc2858d3fa', 'fields' => '{"merchantId":"","merchantAccessCode":"","secureHash":""}'],
|
||||
['id' => 6, 'name' => 'Migs TwoParty', 'provider' => 'Migs_TwoParty', 'key' => '99c2a271b5088951334d1302e038c01a', 'fields' => '{"merchantId":"","merchantAccessCode":"","secureHash":""}'],
|
||||
|
@ -4,7 +4,9 @@
|
||||
@endsection
|
||||
|
||||
@section('gateway_content')
|
||||
<form action="{{ $payment_endpoint_url }}" method="post" id="server_response">
|
||||
<form action="{{ route('client.payment_methods.store', ['method' => App\Models\GatewayType::CREDIT_CARD]) }}" method="post" id="payment_form">
|
||||
|
||||
<input type="hidden" id="securefieldcode" name="SecuredCardData" value="" />
|
||||
|
||||
@if(!Request::isSecure())
|
||||
<p class="alert alert-failure">{{ ctrans('texts.https_required') }}</p>
|
||||
@ -17,6 +19,8 @@
|
||||
{{ ctrans('texts.credit_card') }}
|
||||
@endcomponent
|
||||
|
||||
@include('portal.ninja2020.gateways.eway.includes.credit_card')
|
||||
|
||||
<div class="bg-white px-4 py-5 flex justify-end">
|
||||
<button
|
||||
type="submit"
|
||||
@ -31,4 +35,65 @@
|
||||
|
||||
@section('gateway_footer')
|
||||
<!-- Your JS includes go here -->
|
||||
<script src="https://secure.ewaypayments.com/scripts/eWAY.min.js" data-init="false"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
var publicApiKey = "{{ $public_api_key }}";
|
||||
|
||||
var fieldStyles = "line-height: 1; height: 28px; border: 1px solid #AAA; color: #000; padding: 2px;";
|
||||
|
||||
var nameFieldConfig = {
|
||||
publicApiKey: publicApiKey,
|
||||
fieldDivId: "eway-secure-field-name",
|
||||
fieldType: "name",
|
||||
styles: fieldStyles
|
||||
};
|
||||
var cardFieldConfig = {
|
||||
publicApiKey: publicApiKey,
|
||||
fieldDivId: "eway-secure-field-card",
|
||||
fieldType: "card",
|
||||
styles: fieldStyles
|
||||
};
|
||||
var expiryFieldConfig = {
|
||||
publicApiKey: publicApiKey,
|
||||
fieldDivId: "eway-secure-field-expiry",
|
||||
fieldType: "expiry",
|
||||
styles: fieldStyles
|
||||
};
|
||||
var cvnFieldConfig = {
|
||||
publicApiKey: publicApiKey,
|
||||
fieldDivId: "eway-secure-field-cvn",
|
||||
fieldType: "cvn",
|
||||
styles: fieldStyles
|
||||
};
|
||||
|
||||
function secureFieldCallback(event) {
|
||||
if (!event.fieldValid) {
|
||||
console.log(event.errors);
|
||||
} else {
|
||||
// set the hidden Secure Field Code field
|
||||
var s = document.getElementById("securefieldcode");
|
||||
s.value = event.secureFieldCode
|
||||
console.log(s.value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
window.onload = function () {
|
||||
eWAY.setupSecureField(nameFieldConfig, secureFieldCallback);
|
||||
eWAY.setupSecureField(cardFieldConfig, secureFieldCallback);
|
||||
eWAY.setupSecureField(expiryFieldConfig, secureFieldCallback);
|
||||
eWAY.setupSecureField(cvnFieldConfig, secureFieldCallback);
|
||||
};
|
||||
|
||||
let payNow = document.getElementById('pay-now');
|
||||
|
||||
payNow.addEventListener('click', () => {
|
||||
console.log("click");
|
||||
document.getElementById('server_response').submit();
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
@endsection
|
||||
|
@ -0,0 +1,15 @@
|
||||
<div class="flex grid grid-rows-1" id="eway--credit-card-container">
|
||||
<div class="h-12">
|
||||
<div id="eway-secure-field-name"></div>
|
||||
</div>
|
||||
<div class="h-12">
|
||||
<div id="eway-secure-field-card"></div>
|
||||
</div>
|
||||
<div class="h-12">
|
||||
<div id="eway-secure-field-expiry"></div>
|
||||
</div>
|
||||
<div class="h-12">
|
||||
<div id="eway-secure-field-cvn"></div>
|
||||
</div>
|
||||
<div id="errors"></div>
|
||||
</div>
|
Loading…
x
Reference in New Issue
Block a user