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

feat: recurring payments #20

Übergeordneter 3e28d3ea
No related branches found
No related tags found
Keine zugehörigen Merge Requests gefunden
......@@ -435,7 +435,9 @@ define('package/quiqqer/payment-amazon/bin/controls/recurring/PaymentDisplay', [
$onPayBtnClick: function () {
var self = this;
this.$OrderProcess.Loader.show();
this.$OrderProcess.Loader.show(
QUILocale.get(pkg, 'controls.recurring.PaymentDisplay.loader.submit')
);
this.$createBillingAgreement().then(function (success) {
self.$OrderProcess.Loader.hide();
......
......@@ -482,6 +482,10 @@
<de><![CDATA[Die Erstellung der Abrechnungsvereinbarung über Amazon Pay ist fehlgeschlagen. Bitte wiederholen Sie den Vorgang oder wählen Sie eine andere Zahlungsmethode.]]></de>
<en><![CDATA[The creation of the billing agreement via Amazon Pay failed. Please repeat the process or choose another payment method.]]></en>
</locale>
<locale name="controls.recurring.PaymentDisplay.loader.submit">
<de><![CDATA[Zahlungsvereinbarung wird bei Amazon eingerichtet...]]></de>
<en><![CDATA[Billing agreement is set up at Amazon...]]></en>
</locale>
<!-- Control: bin/controls/backend/BillingAgreementWindow -->
<locale name="controls.backend.BillingAgreementWindow.title">
......
......@@ -272,6 +272,10 @@ class BillingAgreements
return;
}
if (!self::isBillingAgreementActiveAtAmazon($billingAgreementId)) {
return;
}
// Check if a Billing Agreement transaction matches the Invoice
$transactionData = self::getBillingAgreementTransactionData($billingAgreementId, $Invoice->getCleanId());
......@@ -332,7 +336,10 @@ class BillingAgreements
'authorization_reference_id' => Utils::formatApiString($Invoice->getId(), 32),
'authorization_amount' => $invoiceAmount,
'currency_code' => $invoiceCurrency,
'capture_now' => true, // immediately capture amount
// immediately capture amount
'capture_now' => true,
// synchronous mode; https://developer.amazon.com/de/docs/amazon-pay-automatic/sync-modes.html
'transaction_timeout' => 0,
'seller_authorization_note' => QUI::getLocale()->get(
'quiqqer/payment-amazon',
'recurring.BillingAgreement.seller_authorization_note',
......@@ -659,6 +666,23 @@ class BillingAgreements
}
}
/**
* Checks if the subscription is active at the Amazon side
*
* @param string $billingAgreementId
* @return bool
*/
public static function isBillingAgreementActiveAtAmazon(string $billingAgreementId)
{
try {
$data = BillingAgreements::getAmazonBillingAgreementData($billingAgreementId);
return $data['BillingAgreementStatus']['State'] === 'Open';
} catch (\Exception $Exception) {
QUI\System\Log::writeException($Exception);
return true;
}
}
/**
* Process all unpaid Invoices of Billing Agreements
*
......
......@@ -168,13 +168,7 @@ class Payment extends BasePayment implements RecurringPaymentInterface
*/
public function isSubscriptionActiveAtPaymentProvider($subscriptionId)
{
try {
$data = BillingAgreements::getAmazonBillingAgreementData($subscriptionId);
return $data['BillingAgreementStatus']['State'] === 'Open';
} catch (\Exception $Exception) {
QUI\System\Log::writeException($Exception);
return true;
}
return BillingAgreements::isBillingAgreementActiveAtAmazon($subscriptionId);
}
/**
......
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