1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Complete payment rest API

This commit is contained in:
David Bomba 2023-07-23 12:43:23 +10:00
parent 895bd9dd8f
commit fd0e4d75ff
2 changed files with 17 additions and 3 deletions

View File

@ -87,6 +87,9 @@ class PayPalRestPaymentDriver extends BaseDriver
public function setPaymentMethod($payment_method_id)
{
if(!$payment_method_id)
return $this;
$this->paypal_payment_method = $this->funding_options[$payment_method_id];
return $this;
@ -161,10 +164,10 @@ class PayPalRestPaymentDriver extends BaseDriver
public function processPaymentResponse($request)
{
$response = json_decode($request['gateway_response'], true);
if($response['status'] == 'COMPLETED'){
if($response['status'] == 'COMPLETED' && isset($response['purchase_units'])){
$data = [
'payment_type' => PaymentType::PAYPAL,
@ -188,6 +191,17 @@ class PayPalRestPaymentDriver extends BaseDriver
}
else {
SystemLogger::dispatch(
['response' => $response],
SystemLog::CATEGORY_GATEWAY_RESPONSE,
SystemLog::EVENT_GATEWAY_FAILURE,
SystemLog::TYPE_PAYPAL,
$this->client,
$this->client->company,
);
throw new PaymentFailed('Payment failed. Please try again.', 401);
}
}

View File

@ -28,7 +28,7 @@
@endsection
@push('footer')
<script src="https://www.paypal.com/sdk/js?buyer-country=US&currency=USD&enable-funding={!! $funding_options !!}&disable-funding=credit,card&components=buttons,hosted-fields,funding-eligibility&intent=capture&client-id={!! $client_id !!}" data-client-token="{!! $token !!}">
<script src="https://www.paypal.com/sdk/js?buyer-country=US&currency=USD&enable-funding={!! $funding_options !!}&disable-funding=credit&components=buttons,hosted-fields,funding-eligibility&intent=capture&client-id={!! $client_id !!}" data-client-token="{!! $token !!}">
</script>
<script>