Skip to content

Commit

Permalink
[TXNS-1496] Add message support for auth only single charge (#6)
Browse files Browse the repository at this point in the history
* Add message support for auth only single charge
  • Loading branch information
sungcheng committed Dec 3, 2021
1 parent 2123e29 commit af65cdb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Message/IPNCallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,17 @@ public function isCharge()
return $this->getIPNType() === 'CHARGE';
}

/**
* Is this a AUTH_ONLY_SINGLE_CHARGE IPN? This IPN is fired when
* a zero dollar transaction is made.
*
* @return bool
*/
public function isAuthOnlySingleCharge()
{
return $this->getIPNType() === 'AUTH_ONLY_SINGLE_CHARGE';
}

/**
* Is this a CANCELLATION IPN? Cancellation IPNs are fired when a recurring charge
* is cancelled.
Expand Down
13 changes: 13 additions & 0 deletions tests/Message/IPNCallbackTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,19 @@ public function testIsCharge()
$this->assertFalse($callback->isCharge());
}

/**
* @return void
*/
public function testIsAuthOnlySingleCharge()
{
$callback = new IPNCallback($this->queryString . '&transactionType=AUTH_ONLY_SINGLE_CHARGE');
$this->assertTrue($callback->isAuthOnlySingleCharge());
$callback = new IPNCallback($this->faker->url() . '?transactionType=AUTH_ONLY_SINGLE_CHARGE&' . $this->queryString);
$this->assertTrue($callback->isAuthOnlySingleCharge());
$callback = new IPNCallback($this->queryString . '&transactionType=CANCELLATION');
$this->assertFalse($callback->isAuthOnlySingleCharge());
}

/**
* @return void
*/
Expand Down

0 comments on commit af65cdb

Please sign in to comment.