mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
Working on authorization for WePay
This commit is contained in:
parent
8a217358a8
commit
177a4ce58f
@ -51,7 +51,8 @@ class PaymentMethodController extends Controller
|
|||||||
$gateway = $this->getClientGateway();
|
$gateway = $this->getClientGateway();
|
||||||
|
|
||||||
$data['gateway'] = $gateway;
|
$data['gateway'] = $gateway;
|
||||||
|
$data['client'] = auth()->user()->client;
|
||||||
|
|
||||||
return $gateway
|
return $gateway
|
||||||
->driver(auth()->user()->client)
|
->driver(auth()->user()->client)
|
||||||
->setPaymentMethod($request->query('method'))
|
->setPaymentMethod($request->query('method'))
|
||||||
|
@ -31,15 +31,17 @@ class CreditCard
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function authorizeResponse($data)
|
public function authorizeResponse($request)
|
||||||
{
|
{
|
||||||
//https://developer.wepay.com/api/api-calls/credit_card#authorize
|
//https://developer.wepay.com/api/api-calls/credit_card#authorize
|
||||||
|
|
||||||
|
$data = $request->all();
|
||||||
// authorize the credit card
|
// authorize the credit card
|
||||||
$response = $this->wepay->request('credit_card/authorize', array(
|
$response = $this->wepay->request('credit_card/authorize', array(
|
||||||
'client_id' => $account_id,
|
'account_id' => $this->wepay->company_gateway->getConfigField('accountId'),
|
||||||
'client_secret' => 'A vacation home rental',
|
'client_id' => config('ninja.wepay.client_id'),
|
||||||
'credit_card_id' => 'goods',
|
'client_secret' => config('ninja.wepay.client_secret'),
|
||||||
|
'credit_card_id' => $data['source_token'],
|
||||||
));
|
));
|
||||||
|
|
||||||
// display the response
|
// display the response
|
||||||
|
@ -115,6 +115,10 @@ class WePayPaymentDriver extends BaseDriver
|
|||||||
public function authorizeView(array $data)
|
public function authorizeView(array $data)
|
||||||
{
|
{
|
||||||
$data['gateway'] = $this->wepay;
|
$data['gateway'] = $this->wepay;
|
||||||
|
$client = $data['client'];
|
||||||
|
$contact = $client->primary_contact()->first() ? $client->primary_contact()->first() : $lient->contacts->first();
|
||||||
|
$data['contact'] = $contact;
|
||||||
|
// $data['contact'] = $this->company_gateway
|
||||||
// $data['public_client_id'] = $this->authorize->init()->getPublicClientKey();
|
// $data['public_client_id'] = $this->authorize->init()->getPublicClientKey();
|
||||||
// $data['api_login_id'] = $this->authorize->company_gateway->getConfigField('apiLoginId');
|
// $data['api_login_id'] = $this->authorize->company_gateway->getConfigField('apiLoginId');
|
||||||
|
|
||||||
@ -145,4 +149,59 @@ class WePayPaymentDriver extends BaseDriver
|
|||||||
{
|
{
|
||||||
return $this->payment_method->yourTokenBillingImplmentation(); //this is your custom implementation from here
|
return $this->payment_method->yourTokenBillingImplmentation(); //this is your custom implementation from here
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function getClientRequiredFields(): array
|
||||||
|
{
|
||||||
|
$fields = [
|
||||||
|
['name' => 'client_postal_code', 'label' => ctrans('texts.postal_code'), 'type' => 'text', 'validation' => 'required'],
|
||||||
|
['name' => 'contact_email', 'label' => ctrans('texts.email'), 'type' => 'text', 'validation' => 'required'],
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($this->company_gateway->require_client_name) {
|
||||||
|
$fields[] = ['name' => 'client_name', 'label' => ctrans('texts.client_name'), 'type' => 'text', 'validation' => 'required'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->company_gateway->require_client_phone) {
|
||||||
|
$fields[] = ['name' => 'client_phone', 'label' => ctrans('texts.client_phone'), 'type' => 'tel', 'validation' => 'required'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->company_gateway->require_contact_name) {
|
||||||
|
$fields[] = ['name' => 'contact_first_name', 'label' => ctrans('texts.first_name'), 'type' => 'text', 'validation' => 'required'];
|
||||||
|
$fields[] = ['name' => 'contact_last_name', 'label' => ctrans('texts.last_name'), 'type' => 'text', 'validation' => 'required'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->company_gateway->require_contact_email) {
|
||||||
|
$fields[] = ['name' => 'contact_email', 'label' => ctrans('texts.email'), 'type' => 'text', 'validation' => 'required,email:rfc'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->company_gateway->require_billing_address) {
|
||||||
|
$fields[] = ['name' => 'client_address_line_1', 'label' => ctrans('texts.address1'), 'type' => 'text', 'validation' => 'required'];
|
||||||
|
// $fields[] = ['name' => 'client_address_line_2', 'label' => ctrans('texts.address2'), 'type' => 'text', 'validation' => 'nullable'];
|
||||||
|
$fields[] = ['name' => 'client_city', 'label' => ctrans('texts.city'), 'type' => 'text', 'validation' => 'required'];
|
||||||
|
$fields[] = ['name' => 'client_state', 'label' => ctrans('texts.state'), 'type' => 'text', 'validation' => 'required'];
|
||||||
|
$fields[] = ['name' => 'client_country_id', 'label' => ctrans('texts.country'), 'type' => 'text', 'validation' => 'required'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->company_gateway->require_shipping_address) {
|
||||||
|
$fields[] = ['name' => 'client_shipping_address_line_1', 'label' => ctrans('texts.shipping_address1'), 'type' => 'text', 'validation' => 'required'];
|
||||||
|
// $fields[] = ['name' => 'client_shipping_address_line_2', 'label' => ctrans('texts.shipping_address2'), 'type' => 'text', 'validation' => 'sometimes'];
|
||||||
|
$fields[] = ['name' => 'client_shipping_city', 'label' => ctrans('texts.shipping_city'), 'type' => 'text', 'validation' => 'required'];
|
||||||
|
$fields[] = ['name' => 'client_shipping_state', 'label' => ctrans('texts.shipping_state'), 'type' => 'text', 'validation' => 'required'];
|
||||||
|
$fields[] = ['name' => 'client_shipping_postal_code', 'label' => ctrans('texts.shipping_postal_code'), 'type' => 'text', 'validation' => 'required'];
|
||||||
|
$fields[] = ['name' => 'client_shipping_country_id', 'label' => ctrans('texts.shipping_country'), 'type' => 'text', 'validation' => 'required'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -44,8 +44,11 @@
|
|||||||
<script type="text/javascript" src="https://static.wepay.com/min/js/tokenization.4.latest.js"></script>
|
<script type="text/javascript" src="https://static.wepay.com/min/js/tokenization.4.latest.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
(function() {
|
(function() {
|
||||||
WePay.set_endpoint({{ config('ninja.wepay.environment') }}); // change to "production" when live
|
@if(config('ninja.wepay.environment') == 'staging')
|
||||||
|
WePay.set_endpoint("stage"); // change to "production" when live
|
||||||
|
@else
|
||||||
|
WePay.set_endpoint("production"); // change to "production" when live
|
||||||
|
@endif
|
||||||
// Shortcuts
|
// Shortcuts
|
||||||
var d = document;
|
var d = document;
|
||||||
d.id = d.getElementById,
|
d.id = d.getElementById,
|
||||||
@ -60,18 +63,20 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Attach the event to the DOM
|
// Attach the event to the DOM
|
||||||
addEvent(d.id('card_button'), 'click', function() {
|
addEvent(document.getElementById('card_button'), 'click', function() {
|
||||||
|
|
||||||
|
var myCard = $('#my-card');
|
||||||
var userName = [valueById('cardholder_name')].join(' ');
|
var userName = [valueById('cardholder_name')].join(' ');
|
||||||
response = WePay.credit_card.create({
|
response = WePay.credit_card.create({
|
||||||
"client_id": {{ config('ninja.wepay.client_id') }},
|
"client_id": "{{ config('ninja.wepay.client_id') }}",
|
||||||
"user_name": valueById('cardholder_name'),
|
"user_name": valueById('cardholder_name'),
|
||||||
"email": valueById('email'),
|
"email": "{{ $contact->email }}",
|
||||||
"cc_number": valueById('card-number'),
|
"cc_number": myCard.CardJs('cardNumber'),
|
||||||
"cvv": valueById('cvv'),
|
"cvv": myCard.CardJs('cvc'),
|
||||||
"expiration_month": valueById('expiration_month'),
|
"expiration_month": myCard.CardJs('expiryMonth'),
|
||||||
"expiration_year": valueById('expiration_year'),
|
"expiration_year": myCard.CardJs('expiryYear'),
|
||||||
"address": {
|
"address": {
|
||||||
"postal_code": valueById('postal_code')
|
"postal_code": "{{ $contact->client->postal_code }}"
|
||||||
}
|
}
|
||||||
}, function(data) {
|
}, function(data) {
|
||||||
if (data.error) {
|
if (data.error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user