mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 12:12:48 +01:00
Payment webhook bug fixes
This commit is contained in:
parent
718aa6a966
commit
d71017e203
@ -88,12 +88,12 @@ class Payment extends EntityModel
|
||||
|
||||
public function isPending()
|
||||
{
|
||||
return $this->payment_status_id = PAYMENT_STATUS_PENDING;
|
||||
return $this->payment_status_id == PAYMENT_STATUS_PENDING;
|
||||
}
|
||||
|
||||
public function isFailed()
|
||||
{
|
||||
return $this->payment_status_id = PAYMENT_STATUS_FAILED;
|
||||
return $this->payment_status_id == PAYMENT_STATUS_FAILED;
|
||||
}
|
||||
|
||||
public function isCompleted()
|
||||
|
@ -149,9 +149,21 @@ class PaymentMethod extends EntityModel
|
||||
}
|
||||
}
|
||||
|
||||
public function requiresDelayedAutoBill(){
|
||||
public function requiresDelayedAutoBill()
|
||||
{
|
||||
return $this->payment_type_id == PAYMENT_TYPE_ACH;
|
||||
}
|
||||
|
||||
public function gatewayType()
|
||||
{
|
||||
if ($this->payment_type_id == PAYMENT_TYPE_ACH) {
|
||||
return GATEWAY_TYPE_BANK_TRANSFER;
|
||||
} elseif ($this->payment_type_id == PAYMENT_TYPE_PAYPAL) {
|
||||
return GATEWAY_TYPE_PAYPAL;
|
||||
} else {
|
||||
return GATEWAY_TYPE_TOKEN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PaymentMethod::deleting(function($paymentMethod) {
|
||||
|
@ -42,9 +42,14 @@ class BasePaymentDriver
|
||||
return $this->accountGateway->gateway_id == $gatewayId;
|
||||
}
|
||||
|
||||
protected function isGatewayType($gatewayType)
|
||||
// optionally pass a paymentMethod to determine the type from the token
|
||||
protected function isGatewayType($gatewayType, $paymentMethod = false)
|
||||
{
|
||||
return $this->gatewayType === $gatewayType;
|
||||
if ($paymentMethod) {
|
||||
return $paymentMethod->gatewayType() == $gatewayType;
|
||||
} else {
|
||||
return $this->gatewayType === $gatewayType;
|
||||
}
|
||||
}
|
||||
|
||||
public function gatewayTypes()
|
||||
@ -547,7 +552,7 @@ class BasePaymentDriver
|
||||
$payment->payment_date = date_create()->format('Y-m-d');
|
||||
$payment->ip = Request::ip();
|
||||
|
||||
$payment = $this->creatingPayment($payment);
|
||||
$payment = $this->creatingPayment($payment, $paymentMethod);
|
||||
|
||||
if ($paymentMethod) {
|
||||
$payment->last4 = $paymentMethod->last4;
|
||||
@ -618,7 +623,7 @@ class BasePaymentDriver
|
||||
return $payment;
|
||||
}
|
||||
|
||||
protected function creatingPayment($payment)
|
||||
protected function creatingPayment($payment, $paymentMethod)
|
||||
{
|
||||
return $payment;
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ class BraintreePaymentDriver extends BasePaymentDriver
|
||||
$data['device_data'] = $deviceData;
|
||||
}
|
||||
|
||||
if ($this->isGatewayType(GATEWAY_TYPE_PAYPAL)) {
|
||||
if ($this->isGatewayType(GATEWAY_TYPE_PAYPAL, $paymentMethod)) {
|
||||
$data['ButtonSource'] = 'InvoiceNinja_SP';
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function creatingPayment($payment)
|
||||
protected function creatingPayment($payment, $paymentMethod)
|
||||
{
|
||||
$payment->payer_id = $this->input['PayerID'];
|
||||
|
||||
|
@ -168,9 +168,9 @@ class StripePaymentDriver extends BasePaymentDriver
|
||||
return $paymentMethod;
|
||||
}
|
||||
|
||||
protected function creatingPayment($payment)
|
||||
protected function creatingPayment($payment, $paymentMethod)
|
||||
{
|
||||
if ($this->isGatewayType(GATEWAY_TYPE_BANK_TRANSFER)) {
|
||||
if ($this->isGatewayType(GATEWAY_TYPE_BANK_TRANSFER, $paymentMethod)) {
|
||||
$payment->payment_status_id = $this->purchaseResponse['status'] == 'succeeded' ? PAYMENT_STATUS_COMPLETED : PAYMENT_STATUS_PENDING;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user