diff --git a/src/Gateway.php b/src/Gateway.php index ca1a662..309a4c4 100644 --- a/src/Gateway.php +++ b/src/Gateway.php @@ -85,6 +85,25 @@ public function __construct(string $id, string $token, string $environment) $this->environment = $environment; } + /** + * Pre-authorize a purchase. + * + * @param array $params + * + * @return \CraigPaul\Moneris\Response + */ + public function preauth(array $params = []) + { + $params = array_merge($params, [ + 'type' => 'preauth', + 'crypt_type' => Crypt::SSL_ENABLED_MERCHANT, + ]); + + $transaction = $this->transaction($params); + + return $this->process($transaction); + } + /** * Make a purchase. * diff --git a/src/Transaction.php b/src/Transaction.php index 46d7b8a..e202889 100644 --- a/src/Transaction.php +++ b/src/Transaction.php @@ -165,6 +165,7 @@ public function valid() if (isset($params['type'])) { switch ($params['type']) { + case 'preauth': case 'purchase': $errors[] = Validator::set($params, 'order_id') ? null : 'Order Id not provided.'; $errors[] = Validator::set($params, 'pan') ? null : 'Credit card number not provided.';