diff --git a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php index 87fca0a08e7e..e154c5c01250 100644 --- a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php +++ b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php @@ -104,6 +104,9 @@ class AuthorizeCreditCard $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); @@ -144,6 +147,9 @@ 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(); $this->authorize->attachInvoices($payment, $payment_hash); diff --git a/app/PaymentDrivers/CheckoutComPaymentDriver.php b/app/PaymentDrivers/CheckoutComPaymentDriver.php index 0af104818305..b2da639512e1 100644 --- a/app/PaymentDrivers/CheckoutComPaymentDriver.php +++ b/app/PaymentDrivers/CheckoutComPaymentDriver.php @@ -219,6 +219,9 @@ class CheckoutComPaymentDriver extends BaseDriver $payment = $this->createPayment($data, Payment::STATUS_COMPLETED); $payment_hash = PaymentHash::whereRaw('BINARY `hash`= ?', [$state['payment_hash']])->firstOrFail(); + $payment_hash->payment_id = $payment->id; + $payment_hash->save(); + $this->attachInvoices($payment, $payment_hash); $payment->service()->updateInvoicePayment($payment_hash); diff --git a/app/PaymentDrivers/PayPalExpressPaymentDriver.php b/app/PaymentDrivers/PayPalExpressPaymentDriver.php index 76b8600efd63..952410f09688 100644 --- a/app/PaymentDrivers/PayPalExpressPaymentDriver.php +++ b/app/PaymentDrivers/PayPalExpressPaymentDriver.php @@ -162,6 +162,10 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver $payment = $this->createPayment($response->getData()); $payment_hash = PaymentHash::whereRaw('BINARY `hash`= ?', [$request->input('payment_hash')])->firstOrFail(); + + $payment_hash->payment_id = $payment->id; + $payment_hash->save(); + $this->attachInvoices($payment, $payment_hash); $payment->service()->updateInvoicePayment($payment_hash); diff --git a/app/PaymentDrivers/Stripe/Charge.php b/app/PaymentDrivers/Stripe/Charge.php index c92b475f9252..4f76dc3e67d5 100644 --- a/app/PaymentDrivers/Stripe/Charge.php +++ b/app/PaymentDrivers/Stripe/Charge.php @@ -167,6 +167,9 @@ class Charge $payment->meta = $cgt->meta; $payment->save(); + $payment_hash->payment_id = $payment->id; + $payment_hash->save(); + $this->stripe->attachInvoices($payment, $payment_hash); $payment->service()->updateInvoicePayment($payment_hash); diff --git a/app/PaymentDrivers/Stripe/CreditCard.php b/app/PaymentDrivers/Stripe/CreditCard.php index c52ca0b9e279..af617e791fa2 100644 --- a/app/PaymentDrivers/Stripe/CreditCard.php +++ b/app/PaymentDrivers/Stripe/CreditCard.php @@ -197,6 +197,11 @@ class CreditCard $payment = $this->stripe->createPayment($data, $status = Payment::STATUS_COMPLETED); $payment->meta = $payment_meta; + $payment->save(); + + $payment_hash = $state['payment_hash']; + $payment_hash->payment_id = $payment->id; + $payment_hash->save(); $payment = $this->stripe->attachInvoices($payment, $state['payment_hash']); diff --git a/database/migrations/2020_08_18_140557_add_is_public_to_documents_table.php b/database/migrations/2020_08_18_140557_add_is_public_to_documents_table.php index cc58b5309c1e..73e37c195f27 100644 --- a/database/migrations/2020_08_18_140557_add_is_public_to_documents_table.php +++ b/database/migrations/2020_08_18_140557_add_is_public_to_documents_table.php @@ -40,7 +40,11 @@ class AddIsPublicToDocumentsTable extends Migration $table->decimal('fee_total', 16, 4); $table->unsignedInteger('fee_invoice_id')->nullable(); $table->mediumText('data'); + $table->unsignedInteger('payment_id')->nullable(); $table->timestamps(6); + + $table->foreign('payment_id')->references('id')->on('payments')->onDelete('cascade')->onUpdate('cascade'); + }); Schema::table('recurring_invoices', function ($table) {