Payment Payment

This commit is contained in:
David Bomba 2021-07-05 15:13:04 +10:00
parent a6494a68c2
commit a7076be746
4 changed files with 98 additions and 11 deletions

View File

@ -101,7 +101,6 @@ class CreditCard
];
$data['signature'] = $this->payfast->generateSignature($data);
nlog($data['signature']);
$data['gateway'] = $this->payfast;
$data['payment_endpoint_url'] = $this->payfast->endpointUrl();
@ -155,14 +154,35 @@ class CreditCard
$token = $this->payfast->storeGatewayToken($cgt, []);
nlog($token);
return response()->json([], 200);
return response()->json([], 200);
}
public function paymentView($data)
{
$data = [
'merchant_id' => $this->payfast->company_gateway->getConfigField('merchantId'),
'merchant_key' => $this->payfast->company_gateway->getConfigField('merchantKey'),
'return_url' => route('client.payment_methods.index'),
'cancel_url' => route('client.payment_methods.index'),
'notify_url' => $this->payfast->genericWebhookUrl(),
'm_payment_id' => $data['hash'],
'amount' => $data['amount_with_fee'],
'item_name' => 'purchase',
'item_description' => ctrans('texts.invoices') . ': ' . collect($data['invoices'])->pluck('invoice_number'),
'subscription_type' => 2,
'passphrase' => $this->payfast->company_gateway->getConfigField('passphrase'),
];
$data['signature'] = $this->payfast->generateSignature($data);
$data['gateway'] = $this->payfast;
$data['payment_endpoint_url'] = $this->payfast->endpointUrl();
return render('gateways.payfast.authorize', $data);
}
}

View File

@ -95,12 +95,12 @@ class PayFastPaymentDriver extends BaseDriver
public function authorizeView(array $data)
{
return $this->payment_method->authorizeView($data); //this is your custom implementation from here
return $this->payment_method->authorizeView($data);
}
public function authorizeResponse($request)
{
return $this->payment_method->authorizeResponse($request); //this is your custom implementation from here
return $this->payment_method->authorizeResponse($request);
}
public function processPaymentView(array $data)
@ -180,17 +180,13 @@ class PayFastPaymentDriver extends BaseDriver
}
}
nlog(md5(http_build_query($fields)));
return md5(http_build_query($fields));
}
public function processWebhookRequest(Request $request, Payment $payment = null)
{
// $this->init();
nlog($request->all());
$data = $request->all();
if(array_key_exists('m_payment_id', $data))

View File

@ -117,7 +117,6 @@ use WePayCommon;
nlog("authorize the card first!");
$response = $this->wepay_payment_driver->wepay->request('credit_card/authorize', array(
// 'callback_uri' => route('payment_webhook', ['company_key' => $this->wepay_payment_driver->company_gateway->company->company_key, 'company_gateway_id' => $this->wepay_payment_driver->company_gateway->hashed_id]),
'client_id' => config('ninja.wepay.client_id'),
'client_secret' => config('ninja.wepay.client_secret'),
'credit_card_id' => (int)$request->input('credit_card_id'),

View File

@ -0,0 +1,72 @@
@extends('portal.ninja2020.layout.payments', ['gateway_title' => ctrans('texts.credit_card'), 'card_title' => ctrans('texts.credit_card')])
@section('gateway_head')
<meta name="contact-email" content="{{ $contact->email }}">
<meta name="client-postal-code" content="{{ $contact->client->postal_code }}">
@endsection
@section('gateway_content')
<form action="{{ $payment_endpoint_url }}" method="post" id="server_response">
<input type="hidden" name="merchant_id" value="{{ $merchant_id }}">
<input type="hidden" name="merchant_key" value="{{ $merchant_key }}">
<input type="hidden" name="return_url" value="{{ $return_url }}">
<input type="hidden" name="cancel_url" value="{{ $cancel_url }}">
<input type="hidden" name="notify_url" value="{{ $notify_url }}">
<input type="hidden" name="m_payment_id" value="{{ $m_payment_id }}">
<input type="hidden" name="amount" value="{{ $amount }}">
<input type="hidden" name="item_name" value="{{ $item_name }}">
<input type="hidden" name="item_description" value="{{ $item_description}}">
<input type="hidden" name="subscription_type" value="{{ $subscription_type }}">
<input type="hidden" name="passphrase" value="{{ $passphrase }}">
<input type="hidden" name="signature" value="{{ $signature }}">
@if(!Request::isSecure())
<p class="alert alert-failure">{{ ctrans('texts.https_required') }}</p>
@endif
<div class="alert alert-failure mb-4" hidden id="errors"></div>
@component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.method')])
{{ ctrans('texts.credit_card') }}
@endcomponent
@include('portal.ninja2020.gateways.includes.payment_details')
@component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.pay_with')])
@if(count($tokens) > 0)
@foreach($tokens as $token)
<label class="mr-4">
<input
type="radio"
data-token="{{ $token->token }}"
name="payment-type"
class="form-radio cursor-pointer toggle-payment-with-token"/>
<span class="ml-1 cursor-pointer">**** {{ optional($token->meta)->last4 }}</span>
</label>
@endforeach
@endisset
<label>
<input
type="radio"
id="toggle-payment-with-credit-card"
class="form-radio cursor-pointer"
name="payment-type"
checked/>
<span class="ml-1 cursor-pointer">{{ __('texts.new_card') }}</span>
</label>
@endcomponent
@include('portal.ninja2020.gateways.includes.save_card')
@include('portal.ninja2020.gateways.wepay.includes.credit_card')
@include('portal.ninja2020.gateways.includes.pay_now')
</form>
@endsection
@section('gateway_footer')
@endsection