mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Working on paypal response
This commit is contained in:
parent
0b7054b315
commit
c4f777b20e
@ -48,11 +48,13 @@ class BasePaymentDriver
|
|||||||
/* The Invitation */
|
/* The Invitation */
|
||||||
protected $invitation;
|
protected $invitation;
|
||||||
|
|
||||||
/* Member variables */
|
/* Gateway capabilities */
|
||||||
protected $refundable = false;
|
protected $refundable = false;
|
||||||
|
|
||||||
|
/* Token billing */
|
||||||
protected $token_billing = false;
|
protected $token_billing = false;
|
||||||
|
|
||||||
|
/* Authorise payment methods */
|
||||||
protected $can_authorise_credit_card = false;
|
protected $can_authorise_credit_card = false;
|
||||||
|
|
||||||
|
|
||||||
@ -61,7 +63,6 @@ class BasePaymentDriver
|
|||||||
$this->company_gateway = $company_gateway;
|
$this->company_gateway = $company_gateway;
|
||||||
$this->invitation = $invitation;
|
$this->invitation = $invitation;
|
||||||
$this->client = $client;
|
$this->client = $client;
|
||||||
//$this->gatewayType = $gatewayType ?: $this->gatewayTypes()[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -70,7 +71,7 @@ class BasePaymentDriver
|
|||||||
*/
|
*/
|
||||||
protected function gateway()
|
protected function gateway()
|
||||||
{
|
{
|
||||||
\Log::error("booting {$this->company_gateway->gateway->provider}");
|
|
||||||
$this->gateway = Omnipay::create($this->company_gateway->gateway->provider);
|
$this->gateway = Omnipay::create($this->company_gateway->gateway->provider);
|
||||||
$this->gateway->initialize((array) $this->company_gateway->getConfig());
|
$this->gateway->initialize((array) $this->company_gateway->getConfig());
|
||||||
|
|
||||||
@ -98,7 +99,7 @@ class BasePaymentDriver
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCompanyGatewayId()
|
public function getCompanyGatewayId() :int
|
||||||
{
|
{
|
||||||
return $this->company_gateway->id;
|
return $this->company_gateway->id;
|
||||||
}
|
}
|
||||||
@ -106,7 +107,7 @@ class BasePaymentDriver
|
|||||||
* Returns whether refunds are possible with the gateway
|
* Returns whether refunds are possible with the gateway
|
||||||
* @return boolean TRUE|FALSE
|
* @return boolean TRUE|FALSE
|
||||||
*/
|
*/
|
||||||
public function getRefundable()
|
public function getRefundable() :bool
|
||||||
{
|
{
|
||||||
return $this->refundable;
|
return $this->refundable;
|
||||||
}
|
}
|
||||||
@ -115,12 +116,17 @@ class BasePaymentDriver
|
|||||||
* Returns whether token billing is possible with the gateway
|
* Returns whether token billing is possible with the gateway
|
||||||
* @return boolean TRUE|FALSE
|
* @return boolean TRUE|FALSE
|
||||||
*/
|
*/
|
||||||
public function getTokenBilling()
|
public function getTokenBilling() :bool
|
||||||
{
|
{
|
||||||
return $this->token_billing;
|
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;
|
return $this->can_authorise_credit_card;
|
||||||
}
|
}
|
||||||
@ -139,6 +145,11 @@ class BasePaymentDriver
|
|||||||
|
|
||||||
public function processPaymentResponse($request) {}
|
public function processPaymentResponse($request) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the contact if possible
|
||||||
|
*
|
||||||
|
* @return ClientContact The ClientContact object
|
||||||
|
*/
|
||||||
public function getContact()
|
public function getContact()
|
||||||
{
|
{
|
||||||
if($this->invitation)
|
if($this->invitation)
|
||||||
@ -184,7 +195,7 @@ class BasePaymentDriver
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function offsitePurchase($data, $items)
|
public function purchase($data, $items)
|
||||||
{
|
{
|
||||||
$this->gateway();
|
$this->gateway();
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver
|
|||||||
*/
|
*/
|
||||||
public function processPaymentView(array $data)
|
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)
|
public function processPaymentResponse($request)
|
||||||
@ -62,7 +62,7 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver
|
|||||||
|
|
||||||
$response = $this->completePurchase($request->all());
|
$response = $this->completePurchase($request->all());
|
||||||
|
|
||||||
$paymentRef = $response->getTransactionReference() ?: $transRef;
|
$transaction_reference = $response->getTransactionReference() ?: $request->input('token');
|
||||||
|
|
||||||
if ($response->isCancelled()) {
|
if ($response->isCancelled()) {
|
||||||
return false;
|
return false;
|
||||||
@ -168,4 +168,8 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver
|
|||||||
return $items;
|
return $items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function createPayment($data)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
@ -360,27 +360,18 @@ class StripePaymentDriver extends BasePaymentDriver
|
|||||||
$payment->save();
|
$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){
|
$invoice->status_id = Invoice::STATUS_PAID;
|
||||||
// \Log::error('invite count = '.$invoices->invitations->count());
|
|
||||||
// foreach($invoice->invitations as $invitation)
|
|
||||||
// {
|
|
||||||
// \Log::error($invitation);
|
|
||||||
// $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->save();
|
||||||
$invoice->invitations()->update(['transaction_reference' => $payment->transaction_reference]);
|
$invoice->invitations()->update(['transaction_reference' => $payment->transaction_reference]);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
return redirect()->route('client.payments.show', ['id' => $this->encodePrimaryKey($payment->id)]);
|
return redirect()->route('client.payments.show', ['id' => $this->encodePrimaryKey($payment->id)]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user