Online documentation - Websydian v6.0 |
Users Guide | Patterns Reference | WebsydianExpress | Search |
Introduction Implementing Other Uses Parts
By default a Websydian PaymentWebShop implementation supports one event sent to the payment gateway, the Web.Ordering.Submit Payment.Ok event.
If more events are to be sent to the Payment Gateway, the page generator with the sending event and the sending event must be modified
Example
If the Submit Payment document itself must be relayed through the Payment Gateway, a few triples must be added.
First, the event handler initiating the Submit Payment document must be declared as a SendToExternalServer function, and its page generator must be declared as a PageGeneratorWithExternalEvent:
MyShop.Web.Ordering.Enter Contact Information | is a FNC | MyShop.Abstract.PaymentGateway.Abstract. PageGeneratorWithExternalEvent |
MyShop.Web.Ordering.Enter Contact Information.OK | is a FNC | MyShop.Abstract.PaymentGateway.Abstract. SendToExternalServer |
Second, a field for the payment gateway URL that relays the Submit Payment document must be added to the Shop entity and made available to the page generator:
MyShop.Abstract.PaymentGateway.Fields | field FLD | SubmitPaymentFormURL |
MyShop.Abstract.PaymentGateway.Fields. SubmitPaymentFormURL | is a FLD |
MyShop.Abstract.PaymentGateway.Fields. ExternalServerURL |
MyShop.Data.Shop | has FLD |
MyShop.Abstract.PaymentGateway.Fields. SubmitPaymentFormURL |
MyShop.Web.Ordering.Enter Contact Information | local FLD ... for VAR |
MyShop.Abstract.PaymentGateway.Fields. SubmitPaymentFormURL WsyDetails |
MyShop.Web.Ordering.Enter Contact Information | local FLD ... for VAR |
MyShop.Abstract.PaymentGateway.Fields. SubmitPaymentFormURL OmitDetailsFields |
Last, an event handler to receive the Submit Payment Form request from the payment gateway must be added. Since it must do the same processing as the Enter Contact Information.OK event handler, it is obvious to let it inherit from this function:
MyShop.Web.PaymentGateway | includes FNC | MyShop.Web.PaymentGateway.LoadSubmitPayment |
MyShop.Web.PaymentGateway. LoadSubmitPayment |
is a FNC |
MyShop.Abstract.PaymentGateway.Abstract. ReceiveFromExternalServer |
MyShop.Web.Ordering.Enter Contact Information.OK | ||
impl NME | LOADFORM | |
MyShop.Web.EventDispatcher | comprises FNC | MyShop.Web.PaymentGateway. LoadSubmitPayment |
Now the PaymentWebShop implementation will load its Submit Payment document relayed through the payment gateway.
It is strongly recommended that events sent to a payment gateway should be protected against accidental repeat e.g. because a web user hits the "Submit payment" button more than once while waiting for the payment confirmation.
The Websydian pattern Repeated Event Detection can be used to protect payment gateway events.
Example
The Submit Payment.OK event should be protected against accidental repeat. Both the scoped OK event handler and the event handlers receiving the result from the payment gateway must be modified:
MyShop.Web.Ordering.Submit Payment | is a FNC |
MyShop.Data.RepeatedEventDetection.Abstract. PageGenerator |
MyShop.Web.Ordering.Submit Payment.OK | is a FNC |
MyShop.Data.RepeatedEventDetection.Abstract. EventHandler |
MyShop.Web.PaymentGateway. LoadOkPage |
is a FNC |
MyShop.Data.RepeatedEventDetection.Abstract. EventHandler |
MyShop.Web.PaymentGateway. LoadErrorPage |
is a FNC |
MyShop.Data.RepeatedEventDetection.Abstract. EventHandler |
This will add a PageID field to the Submit Payment.OK event. In order for the RepeatedEventDetection implementation to work, the payment gateway must relay event parameters not part of the payment gateway protocol unchanged.
Refer to the Repeated Event Detection pattern documentation for more information.
The abstract PaymentGateway entity in PaymentWebShop is based on the pattern WSYUTIL/ExternalServerControl. This pattern is based on the assumption that a WebShop document has one and only one external event, and that the external URL is given by a field present in WsyDetails derived from the ancestor-field ExternalServerControl.Fields.URLString.
If a PaymentWebShop document should hold more than one payment gateway event, the page must be divided into one parent page and several child pages by using the Parent Child Page Generator pattern.