Payment System
For the current payment system with EveryPay and internal flows, see ./PAYMENT_SYSTEM.md.
Description of old solution
AdaptersAbstract
Related to:
PaymentHandlerBase.
Has properties:
- tag. The tag of adapter
- configuration data.
functionality:
signWithPrivateKey()Signs a given string with a private key specified by a relative configuration path.formatParams()Format all added parameters as described in the parameter definition (cast to string, truncate length).- Related to the
Dataset
- Related to the
getParamMacOrderDefinition()Defines MAC parameters for each service type.getParamDefinition()Returns the definition (with max lengths) of MAC parameters.verifySignatureWithCertificate()Verifies that the signature is correct for the specified data using a given certificate.
Dataset
Related to:
AdaptersAbstract.
Has properties:
- adapter. instance of
AdaptersAbstract - params. Parameter array for this dataset.
functionality:
- data transfer object.
PaymentHandlerBase
Related to:
AdapterFactory.
Has properties:
- configuration of all adapters.
- list of all available adapters as entities.
functionality:
createService()returnsServicesAbstractby passed param.
ServicesAbstract
Related to:
PaymentHandlerBase.
functionality:
loadAdapters()Load supported adapters for this service ??
heirs:
Payment
Payment
Related to:
Transaction.- Extend
ServicesAbstract.
functionality:
generateForms()Generates payment forms for all enabled adapters.handleResponse()Handles the response received from the server after paymentcreateTransaction()Create a new transaction object
Transaction
functionality:
create()Create a new transaction object by ID and amount.generateReference()Generate a reference number based on transaction ID.
AdapterInterface
Related to:
Response.Transaction.Dataset.
functionality:
fillPaymentFormDataset()Returns a dataset describing a payment form for this adaptercanHandlePaymentResponse()Returns TRUE if an adapter can handle a payment responsehandlePaymentResponse()Handles the payment response from the payment provider.loadTransactionFromResponse()Loads a transaction by the response's parameters
IPizza
Related to:
- Extends
AdaptersAbstract - Implements
AdapterInterface
heirs:
CoopSwedBankLHVSebNordea
SwedCard
Related to:
RequestFactory.ResponseAnalyzer.SwedCardRequester.
functionality:
-
canHandlePaymentResponse()Check is response contains one of the next param:dts_referenceexternal transaction IDPaRes3D secure hash param.repeatedQueryboolean, is request made using pre-saved payment token.
-
handlePaymentResponse()- If the response from repeated query then
makeRepeatedQueryAndFinalize() checkTransactionQuery()using reference received from'dts_reference'.- if response has param
'PaRes'then 3D secure is needed.makeVerifyRequest(). SwedCardRequester.authorize()using'dts_reference'.- if
ResponseAnalyzer.if3dRequestNeeded()then generating 3D secure form and redirect customer to the merchant pages. - if
ResponseAnalyzer.canBeProcessedWithout3dSecurity()thenmakeVerifyRequest(). - if
ResponseAnalyzer.isAcceptedthentransactionAccepted().
- if
- if response has param
- If the response from repeated query then
-
makeVerifyRequest()SendSwedCardRequester.verify- If
ResponseAnalyzer.isAccepted()thentransactionAccepted(). - else
transactionFailed().
- If
-
transactionAccepted()- Save credit card info if exists.
- Creating
RrPaymentfromRrOrder. - save entities.
-
transactionFailed()- Creating
RrPaymentfromRrOrder. - save entities.
- Creating
-
loadTransactionFromResponse()Set transaction properties from response. List of the properties:'transactionID''reference''amount''status''currency'
-
makeRepeatedQueryAndFinalize()makeSwedCardRequester.payWithToken()and analyze the response.
RequestFactory
functionality:
buildSetupRequest()Build SOAP request XML for receiveing payment redirect URL.buildAuthorizationRequest()Build SOAP request XML.buildFinishVerifyRequest()Build last request to verify transaction.buildCheckTransactionQuery()Build SOAP request XML for getting transaction state.buildRepeatQuery()Build SOAP request XML for making payment using credit card token.
ResponseAnalyzer
Related to:
AuthorizationStatusPurchaseStatus
functionality:
getRedirectUrl()Return url received from response for making redirect.extractReferenceFromResponse()Return'datacash_reference'of the response.if3dRequestNeeded()check is 3D secure needed by response status ID.canBeProcessedWithout3dSecurity()check is payment can be processed without 3D secure by response status ID.getReference()Return'merchant_reference'from the response.'merchant_reference'is our hash of payment.
getCreditCardInformation()Return array of meta info about used credit card.
SwedCardRequester
Related to:
SetupParamsRrOrderRrUserGuzzleHttp\Client
functionality:
sendSetupRequest()SendRequestFactory.buildSetupRequest().payWithToken()SendRequestFactory.buildRepeatQuery().checkTransactionQuery()SendRequestFactory.buildCheckTransactionQuery().authorize()SendRequestFactory.buildAuthorizationRequest().authorizeZeroAmount()SendRequestFactory.buildAuthorizationRequest().verify()SendRequestFactory.buildFinishVerifyRequest().
Transaction
functionality:
- data transfer object of the next params:
id=>RrPayment->idamount=>RrPayment->amountreference=>RrOrder->referencecomment.
Related to:
- PaymentController::actionForm
- Used for passing params to the payment form generation.
- BankController::actionReturn
- Used for receive the payment.
Payment related actions
PaymentController::actionForm
functionality:
- Check is order status correct
- Create RrPayment
- Create transaction
- Generate payment POST form
- Handle generation exceptions
BankController::actionReturn
functionality:
- Handle received response from the bank.
- find the adapter that can handle response.
- Create Response object using adapter.
- Create transaction from response.
- Get payment by transaction.
- Get order by payment.
- Check is order in a right condition to receive payment.
- Check received payment status and process scenarios.
Order/Payment processing roadmap
Base state:
- order with status: PENDING_PAYMENT
- Payment with status: STATUS_STARTED
BankLink
Don't change the order status && payment status. Return response based on received bank request. Response attributes:
- isSuccessful
- isAutomatic
- transaction
- TransactionID
- Reference
- Sum
- Comment
- Currency* Language
DataCash (Swedcard)
Change the order status && payment status. Can set the next values:
- Order processed successful:
- mark payment as STATUS_COMPLETED.
- mark order as PENDING_PROCESSING.
- Order was failed:
- mark payment as STATUS_CANCELLED.
- mark order as PAYMENT_FAILED.
Common processing:
- Get payment with order by transaction ID.
- if order status is PENDING_PAYMENT:
- Mark payment as failed if response isn't successful.
- Payment validation
- if payment status is STATUS_WAITING then finalize the order with status PENDING_PROCESSING.
- if payment status is STATUS_COMPLETED then
- check is order status not PENDING_PAYMENT or not PAYMENT_FAILED.
- if payment status is STATUS_CANCELLED then:
- mark order as failed.
- if order status in list then order processed successful. List:
- PENDING_NAV_SYNC
- PROCESSING
- PENDING_NAV_PROCESSING
- COMPLETED
- PENDING_PROCESSING
then order processed successful