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
Default implementation for PaymentService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidattachPaymentInfo(PaymentTransactionModel paymentTransactionModel, UserModel userModel, CardInfo cardInfo, BigDecimal amount) Attaches PaymentInfo to the assigned PaymentTransactionModel instance by using the configured PaymentInfoCreatorStrategy.authorize(PaymentTransactionModel transaction, BigDecimal amount, 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.authorize(PaymentTransactionModel transaction, BigDecimal amount, Currency currency, AddressModel deliveryAddress, String subscriptionID) authorize paymentauthorize(PaymentTransactionModel transaction, BigDecimal amount, Currency currency, AddressModel deliveryAddress, String subscriptionID, 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.authorize(String merchantTransactionCode, BigDecimal amount, Currency currency, AddressModel deliveryAddress, AddressModel paymentAddress, CardInfo card) authorize paymentauthorize(String merchantTransactionCode, BigDecimal amount, Currency currency, AddressModel deliveryAddress, 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)authorize(String merchantTransactionCode, BigDecimal amount, Currency currency, AddressModel deliveryAddress, String subscriptionID, String cv2, String paymentProvider) authorize paymentprotected PaymentTransactionEntryModelauthorizeInternal(PaymentTransactionModel transaction, BigDecimal amount, Currency currency, BillingInfo shippingInfo, CardInfo card, String subscriptionID, String cv2, String paymentProvider) ...cancel(PaymentTransactionEntryModel transaction) Cancel paymentcapture(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.createSubscription(PaymentTransactionModel transaction, AddressModel paymentAddress, CardInfo card) Creates a subscription at the payment provider side and stores sensitive data there.createSubscription(String merchantTransactionCode, String paymentProvider, Currency currency, AddressModel paymentAddress, CardInfo card) Creates a subscription at the payment provider side and stores sensitive data there.deleteSubscription(String merchantTransactionCode, String subscriptionID, String paymentProvider) Deletes the subscription at the payment provider.protected CardPaymentServiceprotected CommonI18NServiceprotected FlexibleSearchServiceprotected ModelServicegetNewPaymentTransactionEntryCode(PaymentTransactionModel transaction, PaymentTransactionType paymentTransactionType) Generate new merchant transaction code for payment transaction entries based on code for whole transactionprotected PaymentInfoCreatorStrategygetPaymentTransaction(String code) GetPaymentTransactionModelby codeGetPaymentTransactionEntryModelby codegetSubscriptionData(String merchantTransactionCode, String subscriptionID, String paymentProvider, BillingInfo billingInfo, CardInfo card) Gets the stored card info or payment addressprotected TransactionCodeGeneratorpartialCapture(PaymentTransactionModel transaction, BigDecimal amount) Take a partial capture of authorized transactionrefundFollowOn(PaymentTransactionModel transaction, BigDecimal amount) Refund transactionrefundStandalone(String merchantTransactionCode, BigDecimal amount, Currency currency, AddressModel paymentAddress, CardInfo card) Refund value to a card (no transaction is obligatory)refundStandalone(String merchantTransactionCode, BigDecimal amount, Currency currency, AddressModel paymentAddress, CardInfo card, String providerName, 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) updateSubscription(String merchantTransactionCode, String subscriptionID, String paymentProvider, AddressModel paymentAddress, CardInfo card) Updates the data of the subscription at the payment provider.
-
Constructor Details
-
DefaultPaymentServiceImpl
public DefaultPaymentServiceImpl()
-
-
Method Details
-
authorize
public PaymentTransactionEntryModel authorize(String merchantTransactionCode, BigDecimal amount, Currency currency, AddressModel deliveryAddress, 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(String merchantTransactionCode, BigDecimal amount, Currency currency, AddressModel deliveryAddress, String subscriptionID, String cv2, 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(String merchantTransactionCode, BigDecimal amount, 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, BigDecimal amount, 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, BigDecimal amount, Currency currency, AddressModel deliveryAddress, String subscriptionID, 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, BigDecimal amount, Currency currency, AddressModel deliveryAddress, 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, BigDecimal amount, Currency currency, BillingInfo shippingInfo, CardInfo card, String subscriptionID, String cv2, 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 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
address DTO 2 address DTO -
capture
Description copied from interface:PaymentServicecapture payment- Specified by:
capturein interfacePaymentService- Parameters:
transaction- payment transaction- Returns:
- payment transaction entry
-
cancel
Description copied from interface:PaymentServiceCancel payment- Specified by:
cancelin interfacePaymentService- Parameters:
transaction- payment transaction- Returns:
- payment transaction entry
-
refundFollowOn
public PaymentTransactionEntryModel refundFollowOn(PaymentTransactionModel transaction, 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(String merchantTransactionCode, BigDecimal amount, 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(String merchantTransactionCode, BigDecimal amount, Currency currency, AddressModel paymentAddress, CardInfo card, String providerName, 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, 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
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
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, 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(String merchantTransactionCode, String paymentProvider, 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(String merchantTransactionCode, String subscriptionID, 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(String merchantTransactionCode, String subscriptionID, 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(String merchantTransactionCode, String subscriptionID, 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
-
setCommonI18NService
-
getModelService
-
setModelService
-
getFlexibleSearchService
-
setFlexibleSearchService
-
getPaymentInfoCreator
-
setPaymentInfoCreator
-
getTransactionCodeGenerator
-
setTransactionCodeGenerator
-
getCardPaymentService
-
setCardPaymentService
-