Cert++
Close

Linking a payment processor to SFRA payment processor hooks

Key Takeaway

A payment processor is only a container for gateway settings. An SFRA hook script can read those settings at run time to connect to the gateway. When several cartridges register the same hook, calling it runs the module in each cartridge, in cartridge-path order.

In B2C Commerce, a payment processor stores the settings for a payment gateway. Each payment method can be linked to one payment processor. SFRA hooks are named extension points that run a registered script when your code calls them. A hook script can read the payment processor's settings at run time to connect to the gateway. To link the two, you set up the payment processor, register a hook in a cartridge and call the hook from your code.

Payment methods and payment processors

A payment method is the logical way to pay. A payment processor (dw.order.PaymentProcessor) represents the physical gateway that processes a payment method. A payment processor can process payments of one or more types.

In B2C Commerce, a payment processor is only a container for configuration values. The values are what code needs to connect to a payment gateway, such as the URL, merchant ID and password.

Each payment method is associated with at most one payment processor. One payment processor can serve any number of payment methods. Each payment transaction has one payment processor. Custom code sets it during the checkout process.

A store offers two payment methods: credit card and store card. Both are linked to a payment processor with the ID NORTHWIND_PAY. The setup works because one payment processor can serve any number of payment methods. The credit card method can't also be linked to a second payment processor, because each payment method has at most one.

Script code can't create a payment processor, because PaymentProcessor has no constructor. Each payment processor has a read-only ID, such as BASIC_CREDIT, which code reads with getID().

B2C Commerce Developer Study Guide

Checklist progress

0/237Learned

Given a configuration for tasks, such as payment and shipping information, use Business Manager to enable shoppers to complete storefront orders

0/8

Prepare for the Exam

Play Today's Certle

Study Community

Ask questions and get the latest info from other B2C Commerce Developer studiers. 796 members and growing.