0

I have added a custom field called custom_payment_id in spy_sales_payment table,added the field in transfer file too sales_payment.transfer.xml

and added the column using slaes.schema.xml file

How to set value to this field while placing order

  • Depends on your implementation. Usually the mapping is done in you business or persistence layer. Hard to tell without code, but if your transfer field name matches the database field name, you can be lucky and have to do nothing since the transfers/entities are translated to each other using fromArray/toArray – Jim Panse Feb 06 '23 at 14:24

1 Answers1

0

A concrete answer is hard, because it depends where you get the data from. Spryker is very flexible and there are many ways to solve that.

I guess you're adding the custom_payment_id during checkout (i.e. in the payment step) to the PaymentTransfer object inside of the QuoteTransfer object. (It's a good idea to extend the PaymentTransfer object as well).

Then \Spryker\Zed\Payment\Business\Order\SalesPaymentSaver::mapSalesPaymentEntity is a good starting point to extend, which hydrates the SpySalesPayment object from the PaymentTransfer object.

    protected function mapSalesPaymentEntity(PaymentTransfer $paymentTransfer, $idSalesOrder)
    {
        $paymentMethodTypeEntity = parent::mapSalesPaymentEntity($paymentTransfer, $idSalesOrder);

        $salesPaymentEntity->setCustomPaymentId($paymentTransfer->getCustomPaymentId());

        return $salesPaymentEntity;
    }