mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-05 18:52:44 +01:00
Working on paypal response
This commit is contained in:
parent
0b7054b315
commit
c4f777b20e
@ -48,11 +48,13 @@ class BasePaymentDriver
|
||||
/* The Invitation */
|
||||
protected $invitation;
|
||||
|
||||
/* Member variables */
|
||||
/* Gateway capabilities */
|
||||
protected $refundable = false;
|
||||
|
||||
/* Token billing */
|
||||
protected $token_billing = false;
|
||||
|
||||
/* Authorise payment methods */
|
||||
protected $can_authorise_credit_card = false;
|
||||
|
||||
|
||||
@ -61,7 +63,6 @@ class BasePaymentDriver
|
||||
$this->company_gateway = $company_gateway;
|
||||
$this->invitation = $invitation;
|
||||
$this->client = $client;
|
||||
//$this->gatewayType = $gatewayType ?: $this->gatewayTypes()[0];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -70,7 +71,7 @@ class BasePaymentDriver
|
||||
*/
|
||||
protected function gateway()
|
||||
{
|
||||
\Log::error("booting {$this->company_gateway->gateway->provider}");
|
||||
|
||||
$this->gateway = Omnipay::create($this->company_gateway->gateway->provider);
|
||||
$this->gateway->initialize((array) $this->company_gateway->getConfig());
|
||||
|
||||
@ -91,14 +92,14 @@ class BasePaymentDriver
|
||||
/**
|
||||
* Returns the default gateway type
|
||||
*/
|
||||
public function gatewayTypes()
|
||||
public function gatewayTypes()
|
||||
{
|
||||
return [
|
||||
GatewayType::CREDIT_CARD,
|
||||
];
|
||||
}
|
||||
|
||||
public function getCompanyGatewayId()
|
||||
public function getCompanyGatewayId() :int
|
||||
{
|
||||
return $this->company_gateway->id;
|
||||
}
|
||||
@ -106,7 +107,7 @@ class BasePaymentDriver
|
||||
* Returns whether refunds are possible with the gateway
|
||||
* @return boolean TRUE|FALSE
|
||||
*/
|
||||
public function getRefundable()
|
||||
public function getRefundable() :bool
|
||||
{
|
||||
return $this->refundable;
|
||||
}
|
||||
@ -115,12 +116,17 @@ class BasePaymentDriver
|
||||
* Returns whether token billing is possible with the gateway
|
||||
* @return boolean TRUE|FALSE
|
||||
*/
|
||||
public function getTokenBilling()
|
||||
public function getTokenBilling() :bool
|
||||
{
|
||||
return $this->token_billing;
|
||||
}
|
||||
|
||||
public function canAuthoriseCreditCard()
|
||||
/**
|
||||
* Returns whether gateway can
|
||||
* authorise and credit card.
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function canAuthoriseCreditCard() :bool
|
||||
{
|
||||
return $this->can_authorise_credit_card;
|
||||
}
|
||||
@ -139,6 +145,11 @@ class BasePaymentDriver
|
||||
|
||||
public function processPaymentResponse($request) {}
|
||||
|
||||
/**
|
||||
* Return the contact if possible
|
||||
*
|
||||
* @return ClientContact The ClientContact object
|
||||
*/
|
||||
public function getContact()
|
||||
{
|
||||
if($this->invitation)
|
||||
@ -184,7 +195,7 @@ class BasePaymentDriver
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function offsitePurchase($data, $items)
|
||||
public function purchase($data, $items)
|
||||
{
|
||||
$this->gateway();
|
||||
|
||||
|
@ -54,7 +54,7 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver
|
||||
*/
|
||||
public function processPaymentView(array $data)
|
||||
{
|
||||
$this->offsitePurchase($this->paymentDetails($data), $this->paymentItems($data));
|
||||
$this->purchase($this->paymentDetails($data), $this->paymentItems($data));
|
||||
}
|
||||
|
||||
public function processPaymentResponse($request)
|
||||
@ -62,7 +62,7 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver
|
||||
|
||||
$response = $this->completePurchase($request->all());
|
||||
|
||||
$paymentRef = $response->getTransactionReference() ?: $transRef;
|
||||
$transaction_reference = $response->getTransactionReference() ?: $request->input('token');
|
||||
|
||||
if ($response->isCancelled()) {
|
||||
return false;
|
||||
@ -168,4 +168,8 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver
|
||||
return $items;
|
||||
}
|
||||
|
||||
private function createPayment($data)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -360,27 +360,18 @@ class StripePaymentDriver extends BasePaymentDriver
|
||||
$payment->save();
|
||||
|
||||
|
||||
//mark all invoices as paid
|
||||
//$invoices->update(['status_id' => Payment::STATUS_COMPLETED]);
|
||||
/**
|
||||
* Move this into an event
|
||||
*/
|
||||
$invoices->each(function ($invoice) use($payment) {
|
||||
|
||||
// foreach($invoices as $invoice){
|
||||
// \Log::error('invite count = '.$invoices->invitations->count());
|
||||
// foreach($invoice->invitations as $invitation)
|
||||
// {
|
||||
// \Log::error($invitation);
|
||||
// $invitations->update(['transaction_reference' => $payment->transaction_reference]);
|
||||
// }
|
||||
// }
|
||||
$invoice->status_id = Invoice::STATUS_PAID;
|
||||
$invoice->save();
|
||||
$invoice->invitations()->update(['transaction_reference' => $payment->transaction_reference]);
|
||||
|
||||
//mark all invitations with transaction reference
|
||||
//TODO move this to to be called from an event... doesn't belong here
|
||||
$invoices->each(function ($invoice) use($payment) {
|
||||
});
|
||||
|
||||
$invoice->status_id = Payment::STATUS_COMPLETED;
|
||||
$invoice->save();
|
||||
$invoice->invitations()->update(['transaction_reference' => $payment->transaction_reference]);
|
||||
|
||||
});
|
||||
return redirect()->route('client.payments.show', ['id' => $this->encodePrimaryKey($payment->id)]);
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user