Attach payment_id to payment_hash

This commit is contained in:
David Bomba 2020-09-10 11:52:17 +10:00
parent 100ca67c5f
commit d071ed0d3b
6 changed files with 25 additions and 0 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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']);

View File

@ -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) {