Package de.hybris.platform.payment.impl
Class DefaultPaymentServiceImpl
- java.lang.Object
-
- de.hybris.platform.payment.impl.DefaultPaymentServiceImpl
-
- All Implemented Interfaces:
PaymentService
- Direct Known Subclasses:
DefaultAlipayPaymentService,DefaultWeChatPayPaymentService
public class DefaultPaymentServiceImpl extends java.lang.Object implements PaymentService
Default implementation for PaymentService
-
-
Constructor Summary
Constructors Constructor Description DefaultPaymentServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidattachPaymentInfo(PaymentTransactionModel paymentTransactionModel, UserModel userModel, CardInfo cardInfo, java.math.BigDecimal amount)Attaches PaymentInfo to the assigned PaymentTransactionModel instance by using the configured PaymentInfoCreatorStrategy.PaymentTransactionEntryModelauthorize(PaymentTransactionModel transaction, java.math.BigDecimal amount, java.util.Currency currency, AddressModel deliveryAddress, AddressModel paymentAddress, CardInfo card)authorize payment
note: the code of the assigned payment transaction will be used as code-basecode during thePaymentTransactionEntryModel.CODEcode generation process, which represents the main benefit of this method.PaymentTransactionEntryModelauthorize(PaymentTransactionModel transaction, java.math.BigDecimal amount, java.util.Currency currency, AddressModel deliveryAddress, java.lang.String subscriptionID)authorize paymentPaymentTransactionEntryModelauthorize(PaymentTransactionModel transaction, java.math.BigDecimal amount, java.util.Currency currency, AddressModel deliveryAddress, java.lang.String subscriptionID, java.lang.String paymentprovider)authorize payment
note: the code of the assigned payment transaction will be used as code-basecode during thePaymentTransactionEntryModel.CODEcode generation process, which represents the main benefit of this method.PaymentTransactionEntryModelauthorize(java.lang.String merchantTransactionCode, java.math.BigDecimal amount, java.util.Currency currency, AddressModel deliveryAddress, AddressModel paymentAddress, CardInfo card)authorize paymentPaymentTransactionEntryModelauthorize(java.lang.String merchantTransactionCode, java.math.BigDecimal amount, java.util.Currency currency, AddressModel deliveryAddress, java.lang.String subscriptionID)Authorize payment.
Status, transaction and request related informations are available via the relatedPaymentTransactionEntryModel,/
Informations about the related order will be accessible via the referencedPaymentTransactionModel(see:PaymentTransactionEntryModel.getPaymentTransaction()andPaymentTransactionEntryModel.setPaymentTransaction(PaymentTransactionModel)PaymentTransactionEntryModelauthorize(java.lang.String merchantTransactionCode, java.math.BigDecimal amount, java.util.Currency currency, AddressModel deliveryAddress, java.lang.String subscriptionID, java.lang.String cv2, java.lang.String paymentProvider)authorize paymentprotected PaymentTransactionEntryModelauthorizeInternal(PaymentTransactionModel transaction, java.math.BigDecimal amount, java.util.Currency currency, BillingInfo shippingInfo, CardInfo card, java.lang.String subscriptionID, java.lang.String cv2, java.lang.String paymentProvider)...PaymentTransactionEntryModelcancel(PaymentTransactionEntryModel transaction)Cancel paymentPaymentTransactionEntryModelcapture(PaymentTransactionModel transaction)capture paymentprotected BillingInfocreateBillingInfo(AddressModel address)address DTO 2 address DTOprotected BillingInfocreateBillingInfo(AddressModel deliveryAddress, AddressModel paymentAddress, CardInfo card)creates the billing info based on the assigned delivery address instance.NewSubscriptioncreateSubscription(PaymentTransactionModel transaction, AddressModel paymentAddress, CardInfo card)Creates a subscription at the payment provider side and stores sensitive data there.NewSubscriptioncreateSubscription(java.lang.String merchantTransactionCode, java.lang.String paymentProvider, java.util.Currency currency, AddressModel paymentAddress, CardInfo card)Creates a subscription at the payment provider side and stores sensitive data there.PaymentTransactionEntryModeldeleteSubscription(java.lang.String merchantTransactionCode, java.lang.String subscriptionID, java.lang.String paymentProvider)Deletes the subscription at the payment provider.protected CardPaymentServicegetCardPaymentService()protected CommonI18NServicegetCommonI18NService()protected FlexibleSearchServicegetFlexibleSearchService()protected ModelServicegetModelService()java.lang.StringgetNewPaymentTransactionEntryCode(PaymentTransactionModel transaction, PaymentTransactionType paymentTransactionType)Generate new merchant transaction code for payment transaction entries based on code for whole transactionprotected PaymentInfoCreatorStrategygetPaymentInfoCreator()PaymentTransactionModelgetPaymentTransaction(java.lang.String code)GetPaymentTransactionModelby codePaymentTransactionEntryModelgetPaymentTransactionEntry(java.lang.String code)GetPaymentTransactionEntryModelby codePaymentTransactionEntryModelgetSubscriptionData(java.lang.String merchantTransactionCode, java.lang.String subscriptionID, java.lang.String paymentProvider, BillingInfo billingInfo, CardInfo card)Gets the stored card info or payment addressprotected TransactionCodeGeneratorgetTransactionCodeGenerator()PaymentTransactionEntryModelpartialCapture(PaymentTransactionModel transaction, java.math.BigDecimal amount)Take a partial capture of authorized transactionPaymentTransactionEntryModelrefundFollowOn(PaymentTransactionModel transaction, java.math.BigDecimal amount)Refund transactionPaymentTransactionEntryModelrefundStandalone(java.lang.String merchantTransactionCode, java.math.BigDecimal amount, java.util.Currency currency, AddressModel paymentAddress, CardInfo card)Refund value to a card (no transaction is obligatory)PaymentTransactionEntryModelrefundStandalone(java.lang.String merchantTransactionCode, java.math.BigDecimal amount, java.util.Currency currency, AddressModel paymentAddress, CardInfo card, java.lang.String providerName, java.lang.String subscriptionId)Refund value to a card (no transaction is obligatory)voidsetCardPaymentService(CardPaymentService cardPaymentService)voidsetCommonI18NService(CommonI18NService commonI18NService)voidsetFlexibleSearchService(FlexibleSearchService flexibleSearchService)voidsetModelService(ModelService modelService)voidsetPaymentInfoCreator(PaymentInfoCreatorStrategy paymentInfoCreator)voidsetTransactionCodeGenerator(TransactionCodeGenerator transactionCodeGenerator)PaymentTransactionEntryModelupdateSubscription(java.lang.String merchantTransactionCode, java.lang.String subscriptionID, java.lang.String paymentProvider, AddressModel paymentAddress, CardInfo card)Updates the data of the subscription at the payment provider.
-
-
-
Method Detail
-
authorize
public PaymentTransactionEntryModel authorize(java.lang.String merchantTransactionCode, java.math.BigDecimal amount, java.util.Currency currency, AddressModel deliveryAddress, java.lang.String subscriptionID)
Authorize payment.
Status, transaction and request related informations are available via the relatedPaymentTransactionEntryModel,/
Informations about the related order will be accessible via the referencedPaymentTransactionModel(see:PaymentTransactionEntryModel.getPaymentTransaction()andPaymentTransactionEntryModel.setPaymentTransaction(PaymentTransactionModel)- Specified by:
authorizein interfacePaymentService- Parameters:
merchantTransactionCode- the transaction code. Code of the internally generatedPaymentTransactionModeland code-base of the finalPaymentTransactionEntryModel.CODEwhich will be generated by using the injectedTransactionCodeGeneratoramount- the amountcurrency- the currencydeliveryAddress- the delivery addresssubscriptionID- the subscriptionID- Returns:
- Payment Transaction Entry
- Throws:
AdapterException
-
authorize
public PaymentTransactionEntryModel authorize(java.lang.String merchantTransactionCode, java.math.BigDecimal amount, java.util.Currency currency, AddressModel deliveryAddress, java.lang.String subscriptionID, java.lang.String cv2, java.lang.String paymentProvider)
Description copied from interface:PaymentServiceauthorize payment- Specified by:
authorizein interfacePaymentService- Parameters:
merchantTransactionCode- the transaction codeamount- the amountcurrency- the currencydeliveryAddress- the delivery address (paymentAddress is used if null)subscriptionID- the subscriptionIDcv2- card verification valuepaymentProvider- code of payment provider- Returns:
- Payment Transaction Entry
-
authorize
public PaymentTransactionEntryModel authorize(java.lang.String merchantTransactionCode, java.math.BigDecimal amount, java.util.Currency currency, AddressModel deliveryAddress, AddressModel paymentAddress, CardInfo card)
Description copied from interface:PaymentServiceauthorize payment- Specified by:
authorizein interfacePaymentService- Parameters:
merchantTransactionCode- the transaction codeamount- the amountcurrency- the currencydeliveryAddress- the delivery address (paymentAddress is used if null)paymentAddress- the payment addresscard- the card- Returns:
- Payment Transaction Entry
-
authorize
public PaymentTransactionEntryModel authorize(PaymentTransactionModel transaction, java.math.BigDecimal amount, java.util.Currency currency, AddressModel deliveryAddress, AddressModel paymentAddress, CardInfo card)
authorize payment
note: the code of the assigned payment transaction will be used as code-basecode during thePaymentTransactionEntryModel.CODEcode generation process, which represents the main benefit of this method.- Specified by:
authorizein interfacePaymentService- Parameters:
transaction- the payment transactionamount- the amountcurrency- the currencydeliveryAddress- the delivery addresspaymentAddress- the payment addresscard- the card- Returns:
- Payment Transaction Entry
- Throws:
AdapterException
-
authorize
public PaymentTransactionEntryModel authorize(PaymentTransactionModel transaction, java.math.BigDecimal amount, java.util.Currency currency, AddressModel deliveryAddress, java.lang.String subscriptionID, java.lang.String paymentprovider)
authorize payment
note: the code of the assigned payment transaction will be used as code-basecode during thePaymentTransactionEntryModel.CODEcode generation process, which represents the main benefit of this method.- Specified by:
authorizein interfacePaymentService- Parameters:
transaction- the payment transactionamount- the amountcurrency- the currencydeliveryAddress- the delivery addresssubscriptionID- will be used for identifying the user profile (see payment tokenization)paymentprovider- code of payment provider- Returns:
- Payment Transaction Entry
- Throws:
AdapterException
-
authorize
public PaymentTransactionEntryModel authorize(PaymentTransactionModel transaction, java.math.BigDecimal amount, java.util.Currency currency, AddressModel deliveryAddress, java.lang.String subscriptionID)
Description copied from interface:PaymentServiceauthorize payment- Specified by:
authorizein interfacePaymentService- Parameters:
transaction- the payment transactionamount- the amountcurrency- the currencydeliveryAddress- the delivery address (paymentAddress is used if null)subscriptionID- the subscriptionID- Returns:
- Payment Transaction Entry
-
authorizeInternal
protected PaymentTransactionEntryModel authorizeInternal(PaymentTransactionModel transaction, java.math.BigDecimal amount, java.util.Currency currency, BillingInfo shippingInfo, CardInfo card, java.lang.String subscriptionID, java.lang.String cv2, java.lang.String paymentProvider)
... internally used authorization.- Parameters:
transaction- the payment transactionamount- the amount we ant to authorizecurrency- the related currency of the amountshippingInfo- the shipping infocard- the card infosubscriptionID- will be used for identifying the user profile (see payment tokenization)- Throws:
AdapterException
-
getNewPaymentTransactionEntryCode
public java.lang.String getNewPaymentTransactionEntryCode(PaymentTransactionModel transaction, PaymentTransactionType paymentTransactionType)
Generate new merchant transaction code for payment transaction entries based on code for whole transaction- Specified by:
getNewPaymentTransactionEntryCodein interfacePaymentService- Parameters:
transaction- An associated Payment transactionpaymentTransactionType- A type of entry.- Returns:
- A new unique code withing a transaction context.
-
createBillingInfo
protected BillingInfo createBillingInfo(AddressModel deliveryAddress, AddressModel paymentAddress, CardInfo card)
creates the billing info based on the assigned delivery address instance. In case the deliveryAddress is null, we will use the billing info of the assigned CardInfo instance.- Parameters:
deliveryAddress- the delivery addresspaymentAddress- the payment addresscard- the card info- Returns:
- the billing info
-
createBillingInfo
protected BillingInfo createBillingInfo(AddressModel address)
address DTO 2 address DTO
-
capture
public PaymentTransactionEntryModel capture(PaymentTransactionModel transaction)
Description copied from interface:PaymentServicecapture payment- Specified by:
capturein interfacePaymentService- Parameters:
transaction- payment transaction- Returns:
- payment transaction entry
-
cancel
public PaymentTransactionEntryModel cancel(PaymentTransactionEntryModel transaction)
Description copied from interface:PaymentServiceCancel payment- Specified by:
cancelin interfacePaymentService- Parameters:
transaction- payment transaction- Returns:
- payment transaction entry
-
refundFollowOn
public PaymentTransactionEntryModel refundFollowOn(PaymentTransactionModel transaction, java.math.BigDecimal amount)
Description copied from interface:PaymentServiceRefund transaction- Specified by:
refundFollowOnin interfacePaymentService- Parameters:
transaction- payment transactionamount- amount to refund- Returns:
- payment transaction entry
-
refundStandalone
public PaymentTransactionEntryModel refundStandalone(java.lang.String merchantTransactionCode, java.math.BigDecimal amount, java.util.Currency currency, AddressModel paymentAddress, CardInfo card)
Description copied from interface:PaymentServiceRefund value to a card (no transaction is obligatory)- Specified by:
refundStandalonein interfacePaymentService- Parameters:
merchantTransactionCode- any code to locate transactionamount- amount to refundcurrency- currency, used for refundingpaymentAddress- address to refundcard- card to refund- Returns:
- payment transaction entry
-
refundStandalone
public PaymentTransactionEntryModel refundStandalone(java.lang.String merchantTransactionCode, java.math.BigDecimal amount, java.util.Currency currency, AddressModel paymentAddress, CardInfo card, java.lang.String providerName, java.lang.String subscriptionId)
Description copied from interface:PaymentServiceRefund value to a card (no transaction is obligatory)- Specified by:
refundStandalonein interfacePaymentService- Parameters:
merchantTransactionCode- any code to locate transactionamount- amount to refundcurrency- currency, used for refundingpaymentAddress- address to refundcard- card to refundproviderName- name of the payment providersubscriptionId- subscription identifier- Returns:
- payment transaction entry
-
partialCapture
public PaymentTransactionEntryModel partialCapture(PaymentTransactionModel transaction, java.math.BigDecimal amount)
Description copied from interface:PaymentServiceTake a partial capture of authorized transaction- Specified by:
partialCapturein interfacePaymentService- Parameters:
transaction- authorized transactionamount- value to capture- Returns:
- payment transaction entry
-
getPaymentTransaction
public PaymentTransactionModel getPaymentTransaction(java.lang.String code)
GetPaymentTransactionModelby code- Specified by:
getPaymentTransactionin interfacePaymentService- Parameters:
code- the code of thePaymentTransactionModelwe were looking for- Returns:
- the
PaymentTransactionModel - Throws:
ModelNotFoundException- if nothing was foundAmbiguousIdentifierException- if by the given searchparams to many models where found
-
getPaymentTransactionEntry
public PaymentTransactionEntryModel getPaymentTransactionEntry(java.lang.String code)
GetPaymentTransactionEntryModelby code- Specified by:
getPaymentTransactionEntryin interfacePaymentService- Parameters:
code- the code of thePaymentTransactionModelwe were looking for- Returns:
- the
PaymentTransactionModel - Throws:
ModelNotFoundException- if nothing was foundAmbiguousIdentifierException- if by the given searchparams to many models where found
-
attachPaymentInfo
public void attachPaymentInfo(PaymentTransactionModel paymentTransactionModel, UserModel userModel, CardInfo cardInfo, java.math.BigDecimal amount)
Attaches PaymentInfo to the assigned PaymentTransactionModel instance by using the configured PaymentInfoCreatorStrategy.
You can call this method after/before authorization by yourself if there is a need for it.- Specified by:
attachPaymentInfoin interfacePaymentService- Parameters:
paymentTransactionModel- the payment transactionuserModel- the usercardInfo- the card infoamount- the amount
-
createSubscription
public NewSubscription createSubscription(PaymentTransactionModel transaction, AddressModel paymentAddress, CardInfo card)
Description copied from interface:PaymentServiceCreates a subscription at the payment provider side and stores sensitive data there. Future payment authorization and refundStandalone calls will not have to provide the sensitive information, subscriptionID would be sufficient. Call this method after a successful authorize txn and provide THE SAME billing and card info. Please note: the card and billing info is not saved in the returning PaymentTransactionEntryModel from authorize method call ON PURPOSE.- Specified by:
createSubscriptionin interfacePaymentService- Parameters:
transaction- a previous recent successful authorize payment transactionpaymentAddress- the same billing address as for the authorize txncard- the same card as for the authorize txn- Returns:
- instance of
NewSubscription
-
createSubscription
public NewSubscription createSubscription(java.lang.String merchantTransactionCode, java.lang.String paymentProvider, java.util.Currency currency, AddressModel paymentAddress, CardInfo card)
Description copied from interface:PaymentServiceCreates a subscription at the payment provider side and stores sensitive data there. Future payment authorization and refundStandalone calls will not have to provide the sensitive information, subscriptionID would be sufficient. This method does not need an authorized payment transaction, the authorization is expected to be done implicitly by the payment provider.- Specified by:
createSubscriptionin interfacePaymentService- Parameters:
merchantTransactionCode- the transactionCodepaymentProvider- the paymentProvider who will hold the subscription. You might also have just one payment provider in your implementation.currency- the default customer's currencypaymentAddress- the same billing address as for the authorize txncard- the same card as for the authorize txn- Returns:
- new subscription object (instance of
NewSubscription)
-
updateSubscription
public PaymentTransactionEntryModel updateSubscription(java.lang.String merchantTransactionCode, java.lang.String subscriptionID, java.lang.String paymentProvider, AddressModel paymentAddress, CardInfo card)
Description copied from interface:PaymentServiceUpdates the data of the subscription at the payment provider.- Specified by:
updateSubscriptionin interfacePaymentService- Parameters:
merchantTransactionCode- the transactionCodesubscriptionID- the subscription IDpaymentProvider- the paymentProvider who holds the subscription. You get this value from thePaymentTransactionModelof the createSubscription command. You might also have just one payment provider in your implementation.paymentAddress- the new billing address, could be nullcard- the updated card, could be null- Returns:
- instance of
PaymentTransactionEntryModel
-
getSubscriptionData
public PaymentTransactionEntryModel getSubscriptionData(java.lang.String merchantTransactionCode, java.lang.String subscriptionID, java.lang.String paymentProvider, BillingInfo billingInfo, CardInfo card)
Description copied from interface:PaymentServiceGets the stored card info or payment address- Specified by:
getSubscriptionDatain interfacePaymentService- Parameters:
merchantTransactionCode- the transactionCodesubscriptionID- the subscription IDpaymentProvider- the paymentProvider who holds the subscription. You get this value from thePaymentTransactionModelof the createSubscription command. You might also have just one payment provider in your implementation.billingInfo- the billing address is returned in this DTOcard- the card information is returned in this DTO- Returns:
- instance of
PaymentTransactionEntryModel
-
deleteSubscription
public PaymentTransactionEntryModel deleteSubscription(java.lang.String merchantTransactionCode, java.lang.String subscriptionID, java.lang.String paymentProvider)
Description copied from interface:PaymentServiceDeletes the subscription at the payment provider. Warning: Deleting a customer profile is permanent. You cannot recover a deleted customer profile.- Specified by:
deleteSubscriptionin interfacePaymentService- Parameters:
merchantTransactionCode- the transactionCodesubscriptionID- the subscription IDpaymentProvider- the paymentProvider who holds the subscription. You get this value from thePaymentTransactionModelof the createSubscription command. You might also have just one payment provider in your implementation.- Returns:
- instance of
PaymentTransactionEntryModel
-
getCommonI18NService
protected CommonI18NService getCommonI18NService()
-
setCommonI18NService
public void setCommonI18NService(CommonI18NService commonI18NService)
-
getModelService
protected ModelService getModelService()
-
setModelService
public void setModelService(ModelService modelService)
-
getFlexibleSearchService
protected FlexibleSearchService getFlexibleSearchService()
-
setFlexibleSearchService
public void setFlexibleSearchService(FlexibleSearchService flexibleSearchService)
-
getPaymentInfoCreator
protected PaymentInfoCreatorStrategy getPaymentInfoCreator()
-
setPaymentInfoCreator
public void setPaymentInfoCreator(PaymentInfoCreatorStrategy paymentInfoCreator)
-
getTransactionCodeGenerator
protected TransactionCodeGenerator getTransactionCodeGenerator()
-
setTransactionCodeGenerator
public void setTransactionCodeGenerator(TransactionCodeGenerator transactionCodeGenerator)
-
getCardPaymentService
protected CardPaymentService getCardPaymentService()
-
setCardPaymentService
public void setCardPaymentService(CardPaymentService cardPaymentService)
-
-