Skip to content

Commit 15cd59a

Browse files
Document how to implement test mode
Given that implementers of Omnipay are looking to have one piece of code work with multiple gateways testMode provides some challenges. I'm not sure the best way to deal with this. I would argue that Authorize.net should implement setTestMode to mean 'use sandbox account' since that is the normal meaning for other gateways, but that would not be backward compatible. At minimum I thought I could document how people should implement this to achieve the desired result
1 parent e01aa58 commit 15cd59a

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,25 @@ try {
437437
}
438438
```
439439

440+
## Test mode and developer mode
441+
Most gateways allow you to set up a sandbox or developer account which uses a different url
442+
and credentials. Some also allow you to do test transactions against the live site, which does
443+
not result in a live transaction.
444+
445+
Gateways that implement only the developer account (most of them) call it testMode. Authorize.net,
446+
however, implements both and refers to this mode as developerMode.
447+
448+
When implementing with multiple gateways you should use a construct along the lines of the following:
449+
450+
if ($is_developer_mode)
451+
{
452+
if (method_exists($gateway, 'setDeveloperMode')) {
453+
$gateway->setDeveloperMode(TRUE);
454+
} else {
455+
$gateway->setTestMode(TRUE);
456+
}
457+
}
458+
440459
## Token Billing
441460

442461
Token billing allows you to store a credit card with your gateway, and charge it at a later date.

0 commit comments

Comments
 (0)