mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 03:17:35 -05:00 
			
		
		
		
	Refactor common code WePay
This commit is contained in:
		
							parent
							
								
									2075c4e8c1
								
							
						
					
					
						commit
						4eda6b1190
					
				@ -15,13 +15,17 @@ namespace App\PaymentDrivers\WePay;
 | 
				
			|||||||
use App\Exceptions\PaymentFailed;
 | 
					use App\Exceptions\PaymentFailed;
 | 
				
			||||||
use App\Models\ClientGatewayToken;
 | 
					use App\Models\ClientGatewayToken;
 | 
				
			||||||
use App\Models\GatewayType;
 | 
					use App\Models\GatewayType;
 | 
				
			||||||
 | 
					use App\Models\Payment;
 | 
				
			||||||
use App\PaymentDrivers\WePayPaymentDriver;
 | 
					use App\PaymentDrivers\WePayPaymentDriver;
 | 
				
			||||||
 | 
					use App\PaymentDrivers\WePay\WePayCommon;
 | 
				
			||||||
use App\Utils\Traits\MakesHash;
 | 
					use App\Utils\Traits\MakesHash;
 | 
				
			||||||
use Illuminate\Http\Request;
 | 
					use Illuminate\Http\Request;
 | 
				
			||||||
 | 
					use Illuminate\Support\Str;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ACH
 | 
					class ACH
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    use MakesHash;
 | 
					    use MakesHash;
 | 
				
			||||||
 | 
					    use WePayCommon;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $wepay_payment_driver;
 | 
					    public $wepay_payment_driver;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -193,101 +197,49 @@ class ACH
 | 
				
			|||||||
        if($token_meta->state != "authorized")
 | 
					        if($token_meta->state != "authorized")
 | 
				
			||||||
            return redirect()->route('client.payment_methods.verification', ['payment_method' => $token->hashed_id, 'method' => GatewayType::BANK_TRANSFER]);
 | 
					            return redirect()->route('client.payment_methods.verification', ['payment_method' => $token->hashed_id, 'method' => GatewayType::BANK_TRANSFER]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $response = $this->wepay_payment_driver->wepay->request('checkout/create', array(
 | 
				
			||||||
 | 
					            'unique_id'           => Str::random(40),
 | 
				
			||||||
 | 
					            'account_id'          => $this->wepay_payment_driver->company_gateway->getConfigField('accountId'),
 | 
				
			||||||
 | 
					            'amount'              => $this->wepay_payment_driver->payment_hash->data->amount_with_fee,
 | 
				
			||||||
 | 
					            'currency'            => $this->wepay_payment_driver->client->getCurrencyCode(),
 | 
				
			||||||
 | 
					            'short_description'   => 'A vacation home rental',
 | 
				
			||||||
 | 
					            'type'                => 'goods',
 | 
				
			||||||
 | 
					            'payment_method'      => array(
 | 
				
			||||||
 | 
					                'type'            => 'payment_bank',
 | 
				
			||||||
 | 
					                'payment_bank'     => array(
 | 
				
			||||||
 | 
					                    'id'          => $token->token
 | 
				
			||||||
 | 
					                )
 | 
				
			||||||
 | 
					            )
 | 
				
			||||||
 | 
					        ));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                /* Merge all data and store in the payment hash*/
 | 
				
			||||||
 | 
					        $state = [
 | 
				
			||||||
 | 
					            'server_response' => $response,
 | 
				
			||||||
 | 
					            'payment_hash' => $request->payment_hash,
 | 
				
			||||||
 | 
					        ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $state = array_merge($state, $request->all());
 | 
				
			||||||
 | 
					        $this->wepay_payment_driver->payment_hash->data = array_merge((array) $this->wepay_payment_driver->payment_hash->data, $state); 
 | 
				
			||||||
 | 
					        $this->wepay_payment_driver->payment_hash->save();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(in_array($response->state, ['authorized', 'captured'])){
 | 
				
			||||||
 | 
					            //success
 | 
				
			||||||
 | 
					            nlog("success");
 | 
				
			||||||
 | 
					            $payment_status = $response->state == 'authorized' ? Payment::STATUS_COMPLETED : Payment::STATUS_PENDING;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return $this->processSuccessfulPayment($response, $payment_status, GatewayType::BANK_TRANSFER);
 | 
				
			||||||
// response = wepay.call('/checkout/create', {
 | 
					 | 
				
			||||||
//     'account_id': account_id,
 | 
					 | 
				
			||||||
//     'amount': '25.50',
 | 
					 | 
				
			||||||
//     'short_description': 'A vacation home rental',
 | 
					 | 
				
			||||||
//     'type': 'GOODS', 
 | 
					 | 
				
			||||||
//     'payment_method': {
 | 
					 | 
				
			||||||
//         'type': 'payment_bank',
 | 
					 | 
				
			||||||
//         'payment_bank': {
 | 
					 | 
				
			||||||
//             'id': 20000061
 | 
					 | 
				
			||||||
//         }
 | 
					 | 
				
			||||||
//     }
 | 
					 | 
				
			||||||
// })
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // $this->stripe->init();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // $source = ClientGatewayToken::query()
 | 
					 | 
				
			||||||
        //     ->where('id', $this->decodePrimaryKey($request->source))
 | 
					 | 
				
			||||||
        //     ->where('company_id', auth('contact')->user()->client->company->id)
 | 
					 | 
				
			||||||
        //     ->first();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // if (!$source) {
 | 
					 | 
				
			||||||
        //     throw new PaymentFailed(ctrans('texts.payment_token_not_found'), 401);
 | 
					 | 
				
			||||||
        // }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // $state = [
 | 
					 | 
				
			||||||
        //     'payment_method' => $request->payment_method_id,
 | 
					 | 
				
			||||||
        //     'gateway_type_id' => $request->company_gateway_id,
 | 
					 | 
				
			||||||
        //     'amount' => $this->stripe->convertToStripeAmount($request->amount, $this->stripe->client->currency()->precision),
 | 
					 | 
				
			||||||
        //     'currency' => $request->currency,
 | 
					 | 
				
			||||||
        //     'customer' => $request->customer,
 | 
					 | 
				
			||||||
        // ];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // $state = array_merge($state, $request->all());
 | 
					 | 
				
			||||||
        // $state['source'] = $source->token;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // $this->stripe->payment_hash->data = array_merge((array)$this->stripe->payment_hash->data, $state);
 | 
					 | 
				
			||||||
        // $this->stripe->payment_hash->save();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // try {
 | 
					 | 
				
			||||||
        //     $state['charge'] = \Stripe\Charge::create([
 | 
					 | 
				
			||||||
        //         'amount' => $state['amount'],
 | 
					 | 
				
			||||||
        //         'currency' => $state['currency'],
 | 
					 | 
				
			||||||
        //         'customer' => $state['customer'],
 | 
					 | 
				
			||||||
        //         'source' => $state['source'],
 | 
					 | 
				
			||||||
        //     ], $this->stripe->stripe_connect_auth);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //     $state = array_merge($state, $request->all());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //     $this->stripe->payment_hash->data = array_merge((array)$this->stripe->payment_hash->data, $state);
 | 
					 | 
				
			||||||
        //     $this->stripe->payment_hash->save();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //     if ($state['charge']->status === 'pending' && is_null($state['charge']->failure_message)) {
 | 
					 | 
				
			||||||
        //         return $this->processPendingPayment($state);
 | 
					 | 
				
			||||||
        //     }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //     return $this->processUnsuccessfulPayment($state);
 | 
					 | 
				
			||||||
        // } catch (Exception $e) {
 | 
					 | 
				
			||||||
        //     if ($e instanceof CardException) {
 | 
					 | 
				
			||||||
        //         return redirect()->route('client.payment_methods.verification', ['id' => ClientGatewayToken::first()->hashed_id, 'method' => GatewayType::BANK_TRANSFER]);
 | 
					 | 
				
			||||||
        //     }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //     throw new PaymentFailed($e->getMessage(), $e->getCode());
 | 
					 | 
				
			||||||
        // }
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(in_array($response->state, ['released', 'cancelled', 'failed', 'expired'])){
 | 
				
			||||||
 | 
					            //some type of failure
 | 
				
			||||||
 | 
					            nlog("failure");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            $payment_status = $response->state == 'cancelled' ? Payment::STATUS_CANCELLED : Payment::STATUS_FAILED;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            $this->processUnSuccessfulPayment($response, $payment_status);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function storePaymentMethod($response, $payment_method_id)
 | 
					    private function storePaymentMethod($response, $payment_method_id)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
				
			|||||||
@ -21,9 +21,13 @@ use App\Models\Payment;
 | 
				
			|||||||
use App\Models\PaymentType;
 | 
					use App\Models\PaymentType;
 | 
				
			||||||
use App\Models\SystemLog;
 | 
					use App\Models\SystemLog;
 | 
				
			||||||
use App\PaymentDrivers\WePayPaymentDriver;
 | 
					use App\PaymentDrivers\WePayPaymentDriver;
 | 
				
			||||||
 | 
					use App\PaymentDrivers\WePay\WePayCommon;
 | 
				
			||||||
 | 
					use Illuminate\Support\Str;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class CreditCard
 | 
					class CreditCard
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					use WePayCommon;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $wepay_payment_driver;
 | 
					    public $wepay_payment_driver;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function __construct(WePayPaymentDriver $wepay_payment_driver)
 | 
					    public function __construct(WePayPaymentDriver $wepay_payment_driver)
 | 
				
			||||||
@ -98,6 +102,7 @@ class CreditCard
 | 
				
			|||||||
    public function paymentView(array $data)
 | 
					    public function paymentView(array $data)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $data['gateway'] = $this->wepay_payment_driver;
 | 
					        $data['gateway'] = $this->wepay_payment_driver;
 | 
				
			||||||
 | 
					        $data['description'] = ctrans('texts.invoices') . ': ' . collect($data['invoices'])->pluck('invoice_number');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return render('gateways.wepay.credit_card.pay', $data);
 | 
					        return render('gateways.wepay.credit_card.pay', $data);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -105,7 +110,6 @@ class CreditCard
 | 
				
			|||||||
    public function paymentResponse(PaymentResponseRequest $request)
 | 
					    public function paymentResponse(PaymentResponseRequest $request)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        nlog("payment response");
 | 
					        nlog("payment response");
 | 
				
			||||||
        $this->wepay_payment_driver->init();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //it could be an existing token or a new credit_card_id that needs to be converted into a wepay token
 | 
					        //it could be an existing token or a new credit_card_id that needs to be converted into a wepay token
 | 
				
			||||||
        if($request->has('credit_card_id') && $request->input('credit_card_id'))
 | 
					        if($request->has('credit_card_id') && $request->input('credit_card_id'))
 | 
				
			||||||
@ -120,9 +124,6 @@ class CreditCard
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            $credit_card_id = (int)$response->credit_card_id;
 | 
					            $credit_card_id = (int)$response->credit_card_id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
nlog($response->state);
 | 
					 | 
				
			||||||
nlog(boolval($request->input('store_card')));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if(in_array($response->state, ['new', 'authorized']) && boolval($request->input('store_card'))){
 | 
					            if(in_array($response->state, ['new', 'authorized']) && boolval($request->input('store_card'))){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                $this->storePaymentMethod($response, GatewayType::CREDIT_CARD);
 | 
					                $this->storePaymentMethod($response, GatewayType::CREDIT_CARD);
 | 
				
			||||||
@ -140,6 +141,7 @@ nlog(boolval($request->input('store_card')));
 | 
				
			|||||||
        nlog($request->all());
 | 
					        nlog($request->all());
 | 
				
			||||||
        // charge the credit card
 | 
					        // charge the credit card
 | 
				
			||||||
        $response = $this->wepay_payment_driver->wepay->request('checkout/create', array(
 | 
					        $response = $this->wepay_payment_driver->wepay->request('checkout/create', array(
 | 
				
			||||||
 | 
					            'unique_id'           => Str::random(40),
 | 
				
			||||||
            'account_id'          => $this->wepay_payment_driver->company_gateway->getConfigField('accountId'),
 | 
					            'account_id'          => $this->wepay_payment_driver->company_gateway->getConfigField('accountId'),
 | 
				
			||||||
            'amount'              => $this->wepay_payment_driver->payment_hash->data->amount_with_fee,
 | 
					            'amount'              => $this->wepay_payment_driver->payment_hash->data->amount_with_fee,
 | 
				
			||||||
            'currency'            => $this->wepay_payment_driver->client->getCurrencyCode(),
 | 
					            'currency'            => $this->wepay_payment_driver->client->getCurrencyCode(),
 | 
				
			||||||
@ -169,7 +171,7 @@ nlog(boolval($request->input('store_card')));
 | 
				
			|||||||
            nlog("success");
 | 
					            nlog("success");
 | 
				
			||||||
            $payment_status = $response->state == 'authorized' ? Payment::STATUS_COMPLETED : Payment::STATUS_PENDING;
 | 
					            $payment_status = $response->state == 'authorized' ? Payment::STATUS_COMPLETED : Payment::STATUS_PENDING;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return $this->processSuccessfulPayment($response, $payment_status);
 | 
					            return $this->processSuccessfulPayment($response, $payment_status, GatewayType::CREDIT_CARD);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(in_array($response->state, ['released', 'cancelled', 'failed', 'expired'])){
 | 
					        if(in_array($response->state, ['released', 'cancelled', 'failed', 'expired'])){
 | 
				
			||||||
@ -250,57 +252,6 @@ https://developer.wepay.com/api/api-calls/checkout
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function processSuccessfulPayment($response, $payment_status)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $data = [
 | 
					 | 
				
			||||||
            'payment_type' => PaymentType::CREDIT_CARD_OTHER,
 | 
					 | 
				
			||||||
            'amount' => $response->amount,
 | 
					 | 
				
			||||||
            'transaction_reference' => $response->checkout_id,
 | 
					 | 
				
			||||||
            'gateway_type_id' => GatewayType::CREDIT_CARD,
 | 
					 | 
				
			||||||
        ];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $payment = $this->wepay_payment_driver->createPayment($data, $payment_status);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
         SystemLogger::dispatch(
 | 
					 | 
				
			||||||
            ['response' => $this->wepay_payment_driver->payment_hash->data->server_response, 'data' => $data],
 | 
					 | 
				
			||||||
            SystemLog::CATEGORY_GATEWAY_RESPONSE,
 | 
					 | 
				
			||||||
            SystemLog::EVENT_GATEWAY_SUCCESS,
 | 
					 | 
				
			||||||
            SystemLog::TYPE_WEPAY,
 | 
					 | 
				
			||||||
            $this->wepay_payment_driver->client,
 | 
					 | 
				
			||||||
            $this->wepay_payment_driver->client->company,
 | 
					 | 
				
			||||||
        );
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return redirect()->route('client.payments.show', ['payment' => $this->wepay_payment_driver->encodePrimaryKey($payment->id)]);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private function processUnSuccessfulPayment($response, $payment_status)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        PaymentFailureMailer::dispatch($this->wepay_payment_driver->client, $response->state, $this->wepay_payment_driver->client->company, $response->gross);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        PaymentFailureMailer::dispatch(
 | 
					 | 
				
			||||||
            $this->wepay_payment_driver->client,
 | 
					 | 
				
			||||||
            $response,
 | 
					 | 
				
			||||||
            $this->wepay_payment_driver->client->company,
 | 
					 | 
				
			||||||
            $response->gross
 | 
					 | 
				
			||||||
        );
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $message = [
 | 
					 | 
				
			||||||
            'server_response' => $response,
 | 
					 | 
				
			||||||
            'data' => $this->wepay_payment_driver->payment_hash->data,
 | 
					 | 
				
			||||||
        ];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        SystemLogger::dispatch(
 | 
					 | 
				
			||||||
            $message,
 | 
					 | 
				
			||||||
            SystemLog::CATEGORY_GATEWAY_RESPONSE,
 | 
					 | 
				
			||||||
            SystemLog::EVENT_GATEWAY_FAILURE,
 | 
					 | 
				
			||||||
            SystemLog::TYPE_WEPAY,
 | 
					 | 
				
			||||||
            $this->wepay_payment_driver->client,
 | 
					 | 
				
			||||||
            $this->wepay_payment_driver->client->company,
 | 
					 | 
				
			||||||
        );
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        throw new PaymentFailed('Failed to process the payment.', 500);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function storePaymentMethod($response, $payment_method_id)
 | 
					    private function storePaymentMethod($response, $payment_method_id)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										76
									
								
								app/PaymentDrivers/WePay/WePayCommon.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										76
									
								
								app/PaymentDrivers/WePay/WePayCommon.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,76 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Invoice Ninja (https://invoiceninja.com).
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @link https://github.com/invoiceninja/invoiceninja source repository
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @license https://opensource.org/licenses/AAL
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace App\PaymentDrivers\WePay;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use App\Exceptions\PaymentFailed;
 | 
				
			||||||
 | 
					use App\Jobs\Mail\PaymentFailureMailer;
 | 
				
			||||||
 | 
					use App\Jobs\Util\SystemLogger;
 | 
				
			||||||
 | 
					use App\Models\PaymentType;
 | 
				
			||||||
 | 
					use App\Models\SystemLog;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					trait WePayCommon
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private function processSuccessfulPayment($response, $payment_status, $gateway_type)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $data = [
 | 
				
			||||||
 | 
					            'payment_type' => PaymentType::CREDIT_CARD_OTHER,
 | 
				
			||||||
 | 
					            'amount' => $response->amount,
 | 
				
			||||||
 | 
					            'transaction_reference' => $response->checkout_id,
 | 
				
			||||||
 | 
					            'gateway_type_id' => $gateway_type,
 | 
				
			||||||
 | 
					        ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $payment = $this->wepay_payment_driver->createPayment($data, $payment_status);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					         SystemLogger::dispatch(
 | 
				
			||||||
 | 
					            ['response' => $this->wepay_payment_driver->payment_hash->data->server_response, 'data' => $data],
 | 
				
			||||||
 | 
					            SystemLog::CATEGORY_GATEWAY_RESPONSE,
 | 
				
			||||||
 | 
					            SystemLog::EVENT_GATEWAY_SUCCESS,
 | 
				
			||||||
 | 
					            SystemLog::TYPE_WEPAY,
 | 
				
			||||||
 | 
					            $this->wepay_payment_driver->client,
 | 
				
			||||||
 | 
					            $this->wepay_payment_driver->client->company,
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return redirect()->route('client.payments.show', ['payment' => $this->wepay_payment_driver->encodePrimaryKey($payment->id)]);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private function processUnSuccessfulPayment($response, $payment_status)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        PaymentFailureMailer::dispatch($this->wepay_payment_driver->client, $response->state, $this->wepay_payment_driver->client->company, $response->amount);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        PaymentFailureMailer::dispatch(
 | 
				
			||||||
 | 
					            $this->wepay_payment_driver->client,
 | 
				
			||||||
 | 
					            $response,
 | 
				
			||||||
 | 
					            $this->wepay_payment_driver->client->company,
 | 
				
			||||||
 | 
					            $response->gross
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $message = [
 | 
				
			||||||
 | 
					            'server_response' => $response,
 | 
				
			||||||
 | 
					            'data' => $this->wepay_payment_driver->payment_hash->data,
 | 
				
			||||||
 | 
					        ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        SystemLogger::dispatch(
 | 
				
			||||||
 | 
					            $message,
 | 
				
			||||||
 | 
					            SystemLog::CATEGORY_GATEWAY_RESPONSE,
 | 
				
			||||||
 | 
					            SystemLog::EVENT_GATEWAY_FAILURE,
 | 
				
			||||||
 | 
					            SystemLog::TYPE_WEPAY,
 | 
				
			||||||
 | 
					            $this->wepay_payment_driver->client,
 | 
				
			||||||
 | 
					            $this->wepay_payment_driver->client->company,
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        throw new PaymentFailed('Failed to process the payment.', 500);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user