Skip to content

Commit

Permalink
Add message support for auth only (#7)
Browse files Browse the repository at this point in the history
* Add message support for auth only
  • Loading branch information
sungcheng committed Dec 14, 2021
1 parent af65cdb commit e696059
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/Message/IPNCallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,34 @@ public function isCharge()

/**
* Is this a AUTH_ONLY_SINGLE_CHARGE IPN? This IPN is fired when
* a zero dollar transaction is made.
* a zero dollar transaction is made for plan type of
* standard subscription. Currently a product with a contract for a standard
* subscription only will only emit an auth charge IPN with no subscription info.
* https://bluesnap.zendesk.com/hc/en-us/requests/1444951
*
* https://support.bluesnap.com/docs/setting-up-a-standard-subscription-plan
* https://support.bluesnap.com/docs/ipns-name-reference#AUTH_ONLY_SINGLE_CHARGE
* @return bool
*/
public function isAuthOnlySingleCharge()
{
return $this->getIPNType() === 'AUTH_ONLY_SINGLE_CHARGE';
}

/**
* Is this a AUTH_ONLY_SINGLE_CHARGE IPN? This IPN is fired when
* a zero dollar transaction is made for plan type of standard subscription with trial.
*
* https://support.bluesnap.com/docs/ipns-name-reference#AUTH_ONLY
* https://support.bluesnap.com/docs/setting-up-a-standard-subscription-plan
* @return bool
*/
public function isAuthOnly()
{
return $this->getIPNType() === 'AUTH_ONLY';
}


/**
* 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 @@ -85,6 +85,19 @@ public function testIsAuthOnlySingleCharge()
$this->assertFalse($callback->isAuthOnlySingleCharge());
}

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

/**
* @return void
*/
Expand Down

0 comments on commit e696059

Please sign in to comment.