From e6960590f7340806184440c0e0aa56272578ebc9 Mon Sep 17 00:00:00 2001 From: Sung Cheng Date: Tue, 14 Dec 2021 14:17:17 -0500 Subject: [PATCH] Add message support for auth only (#7) * Add message support for auth only --- src/Message/IPNCallback.php | 21 ++++++++++++++++++++- tests/Message/IPNCallbackTest.php | 13 +++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/Message/IPNCallback.php b/src/Message/IPNCallback.php index 5f6f6ed..ff05cd5 100644 --- a/src/Message/IPNCallback.php +++ b/src/Message/IPNCallback.php @@ -107,8 +107,13 @@ 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() @@ -116,6 +121,20 @@ 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. diff --git a/tests/Message/IPNCallbackTest.php b/tests/Message/IPNCallbackTest.php index 495b162..4178a09 100644 --- a/tests/Message/IPNCallbackTest.php +++ b/tests/Message/IPNCallbackTest.php @@ -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 */