mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-30 21:34:34 -04:00
Updates
This commit is contained in:
parent
2c2ffb4ef8
commit
b219a655be
@ -30,7 +30,7 @@ class CreditFilters extends QueryFilters
|
||||
* @param string $value The credit status as seen by the client
|
||||
* @return Builder
|
||||
*/
|
||||
public function credit_status(string $value = ''): Builder
|
||||
public function client_status(string $value = ''): Builder
|
||||
{
|
||||
if (strlen($value) == 0) {
|
||||
return $this->builder;
|
||||
|
@ -37,6 +37,7 @@ class ImportRequest extends Request
|
||||
'column_map' => 'required_with:hash|array',
|
||||
'skip_header' => 'required_with:hash|boolean',
|
||||
'files.*' => 'file|mimes:csv,txt',
|
||||
'bank_integration_id' => 'bail|required_if:column_map,bank_transaction|min:2'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,10 @@ class PreImportRequest extends Request
|
||||
*/
|
||||
public function authorize() : bool
|
||||
{
|
||||
return auth()->user()->isAdmin();
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
return $user->isAdmin();
|
||||
}
|
||||
|
||||
public function rules()
|
||||
|
@ -139,9 +139,8 @@ class PayPalPPCPPaymentDriver extends BaseDriver
|
||||
public function init(): self
|
||||
{
|
||||
|
||||
// $this->api_endpoint_url = $this->company_gateway->getConfigField('testMode') ? 'https://api-m.sandbox.paypal.com' : 'https://api-m.paypal.com';
|
||||
$this->api_endpoint_url = 'https://api-m.paypal.com';
|
||||
|
||||
// $this->api_endpoint_url = 'https://api-m.sandbox.paypal.com';
|
||||
$secret = config('ninja.paypal.secret');
|
||||
$client_id = config('ninja.paypal.client_id');
|
||||
|
||||
@ -238,30 +237,23 @@ class PayPalPPCPPaymentDriver extends BaseDriver
|
||||
|
||||
}
|
||||
|
||||
private function getClientToken(): string
|
||||
{
|
||||
|
||||
$r = $this->gatewayRequest('/v1/identity/generate-token', 'post', ['body' => '']);
|
||||
|
||||
if($r->successful()) {
|
||||
return $r->json()['client_token'];
|
||||
}
|
||||
|
||||
throw new PaymentFailed('Unable to gain client token from Paypal. Check your configuration', 401);
|
||||
|
||||
}
|
||||
|
||||
public function processPaymentResponse($request)
|
||||
{
|
||||
|
||||
$request['gateway_response'] = str_replace("Error: ", "", $request['gateway_response']);
|
||||
$response = json_decode($request['gateway_response'], true);
|
||||
|
||||
//capture
|
||||
$orderID = $response['orderID'];
|
||||
$r = $this->gatewayRequest("/v2/checkout/orders/{$orderID}/capture", 'post', ['body' => '']);
|
||||
|
||||
$response = $r;
|
||||
|
||||
if(isset($response['status']) && $response['status'] == 'COMPLETED' && isset($response['purchase_units'])) {
|
||||
|
||||
$data = [
|
||||
'payment_type' => $this->getPaymentMethod($request->gateway_type_id),
|
||||
'amount' => $response['purchase_units'][0]['amount']['value'],
|
||||
'amount' => $response['purchase_units'][0]['payments']['captures'][0]['amount']['value'],
|
||||
'transaction_reference' => $response['purchase_units'][0]['payments']['captures'][0]['id'],
|
||||
'gateway_type_id' => GatewayType::PAYPAL,
|
||||
];
|
||||
@ -300,6 +292,21 @@ class PayPalPPCPPaymentDriver extends BaseDriver
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private function getClientToken(): string
|
||||
{
|
||||
|
||||
$r = $this->gatewayRequest('/v1/identity/generate-token', 'post', ['body' => '']);
|
||||
|
||||
if($r->successful()) {
|
||||
return $r->json()['client_token'];
|
||||
}
|
||||
|
||||
throw new PaymentFailed('Unable to gain client token from Paypal. Check your configuration', 401);
|
||||
|
||||
}
|
||||
|
||||
private function paymentSource(): array
|
||||
{
|
||||
/** we only need to support paypal as payment source until as we are only using hosted payment buttons */
|
||||
@ -307,36 +314,6 @@ class PayPalPPCPPaymentDriver extends BaseDriver
|
||||
|
||||
}
|
||||
|
||||
/**@deprecated v5.7.54 */
|
||||
private function injectVenmoPaymentSource(): array
|
||||
{
|
||||
|
||||
return [
|
||||
"venmo" => [
|
||||
"email_address" => $this->client->present()->email(),
|
||||
],
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
/**@deprecated v5.7.54 */
|
||||
private function injectCardPaymentSource(): array
|
||||
{
|
||||
|
||||
return [
|
||||
"card" => [
|
||||
|
||||
"name" => $this->client->present()->name(),
|
||||
"email_address" => $this->client->present()->email(),
|
||||
"billing_address" => $this->getBillingAddress(),
|
||||
"experience_context"=> [
|
||||
"user_action" => "PAY_NOW"
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
private function injectPayPalPaymentSource(): array
|
||||
{
|
||||
|
||||
@ -462,10 +439,23 @@ class PayPalPPCPPaymentDriver extends BaseDriver
|
||||
->withHeaders($this->getHeaders($headers))
|
||||
->{$verb}("{$this->api_endpoint_url}{$uri}", $data);
|
||||
|
||||
nlog($r);
|
||||
nlog($r->json());
|
||||
|
||||
if($r->successful()) {
|
||||
return $r;
|
||||
}
|
||||
|
||||
|
||||
SystemLogger::dispatch(
|
||||
['response' => $r->body()],
|
||||
SystemLog::CATEGORY_GATEWAY_RESPONSE,
|
||||
SystemLog::EVENT_GATEWAY_FAILURE,
|
||||
SystemLog::TYPE_PAYPAL,
|
||||
$this->client,
|
||||
$this->client->company,
|
||||
);
|
||||
|
||||
throw new PaymentFailed("Gateway failure - {$r->body()}", 401);
|
||||
|
||||
}
|
||||
|
@ -53,10 +53,11 @@
|
||||
return actions.restart();
|
||||
}
|
||||
|
||||
return actions.order.capture().then(function(details) {
|
||||
document.getElementById("gateway_response").value =JSON.stringify( details );
|
||||
// return actions.order.capture().then(function(details) {
|
||||
document.getElementById("gateway_response").value =JSON.stringify( data );
|
||||
// document.getElementById("gateway_response").value =JSON.stringify( details );
|
||||
document.getElementById("server_response").submit();
|
||||
});
|
||||
// });
|
||||
},
|
||||
onCancel: function() {
|
||||
window.location.href = "/client/invoices/";
|
||||
|
Loading…
x
Reference in New Issue
Block a user