Authorization is the first step in the card payment process. The authorized means "locked money" on the card account until it is captured and authorization is reversed or has expired. AuthorizationCommand interface need to implement for lock money
public interface AuthorizationCommand extends Command<RequestAuthorizationData, ResponseAuthorizationData> {
}
After authorization complete, The normal way is to Capture payment. Actual payment is received to business when capture is complete. CaptureCommand interface need to implement for capture money
public interface CaptureCommand extends Command<RequestCaptureData, ResponseCaptureData> {
}
public interface PartialCaptureCommand extends Command<PartialCaptureRequest, CaptureResult> {
}
public interface VoidCommand extends Command<VoidRequest, VoidResult> {
}
public interface StandaloneRefundCommand<T extends AbstractRequest> extends Command<T, RefundResult> {
RefundResult perform(T var1);
}
public interface FollowOnRefundCommand<T extends AbstractRequest> extends Command<T, RefundResult>
{
RefundResult perform(T request);
}
After Implementation Classes, Now we required spring configuration
We will define a command factory bean as per payment provider. Hybris is provide mock spring file configuration. We will follow same configuration and add our PSP implementation bean classes and PSP value. It is follow Command factory pattern.
We need to define similar configuration in our custom extension and payment provider value as used PSP name like CyberSouce ,Adyen etc and below bold configuration will be update actual Command class as per PSP.
Sample File : mock-payment-spring.xml
<!-- Payment mockup implementation -->
<bean name="mockupCommandFactory" class="de.hybris.platform.payment.commands.factory.impl.DefaultCommandFactoryImpl" >
<property name="paymentProvider" value="Mockup"/>
<property name="commands">
<map>
<entry>
<key><value type="java.lang.Class">de.hybris.platform.payment.commands.IsApplicableCommand</value></key>
<bean class="de.hybris.platform.payment.commands.impl.IsApplicableMockCommand" />
</entry>
<entry>
<key><value type="java.lang.Class">de.hybris.platform.payment.commands.AuthorizationCommand</value></key>
<bean class="de.hybris.platform.payment.commands.impl.AuthorizationMockCommand" />
</entry>
<entry>
<key>
<value type="java.lang.Class">de.hybris.platform.payment.commands.SubscriptionAuthorizationCommand</value>
</key>
<bean class="de.hybris.platform.payment.commands.impl.SubscriptionAuthorizationMockCommand" />
</entry>
<entry>
<key>
<value type="java.lang.Class">de.hybris.platform.payment.commands.CaptureCommand</value>
</key>
<bean class="de.hybris.platform.payment.commands.impl.CaptureMockCommand" />
</entry>
<entry>
<key>
<value type="java.lang.Class">de.hybris.platform.payment.commands.PartialCaptureCommand</value>
</key>
<bean class="de.hybris.platform.payment.commands.impl.PartialCaptureMockCommand" />
</entry>
<entry>
<key><value type="java.lang.Class">de.hybris.platform.payment.commands.EnrollmentCheckCommand</value>
</key>
<bean class="de.hybris.platform.payment.commands.impl.EnrollmentCheckMockCommand" />
</entry>
<entry>
<key>
<value type="java.lang.Class">de.hybris.platform.payment.commands.VoidCommand</value>
</key>
<bean class="de.hybris.platform.payment.commands.impl.VoidMockCommand" />
</entry>
<entry>
<key>
<value type="java.lang.Class">de.hybris.platform.payment.commands.FollowOnRefundCommand</value>
</key>
<bean class="de.hybris.platform.payment.commands.impl.FollowOnRefundMockCommand" />
</entry>
<entry>
<key>
<value type="java.lang.Class">de.hybris.platform.payment.commands.StandaloneRefundCommand</value>
</key>
<bean class="de.hybris.platform.payment.commands.impl.StandaloneRefundMockCommand" />
</entry>
<entry>
<key>
<value type="java.lang.Class">de.hybris.platform.payment.commands.CreateSubscriptionCommand</value>
</key>
<bean class="de.hybris.platform.payment.commands.impl.CreateSubscriptionMockCommand" />
</entry>
<entry>
<key>
<value type="java.lang.Class">de.hybris.platform.payment.commands.DeleteSubscriptionCommand</value>
</key>
<bean class="de.hybris.platform.payment.commands.impl.DeleteSubscriptionMockCommand" />
</entry>
<entry>
<key>
<value type="java.lang.Class">de.hybris.platform.payment.commands.GetSubscriptionDataCommand</value>
</key>
<bean class="de.hybris.platform.payment.commands.impl.GetSubscriptionDataMockCommand" />
</entry>
<entry>
<key>
<value type="java.lang.Class">de.hybris.platform.payment.commands.UpdateSubscriptionCommand</value>
</key>
<bean class="de.hybris.platform.payment.commands.impl.UpdateSubscriptionMockCommand" />
</entry>
</map>
</property>
/bean>
<bean name="mockupCommandFactoryRegistry" class="de.hybris.platform.payment.commands.impl.CommandFactoryRegistryMockImpl" />
The payment functionality is provided by the PaymentService interface, which contains methods responsible for several operations on orders.
public interface PaymentService
{
PaymentTransactionEntryModel authorize(final String merchantTransactionCode,
final BigDecimal amount, final Currency currency, final AddressModel deliveryAddress,
final AddressModel paymentAddress, final CardInfo card) throws AdapterException;
PaymentTransactionEntryModel capture(PaymentTransactionModel transaction) throws AdapterException;
PaymentTransactionEntryModel cancel(final PaymentTransactionEntryModel transaction) throws AdapterException;
-----
//same other method define
-----
}
Authentication with Credit Card by Saved Token
As per PCI regulations, Hybris recommend that only store a subscription ID or tokenized representation on the SAP Commerce DB and allow the PSP to store the full credit card information. The CreditCardPaymentInfo has a place to save the subscriptionID when sensitive credit card details, like card number and CVV number, are saved