Implement invoice payment in shared layer
Edit on GitHubThis tutorial helps you identify the new payment type through some unique constants. Those constants are going to be defined in the Shared
namespace, since they’re needed both by Yves and Zed.
- Create the
PaymentMethodsConstants
interface under theShared
namespace, where you define these unique constants.
Code sample:
<?php
namespace Pyz\Shared\PaymentMethods;
interface PaymentMethodsConstants
{
/**
* @const string
*/
const PROVIDER = 'paymentmethods';
/**
* @const string
*/
const PAYMENT_METHOD_INVOICE = 'invoice';
/**
* @const string
*/
const PAYMENT_INVOICE_FORM_PROPERTY_PATH = static::PROVIDER . static::PAYMENT_METHOD_INVOICE;
}
- Enrich the
Payment
transfer file with a new property that corresponds to the new payment method. AddShared/PaymentMethods/Transfer/invoicepayment.transfer.xml
file with the following content:
Code sample:
<?xml version="1.0"?>
<transfers xmlns="spryker:transfer-01"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="spryker:transfer-01 http://static.spryker.com/transfer-01.xsd">
<transfer name="Payment">
<!-- Should be equal to PaymentMethodsConstants::PAYMENT_INVOICE_FORM_PROPERTY_PATH.
Then the form fields can be automatically mapped to the transfer object inside this field. -->
<property name="paymentmethodsinvoice" type="string"/>
</transfer>
</transfers>
- Update the
PaymentTransfer
class:
vendor/bin/console transfer:generate
``
Thank you!
For submitting the form