Implement prepayment in shared layer
Edit on GitHubThis tutorial shows how to identify the new payment type through some unique constants. Those constants are going to be defined under the Shared namespace because both Yves and Zed need them.
- 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_PREPAYMENT = 'prepayment';
/**
* @const string
*/
const PAYMENT_PREPAYMENT_FORM_PROPERTY_PATH = static::PROVIDER . static::PAYMENT_METHOD_PREPAYMENT;
}
- Enrich the
Payment
transfer file with a new property that corresponds to the new payment method.
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_PREPAYMENT_FORM_PROPERTY_PATH. Then the form fields can be automatically mapped to the transfer object inside this field. -->
<property name="paymentmethodsprepayment" type="string"/>
</transfer>
</transfers>
- Update the
PaymentTransfer
class:
vendor/bin/console transfer:generate
Thank you!
For submitting the form