mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-10-30 22:27:32 -04:00 
			
		
		
		
	Merge pull request #4365 from turbo124/authorize_refactor
Authorize refactor
This commit is contained in:
		
						commit
						e57eee713a
					
				| @ -155,19 +155,19 @@ class InvoiceSum | ||||
|     { | ||||
|         $this->total += $this->total_taxes; | ||||
| 
 | ||||
|         if (is_numeric($this->invoice->custom_value1) && $this->invoice->custom_value1 > 0) { | ||||
|         if (is_numeric($this->invoice->custom_value1)) { | ||||
|             $this->total += $this->invoice->custom_value1; | ||||
|         } | ||||
| 
 | ||||
|         if (is_numeric($this->invoice->custom_value2) && $this->invoice->custom_value2 > 0) { | ||||
|         if (is_numeric($this->invoice->custom_value2)) { | ||||
|             $this->total += $this->invoice->custom_value2; | ||||
|         } | ||||
| 
 | ||||
|         if (is_numeric($this->invoice->custom_value3) && $this->invoice->custom_value3 > 0) { | ||||
|         if (is_numeric($this->invoice->custom_value3)) { | ||||
|             $this->total += $this->invoice->custom_value3; | ||||
|         } | ||||
| 
 | ||||
|         if (is_numeric($this->invoice->custom_value4) && $this->invoice->custom_value4 > 0) { | ||||
|         if (is_numeric($this->invoice->custom_value4)) { | ||||
|             $this->total += $this->invoice->custom_value4; | ||||
|         } | ||||
| 
 | ||||
|  | ||||
| @ -166,19 +166,19 @@ class InvoiceSumInclusive | ||||
|     { | ||||
|         //$this->total += $this->total_taxes;
 | ||||
| 
 | ||||
|         if (is_numeric($this->invoice->custom_value1) && $this->invoice->custom_value1 > 0) { | ||||
|         if (is_numeric($this->invoice->custom_value1)) { | ||||
|             $this->total += $this->invoice->custom_value1; | ||||
|         } | ||||
| 
 | ||||
|         if (is_numeric($this->invoice->custom_value2) && $this->invoice->custom_value2 > 0) { | ||||
|         if (is_numeric($this->invoice->custom_value2)) { | ||||
|             $this->total += $this->invoice->custom_value2; | ||||
|         } | ||||
| 
 | ||||
|         if (is_numeric($this->invoice->custom_value3) && $this->invoice->custom_value3 > 0) { | ||||
|         if (is_numeric($this->invoice->custom_value3)) { | ||||
|             $this->total += $this->invoice->custom_value3; | ||||
|         } | ||||
| 
 | ||||
|         if (is_numeric($this->invoice->custom_value4) && $this->invoice->custom_value4 > 0) { | ||||
|         if (is_numeric($this->invoice->custom_value4)) { | ||||
|             $this->total += $this->invoice->custom_value4; | ||||
|         } | ||||
| 
 | ||||
|  | ||||
| @ -11,15 +11,24 @@ | ||||
| 
 | ||||
| namespace App\PaymentDrivers; | ||||
| 
 | ||||
| use App\Models\ClientGatewayToken; | ||||
| use App\Models\Payment; | ||||
| use App\Models\PaymentHash; | ||||
| use Illuminate\Http\Request; | ||||
| 
 | ||||
| abstract class AbstractPaymentDriver | ||||
| { | ||||
|     abstract public function authorize($payment_method); | ||||
|     abstract public function authorizeView(array $data); | ||||
| 
 | ||||
|     abstract public function purchase($amount, $return_client_response = false); | ||||
|     abstract public function authorizeResponse(Request $request); | ||||
| 
 | ||||
|     abstract public function processPaymentView(array $data); | ||||
| 
 | ||||
|     abstract public function processPaymentResponse(Request $request); | ||||
| 
 | ||||
|     abstract public function refund(Payment $payment, $refund_amount, $return_client_response = false); | ||||
| 
 | ||||
|     abstract public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash); | ||||
| 
 | ||||
|     abstract public function setPaymentMethod($payment_method_id); | ||||
| } | ||||
|  | ||||
| @ -95,18 +95,31 @@ class AuthorizeCreditCard | ||||
| 
 | ||||
|         $data = (new ChargePaymentProfile($this->authorize))->chargeCustomerProfile($cgt->gateway_customer_reference, $cgt->token, $amount); | ||||
| 
 | ||||
|         /*Refactor and push to BaseDriver*/ | ||||
|         if ($data['response'] != null && $data['response']->getMessages()->getResultCode() == 'Ok') { | ||||
|             $payment = $this->createPaymentRecord($data, $amount); | ||||
|             $payment->meta = $cgt->meta; | ||||
|             $payment->save(); | ||||
| 
 | ||||
|             // $response = $data['response'];
 | ||||
| 
 | ||||
|             // $payment_record = [];
 | ||||
|             // $payment_record['amount'] = $amount;
 | ||||
|             // $payment_record['payment_type'] = PaymentType::CREDIT_CARD_OTHER;;
 | ||||
|             // $payment_record['transaction_reference'] = $response->getTransactionResponse()->getTransId();
 | ||||
| 
 | ||||
|             // $this->authorize->createPayment($payment_record);
 | ||||
|              | ||||
|             $payment_hash->payment_id = $payment->id; | ||||
|             $payment_hash->save(); | ||||
|             $this->storePayment($payment_hash, $data); | ||||
|              | ||||
|             // $payment = $this->createPaymentRecord($data, $amount);
 | ||||
|             // $payment->meta = $cgt->meta;
 | ||||
|             // $payment->save();
 | ||||
|              | ||||
|             // $payment_hash->payment_id = $payment->id;
 | ||||
|             // $payment_hash->save();
 | ||||
| 
 | ||||
|             $this->authorize->attachInvoices($payment, $payment_hash); | ||||
|             $payment->service()->updateInvoicePayment($payment_hash); | ||||
|             // $this->authorize->attachInvoices($payment, $payment_hash);
 | ||||
|             // $payment->service()->updateInvoicePayment($payment_hash);
 | ||||
| 
 | ||||
|             event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars())); | ||||
|             // event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars()));
 | ||||
| 
 | ||||
|             $vars = [ | ||||
|                 'hashed_ids' => $invoice->hashed_id, | ||||
| @ -126,6 +139,12 @@ class AuthorizeCreditCard | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     private function handleResponse($data, $request) | ||||
|     { | ||||
|         $response = $data['response']; | ||||
| @ -143,16 +162,14 @@ class AuthorizeCreditCard | ||||
|     { | ||||
|         $amount = array_sum(array_column($payment_hash->invoices(), 'amount')) + $payment_hash->fee_total; | ||||
| 
 | ||||
|         $payment = $this->createPaymentRecord($data, $amount); | ||||
|          | ||||
|         $payment_hash->payment_id = $payment->id; | ||||
|         $payment_hash->save(); | ||||
|         $response = $data['response']; | ||||
| 
 | ||||
|         $this->authorize->attachInvoices($payment, $payment_hash); | ||||
|         $payment_record = []; | ||||
|         $payment_record['amount'] = $amount; | ||||
|         $payment_record['payment_type'] = PaymentType::CREDIT_CARD_OTHER;; | ||||
|         $payment_record['transaction_reference'] = $response->getTransactionResponse()->getTransId(); | ||||
| 
 | ||||
|         $payment->service()->updateInvoicePayment($payment_hash); | ||||
| 
 | ||||
|         event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars())); | ||||
|         $payment = $this->authorize->createPayment($payment_record); | ||||
| 
 | ||||
|         return $payment; | ||||
|     } | ||||
|  | ||||
| @ -16,6 +16,8 @@ use App\Exceptions\GenericPaymentDriverFailure; | ||||
| use App\Models\ClientGatewayToken; | ||||
| use App\Models\GatewayType; | ||||
| use App\PaymentDrivers\AuthorizePaymentDriver; | ||||
| use App\PaymentDrivers\Authorize\AuthorizeCreateCustomer; | ||||
| use App\PaymentDrivers\Authorize\AuthorizeCreditCard; | ||||
| use net\authorize\api\contract\v1\CreateCustomerPaymentProfileRequest; | ||||
| use net\authorize\api\contract\v1\CustomerAddressType; | ||||
| use net\authorize\api\contract\v1\CustomerPaymentProfileType; | ||||
| @ -35,34 +37,37 @@ class AuthorizePaymentMethod | ||||
| 
 | ||||
|     public $payment_method; | ||||
| 
 | ||||
|     private $payment_method_id; | ||||
| 
 | ||||
|     public function __construct(AuthorizePaymentDriver $authorize) | ||||
|     { | ||||
|         $this->authorize = $authorize; | ||||
|     } | ||||
| 
 | ||||
|     public function authorizeView($payment_method) | ||||
|     public function authorizeView() | ||||
|     { | ||||
|         $this->payment_method = $payment_method; | ||||
|         if($this->authorize->payment_method instanceof AuthorizeCreditCard){ | ||||
| 
 | ||||
|         switch ($payment_method) { | ||||
|             case GatewayType::CREDIT_CARD: | ||||
|                 return $this->authorizeCreditCard(); | ||||
|                 break; | ||||
|             case GatewayType::BANK_TRANSFER: | ||||
|                 return $this->authorizeBankTransfer(); | ||||
|                 break; | ||||
|             $this->payment_method_id = GatewayType::CREDIT_CARD; | ||||
| 
 | ||||
|             return $this->authorizeCreditCard(); | ||||
| 
 | ||||
|             default: | ||||
|                 // code...
 | ||||
|                 break; | ||||
|         } | ||||
| 
 | ||||
|          | ||||
|         // case GatewayType::BANK_TRANSFER:
 | ||||
|         //     return $this->authorizeBankTransfer();
 | ||||
|         //     break;
 | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     public function authorizeResponseView($data) | ||||
|     public function authorizeResponseView($request) | ||||
|     { | ||||
|         $this->payment_method = $data['payment_method_id']; | ||||
|         $data = $request->all(); | ||||
|          | ||||
|         $this->payment_method_id = $data['method']; | ||||
| 
 | ||||
|         switch ($this->payment_method) { | ||||
|         switch ($this->payment_method_id) { | ||||
|             case GatewayType::CREDIT_CARD: | ||||
|                 return $this->authorizeCreditCardResponse($data); | ||||
|                 break; | ||||
| @ -111,19 +116,17 @@ class AuthorizePaymentMethod | ||||
| 
 | ||||
|     public function createClientGatewayToken($payment_profile, $gateway_customer_reference) | ||||
|     { | ||||
|         //  info(print_r($payment_profile,1));
 | ||||
| 
 | ||||
|         $client_gateway_token = new ClientGatewayToken(); | ||||
|         $client_gateway_token->company_id = $this->authorize->client->company_id; | ||||
|         $client_gateway_token->client_id = $this->authorize->client->id; | ||||
|         $client_gateway_token->token = $payment_profile->getPaymentProfile()->getCustomerPaymentProfileId(); | ||||
|         $client_gateway_token->company_gateway_id = $this->authorize->company_gateway->id; | ||||
|         $client_gateway_token->gateway_type_id = $this->payment_method; | ||||
|         $client_gateway_token->gateway_customer_reference = $gateway_customer_reference; | ||||
|         $client_gateway_token->meta = $this->buildPaymentMethod($payment_profile); | ||||
|         $client_gateway_token->save(); | ||||
|         $data = []; | ||||
|         $additonal = []; | ||||
| 
 | ||||
|         return $client_gateway_token; | ||||
|         $data['token'] = $payment_profile->getPaymentProfile()->getCustomerPaymentProfileId(); | ||||
|         $data['payment_method_id'] = $this->payment_method_id; | ||||
|         $data['payment_meta'] = $this->buildPaymentMethod($payment_profile); | ||||
| 
 | ||||
|         $additional['gateway_customer_reference'] = $gateway_customer_reference; | ||||
| 
 | ||||
|         $this->authorize->storeGatewayToken($data, $additional); | ||||
|     } | ||||
| 
 | ||||
|     public function buildPaymentMethod($payment_profile) | ||||
|  | ||||
| @ -63,6 +63,38 @@ class AuthorizePaymentDriver extends BaseDriver | ||||
|         return $types; | ||||
|     } | ||||
| 
 | ||||
|     public function authorizeView($payment_method) | ||||
|     { | ||||
|         return (new AuthorizePaymentMethod($this))->authorizeView(); | ||||
|     } | ||||
| 
 | ||||
|     public function authorizeResponse($request) | ||||
|     { | ||||
|         return (new AuthorizePaymentMethod($this))->authorizeResponseView($request); | ||||
|     } | ||||
| 
 | ||||
|     public function processPaymentView($data) | ||||
|     { | ||||
|         return $this->payment_method->processPaymentView($data); | ||||
|     } | ||||
| 
 | ||||
|     public function processPaymentResponse($request) | ||||
|     { | ||||
|         return $this->payment_method->processPaymentResponse($request); | ||||
|     } | ||||
| 
 | ||||
|     public function refund(Payment $payment, $refund_amount, $return_client_response = false) | ||||
|     { | ||||
|         return (new RefundTransaction($this))->refundTransaction($payment, $refund_amount); | ||||
|     } | ||||
| 
 | ||||
|     public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash) | ||||
|     { | ||||
|         $this->setPaymentMethod($cgt->gateway_type_id); | ||||
| 
 | ||||
|         return $this->payment_method->tokenBilling($cgt, $payment_hash); | ||||
|     } | ||||
| 
 | ||||
|     public function init() | ||||
|     { | ||||
|         error_reporting(E_ALL & ~E_DEPRECATED); | ||||
| @ -94,59 +126,6 @@ class AuthorizePaymentDriver extends BaseDriver | ||||
|         return $env = ANetEnvironment::PRODUCTION; | ||||
|     } | ||||
| 
 | ||||
|     public function authorizeView($payment_method) | ||||
|     { | ||||
|         if (count($this->required_fields) > 0) { | ||||
|             return redirect() | ||||
|                 ->route('client.profile.edit', ['client_contact' => auth()->user()->hashed_id]) | ||||
|                 ->with('missing_required_fields', $this->required_fields); | ||||
|         } | ||||
| 
 | ||||
|         return (new AuthorizePaymentMethod($this))->authorizeView($payment_method); | ||||
|     } | ||||
| 
 | ||||
|     public function authorizeResponseView(array $data) | ||||
|     { | ||||
|         return (new AuthorizePaymentMethod($this))->authorizeResponseView($data); | ||||
|     } | ||||
| 
 | ||||
|     public function authorize($payment_method) | ||||
|     { | ||||
|         return $this->authorizeView($payment_method); | ||||
|     } | ||||
| 
 | ||||
|     public function processPaymentView($data) | ||||
|     { | ||||
|         if (count($this->required_fields) > 0) { | ||||
|             return redirect() | ||||
|                 ->route('client.profile.edit', ['client_contact' => auth()->user()->hashed_id]) | ||||
|                 ->with('missing_required_fields', $this->required_fields); | ||||
|         } | ||||
| 
 | ||||
|         return $this->payment_method->processPaymentView($data); | ||||
|     } | ||||
| 
 | ||||
|     public function processPaymentResponse($request) | ||||
|     { | ||||
|         if (count($this->required_fields) > 0) { | ||||
|             return redirect() | ||||
|                 ->route('client.profile.edit', ['client_contact' => auth()->user()->hashed_id]) | ||||
|                 ->with('missing_required_fields', $this->required_fields); | ||||
|         } | ||||
| 
 | ||||
|         return $this->payment_method->processPaymentResponse($request); | ||||
|     } | ||||
| 
 | ||||
|     public function purchase($amount, $return_client_response = false) | ||||
|     { | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
|     public function refund(Payment $payment, $refund_amount, $return_client_response = false) | ||||
|     { | ||||
|         return (new RefundTransaction($this))->refundTransaction($payment, $refund_amount); | ||||
|     } | ||||
| 
 | ||||
|     public function findClientGatewayRecord() :?ClientGatewayToken | ||||
|     { | ||||
|         return ClientGatewayToken::where('client_id', $this->client->id) | ||||
| @ -154,12 +133,6 @@ class AuthorizePaymentDriver extends BaseDriver | ||||
|                                  ->first(); | ||||
|     } | ||||
| 
 | ||||
|     public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash) | ||||
|     { | ||||
|         $this->setPaymentMethod($cgt->gateway_type_id); | ||||
| 
 | ||||
|         return $this->payment_method->tokenBilling($cgt, $payment_hash); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Detach payment method from Authorize.net. | ||||
|  | ||||
| @ -32,7 +32,7 @@ use App\Utils\Traits\SystemLogTrait; | ||||
| use Checkout\Library\Exceptions\CheckoutHttpException; | ||||
| use Exception; | ||||
| use Illuminate\Support\Carbon; | ||||
| use Illuminate\Support\Str; | ||||
| use Illuminate\Http\Request; | ||||
| 
 | ||||
| /** | ||||
|  * Class BaseDriver. | ||||
| @ -60,14 +60,13 @@ class BaseDriver extends AbstractPaymentDriver | ||||
|     /* The client */ | ||||
|     public $client; | ||||
| 
 | ||||
|     /* The initiated gateway driver class*/ | ||||
|     /* The initialized gateway driver class*/ | ||||
|     public $payment_method; | ||||
| 
 | ||||
|     /** | ||||
|      * @var PaymentHash | ||||
|      */ | ||||
|     /* PaymentHash */ | ||||
|     public $payment_hash; | ||||
| 
 | ||||
|     /* Array of payment methods */ | ||||
|     public static $methods = []; | ||||
|      | ||||
|     /** @var array */ | ||||
| @ -76,9 +75,7 @@ class BaseDriver extends AbstractPaymentDriver | ||||
|     public function __construct(CompanyGateway $company_gateway, Client $client = null, $invitation = false) | ||||
|     { | ||||
|         $this->company_gateway = $company_gateway; | ||||
| 
 | ||||
|         $this->invitation = $invitation; | ||||
| 
 | ||||
|         $this->client = $client; | ||||
|     } | ||||
| 
 | ||||
| @ -86,23 +83,35 @@ class BaseDriver extends AbstractPaymentDriver | ||||
|      * Authorize a payment method. | ||||
|      * | ||||
|      * Returns a reusable token for storage for future payments | ||||
|      * @param const $payment_method The GatewayType::constant | ||||
|      * @return void Return a view for collecting payment method information | ||||
|      *  | ||||
|      * @param array $data | ||||
|      * @return mixed Return a view for collecting payment method information | ||||
|      */ | ||||
|     public function authorize($payment_method) | ||||
|     { | ||||
|     } | ||||
|     public function authorizeView(array $data) {} | ||||
| 
 | ||||
|     /** | ||||
|      * Executes purchase attempt for a given amount. | ||||
|      * | ||||
|      * @param  float   $amount                  The amount to be collected | ||||
|      * @param  bool $return_client_response     Whether the method needs to return a response (otherwise we assume an unattended payment) | ||||
|      * @return mixed | ||||
|      * The payment authorization response | ||||
|      *          | ||||
|      * @param  Request $request  | ||||
|      * @return mixed Return a response for collecting payment method information | ||||
|      */ | ||||
|     public function purchase($amount, $return_client_response = false) | ||||
|     { | ||||
|     } | ||||
|     public function authorizeResponse(Request $request) {} | ||||
| 
 | ||||
|     /** | ||||
|      * Process a payment | ||||
|      *  | ||||
|      * @param  array $data  | ||||
|      * @return mixed Return a view for the payment | ||||
|      */ | ||||
|     public function processPaymentView(array $data) {} | ||||
| 
 | ||||
|     /** | ||||
|      * Process payment response | ||||
|      *  | ||||
|      * @param  Request $request | ||||
|      * @return mixed   Return a response for the payment | ||||
|      */ | ||||
|     public function processPaymentResponse(Request $request) {} | ||||
| 
 | ||||
|     /** | ||||
|      * Executes a refund attempt for a given amount with a transaction_reference. | ||||
| @ -112,23 +121,30 @@ class BaseDriver extends AbstractPaymentDriver | ||||
|      * @param  bool $return_client_response    Whether the method needs to return a response (otherwise we assume an unattended payment) | ||||
|      * @return mixed | ||||
|      */ | ||||
|     public function refund(Payment $payment, $amount, $return_client_response = false) | ||||
|     { | ||||
|     } | ||||
|     public function refund(Payment $payment, $amount, $return_client_response = false) {} | ||||
| 
 | ||||
|     /** | ||||
|      * Process an unattended payment. | ||||
|      * | ||||
|      * @param ClientGatewayToken $cgt The client gateway token object | ||||
|      * @param PaymentHash $payment_hash The Payment hash containing the payment meta data | ||||
|      * @return void The payment response | ||||
|      */ | ||||
|     public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash){} | ||||
| 
 | ||||
|     /** | ||||
|      * Set the inbound request payment method type for access. | ||||
|      * | ||||
|      * @param int $payment_method_id The Payment Method ID | ||||
|      */ | ||||
|     public function setPaymentMethod($payment_method_id) | ||||
|     { | ||||
|     } | ||||
|     public function setPaymentMethod($payment_method_id){} | ||||
| 
 | ||||
| 
 | ||||
|     /************************** Helper methods *************************************/ | ||||
| 
 | ||||
|     public function setPaymentHash(PaymentHash $payment_hash) | ||||
|     { | ||||
|         $this->payment_hash = $payment_hash; | ||||
| 
 | ||||
|         return $this; | ||||
|     } | ||||
| 
 | ||||
| @ -189,17 +205,6 @@ class BaseDriver extends AbstractPaymentDriver | ||||
|         return $payment->service()->applyNumber()->save(); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Process an unattended payment. | ||||
|      * | ||||
|      * @param ClientGatewayToken $cgt The client gateway token object | ||||
|      * @param PaymentHash $payment_hash The Payment hash containing the payment meta data | ||||
|      * @return void The payment response | ||||
|      */ | ||||
|     public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash) | ||||
|     { | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * When a successful payment is made, we need to append the gateway fee | ||||
|      * to an invoice. | ||||
| @ -215,7 +220,7 @@ class BaseDriver extends AbstractPaymentDriver | ||||
|         /*Payment invoices*/ | ||||
|         $payment_invoices = $payment_hash->invoices(); | ||||
| 
 | ||||
|         // /*Fee charged at gateway*/
 | ||||
|         /*Fee charged at gateway*/ | ||||
|         $fee_total = $payment_hash->fee_total; | ||||
| 
 | ||||
|         // Sum of invoice amounts
 | ||||
| @ -265,7 +270,6 @@ class BaseDriver extends AbstractPaymentDriver | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * Store payment method as company gateway token. | ||||
|      * | ||||
|  | ||||
							
								
								
									
										73
									
								
								app/PaymentDrivers/DriverTemplate.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										73
									
								
								app/PaymentDrivers/DriverTemplate.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,73 @@ | ||||
| <?php | ||||
| /** | ||||
|  * Invoice Ninja (https://invoiceninja.com). | ||||
|  * | ||||
|  * @link https://github.com/invoiceninja/invoiceninja source repository | ||||
|  * | ||||
|  * @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com) | ||||
|  * | ||||
|  * @license https://opensource.org/licenses/AAL | ||||
|  */ | ||||
| 
 | ||||
| namespace App\PaymentDrivers; | ||||
| 
 | ||||
| use App\Utils\Traits\MakesHash; | ||||
| 
 | ||||
| class YourGatewayPaymentDriver extends BaseDriver | ||||
| { | ||||
|     use MakesHash; | ||||
| 
 | ||||
|     public $refundable = true; //does this gateway support refunds?
 | ||||
| 
 | ||||
|     public $token_billing = true; //does this gateway support token billing?
 | ||||
| 
 | ||||
|     public $can_authorise_credit_card = true; //does this gateway support authorizations?
 | ||||
| 
 | ||||
|     public $gateway; //initialized gateway
 | ||||
| 
 | ||||
|     public $payment_method; //initialized payment method
 | ||||
| 
 | ||||
|     public static $methods = [ | ||||
|         GatewayType::CREDIT_CARD => CreditCard::class, //maps GatewayType => Implementation class
 | ||||
|     ]; | ||||
| 
 | ||||
|     const SYSTEM_LOG_TYPE = SystemLog::TYPE_STRIPE; | ||||
| 
 | ||||
|     public function setPaymentMethod($payment_method_id) | ||||
|     { | ||||
|         $class = self::$methods[$payment_method_id]; | ||||
|         $this->payment_method = new $class($this); | ||||
|         return $this; | ||||
|     } | ||||
| 
 | ||||
|     public function authorizeView(array $data) | ||||
|     { | ||||
|         return $this->payment_method->authorizeView($data); //this is your custom implementation from here
 | ||||
|     } | ||||
| 
 | ||||
|     public function authorizeResponse($request) | ||||
|     { | ||||
|         return $this->payment_method->authorizeResponse($request);  //this is your custom implementation from here
 | ||||
|     } | ||||
| 
 | ||||
|     public function processPaymentView(array $data) | ||||
|     { | ||||
|         return $this->payment_method->paymentView($data);  //this is your custom implementation from here
 | ||||
|     } | ||||
| 
 | ||||
|     public function processPaymentResponse($request)  | ||||
|     { | ||||
|         return $this->payment_method->paymentResponse($request); //this is your custom implementation from here
 | ||||
|     } | ||||
| 
 | ||||
|     public function refund(Payment $payment, $amount, $return_client_response = false) | ||||
|     { | ||||
|     	return $this->payment_method->yourRefundImplementationHere(); //this is your custom implementation from here
 | ||||
|     } | ||||
| 
 | ||||
|     public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash) | ||||
|     { | ||||
|         return $this->payment_method->yourTokenBillingImplmentation(); //this is your custom implementation from here
 | ||||
|     } | ||||
|      | ||||
| } | ||||
| @ -75,6 +75,8 @@ class Phantom | ||||
|         $phantom_url = "https://phantomjscloud.com/api/browser/v2/{$key}/?request=%7Burl:%22{$url}%22,renderType:%22pdf%22%7D"; | ||||
|         $pdf = CurlUtils::get($phantom_url); | ||||
| 
 | ||||
|         //info($pdf);
 | ||||
| 
 | ||||
|         Storage::makeDirectory($path, 0775); | ||||
| 
 | ||||
|         $instance = Storage::disk(config('filesystems.default'))->put($file_path, $pdf); | ||||
|  | ||||
| @ -60,7 +60,8 @@ return [ | ||||
| 
 | ||||
|         'public' => [ | ||||
|             'driver' => 'local', | ||||
|             'root' => storage_path('app/public'), | ||||
|             'root' => 'storage/', | ||||
|             // 'root' => storage_path('app/public'),
 | ||||
|             'url' => env('APP_URL').'/storage', | ||||
|             'visibility' => 'public', | ||||
|             'permissions' => [ | ||||
|  | ||||
| @ -17,7 +17,8 @@ | ||||
| @endpush | ||||
| 
 | ||||
| @section('body') | ||||
| <form action="{{ route('client.payment_methods.store') }}" method="post" id="server_response"> | ||||
| <form action="{{ route('client.payment_methods.store', ['method' => App\Models\GatewayType::CREDIT_CARD]) }}" method="post" id="server_response"> | ||||
| 
 | ||||
|     @csrf | ||||
|     <input type="hidden" name="company_gateway_id" value="{{ $gateway->id }}"> | ||||
|     <input type="hidden" name="payment_method_id" value="1"> | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user