Skip to content
Code-Schnipsel Gruppen Projekte
Commit 4f543214 erstellt von Patrick Müller's avatar Patrick Müller
Dateien durchsuchen

feat: implemented pause/resume subscription API

Übergeordneter 5899f14e
No related branches found
No related tags found
Keine zugehörigen Merge Requests gefunden
{ {
"name": "quiqqer\/payment-stripe", "name": "quiqqer\/payment-stripe",
"type": "quiqqer-module", "type": "quiqqer-module",
"description": "Use the Stripe payment gateway to accept payments in your QUIQQER Shop", "description": "Use the Stripe payment gateway to accept payments in your QUIQQER Shop",
"license": [ "license": [
"GPL-3.0+", "GPL-3.0+",
"PCSG QL-1.0" "PCSG QL-1.0"
], ],
"authors": [ "authors": [
{ {
"name": "Patrick M\u00fcller", "name": "Patrick M\u00fcller",
"email": "p.mueller@pcsg.de", "email": "p.mueller@pcsg.de",
"homepage": "https:\/\/www.pcsg.de", "homepage": "https:\/\/www.pcsg.de",
"role": "Developer" "role": "Developer"
}
],
"support": {
"email": "support@pcsg.de",
"url": "http:\/\/www.pcsg.de"
},
"require": {
"quiqqer\/payments": "^1.0.1|*@dev",
"stripe\/stripe-php": "^7",
"cbschuld\/browser.php": "^1"
},
"autoload": {
"psr-4": {
"QUI\\ERP\\Payments\\Stripe\\": "src\/QUI\/ERP\/Payments\/Stripe"
}
} }
],
"support": {
"email": "support@pcsg.de",
"url": "http:\/\/www.pcsg.de"
},
"require": {
"quiqqer\/payments": "^1.1|dev-master|dev-dev",
"stripe\/stripe-php": "^7",
"cbschuld\/browser.php": "^1"
},
"autoload": {
"psr-4": {
"QUI\\ERP\\Payments\\Stripe\\": "src\/QUI\/ERP\/Payments\/Stripe"
}
}
} }
\ No newline at end of file
...@@ -453,7 +453,7 @@ ...@@ -453,7 +453,7 @@
<de><![CDATA[Stripe Abonnement (Subscription) [subscriptionId] erstellt.]]></de> <de><![CDATA[Stripe Abonnement (Subscription) [subscriptionId] erstellt.]]></de>
<en><![CDATA[Stripe Subscription [subscriptionId] created.]]></en> <en><![CDATA[Stripe Subscription [subscriptionId] created.]]></en>
</locale> </locale>
<locale name="exception.PaymentMethods.Recurring.Subscriptions.cancelSubscription.no_data"> <locale name="exception.PaymentMethods.Recurring.Subscriptions.no_data">
<de><![CDATA[Zur Abrechnungsvereinbarung "[subscriptionId]" konnten im QUIQQER-System keine Daten gefunden werden.]]></de> <de><![CDATA[Zur Abrechnungsvereinbarung "[subscriptionId]" konnten im QUIQQER-System keine Daten gefunden werden.]]></de>
<en><![CDATA[No data was found in the QUIQQER system for Subscription "[subscriptionId]".]]></en> <en><![CDATA[No data was found in the QUIQQER system for Subscription "[subscriptionId]".]]></en>
</locale> </locale>
......
...@@ -84,6 +84,45 @@ public function cancelSubscription($subscriptionId, $reason = '') ...@@ -84,6 +84,45 @@ public function cancelSubscription($subscriptionId, $reason = '')
Subscriptions::cancelSubscription($subscriptionId, $reason); Subscriptions::cancelSubscription($subscriptionId, $reason);
} }
/**
* Suspend a Subscription
*
* This *temporarily* suspends the automated collection of payments until explicitly resumed.
*
* @param int|string $subscriptionId
* @param string $note (optional) - Suspension note
* @return void
*/
public function suspendSubscription($subscriptionId, string $note = null)
{
Subscriptions::suspendSubscription($subscriptionId);
}
/**
* Resume a suspended Subscription
*
* This resumes automated collection of payments of a previously supsendes Subscription.
*
* @param int|string $subscriptionId
* @param string $note (optional) - Resume note
* @return void
*/
public function resumeSubscription($subscriptionId, string $note = null)
{
Subscriptions::resumeSubscription($subscriptionId);
}
/**
* Checks if a subscription is currently suspended
*
* @param int|string $subscriptionId
* @return bool
*/
public function isSuspended($subscriptionId)
{
return Subscriptions::isSuspended($subscriptionId);
}
/** /**
* Sets a subscription as inactive (on the side of this QUIQQER system only!) * Sets a subscription as inactive (on the side of this QUIQQER system only!)
* *
......
...@@ -415,7 +415,7 @@ public static function cancelSubscription($subscriptionId, $reason = '') ...@@ -415,7 +415,7 @@ public static function cancelSubscription($subscriptionId, $reason = '')
if (empty($data)) { if (empty($data)) {
throw new QUI\ERP\Payments\Stripe\StripeException([ throw new QUI\ERP\Payments\Stripe\StripeException([
'quiqqer/payment-stripe', 'quiqqer/payment-stripe',
'exception.PaymentMethods.Recurring.Subscriptions.cancelSubscription.no_data', 'exception.PaymentMethods.Recurring.Subscriptions.no_data',
[ [
'subscriptionId' => $subscriptionId 'subscriptionId' => $subscriptionId
] ]
...@@ -439,6 +439,111 @@ public static function cancelSubscription($subscriptionId, $reason = '') ...@@ -439,6 +439,111 @@ public static function cancelSubscription($subscriptionId, $reason = '')
self::setSubscriptionAsInactive($subscriptionId); self::setSubscriptionAsInactive($subscriptionId);
} }
/**
* Suspend a Subscription
*
* This *temporarily* suspends the automated collection of payments until explicitly resumed.
*
* @param int|string $subscriptionId
* @return void
*
* @throws QUI\ERP\Payments\Stripe\StripeException
* @throws ApiErrorException
*/
public static function suspendSubscription($subscriptionId)
{
$data = self::getSubscriptionData($subscriptionId);
if (empty($data)) {
throw new QUI\ERP\Payments\Stripe\StripeException([
'quiqqer/payment-stripe',
'exception.PaymentMethods.Recurring.Subscriptions.no_data',
[
'subscriptionId' => $subscriptionId
]
]);
}
try {
$Locale = new QUI\Locale();
$Locale->setCurrent($data['customer']['lang']);
} catch (\Exception $Exception) {
QUI\System\Log::writeException($Exception);
return;
}
Provider::setupApi();
StripeSubscription::update(
$subscriptionId,
[
'pause_collection' => [
'behavior' => 'void'
]
]
);
}
/**
* Resume a suspended Subscription
*
* This resumes automated collection of payments of a previously supsendes Subscription.
*
* @param int|string $subscriptionId
* @return void
*
* @throws QUI\ERP\Payments\Stripe\StripeException
* @throws ApiErrorException
*/
public static function resumeSubscription($subscriptionId)
{
$data = self::getSubscriptionData($subscriptionId);
if (empty($data)) {
throw new QUI\ERP\Payments\Stripe\StripeException([
'quiqqer/payment-stripe',
'exception.PaymentMethods.Recurring.Subscriptions.no_data',
[
'subscriptionId' => $subscriptionId
]
]);
}
try {
$Locale = new QUI\Locale();
$Locale->setCurrent($data['customer']['lang']);
} catch (\Exception $Exception) {
QUI\System\Log::writeException($Exception);
return;
}
Provider::setupApi();
StripeSubscription::update(
$subscriptionId,
[
'pause_collection' => ''
]
);
}
/**
* Checks if a subscription is currently suspended
*
* @param int|string $subscriptionId
* @return bool
*/
public static function isSuspended($subscriptionId)
{
$data = self::getSubscriptionDetails($subscriptionId);
if (empty($data)) {
return false;
}
return !empty($data['pause_collection']);
}
/** /**
* Set a subscription as inactive * Set a subscription as inactive
* *
......
0% oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren