Version 4.7.23
This commit is contained in:
1 parent
7124a02564
commit
25ddeb65d6
1791 files changed
+76990
-44452
No files matched your search
@@ -122,6 +122,7 @@ class _BillingAgreement extends \IPS\nexus\Customer\BillingAgreement
|
||||
/* PayPal Subscriptions */
|
||||
if ( isset( $data['plan_id'] ) )
|
||||
{
|
||||
$url = '';
|
||||
$transactions = $this->method->api( "billing/subscriptions/{$this->gw_id}/transactions?start_time=" . \IPS\DateTime::create()->sub( new \DateInterval( 'P31D' ) )->rfc3339() . '&end_time=' . \IPS\DateTime::create()->rfc3339(), NULL, 'get' );
|
||||
foreach ( array_reverse( $transactions['transactions'] ?? [] ) as $t )
|
||||
{
|
||||
@@ -129,7 +130,8 @@ class _BillingAgreement extends \IPS\nexus\Customer\BillingAgreement
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Db::i()->select( 't_id', 'nexus_transactions', array( 't_method=? AND t_gw_id=?', $this->method->id, $t['id'] ) )->first();
|
||||
/* @note SELECT_FROM_WRITE_SERVER transaction race condition */
|
||||
\IPS\Db::i()->select( 't_id', 'nexus_transactions', [ 't_gw_id=? AND t_method=?', $t['id'], $this->method->id ], flags: \IPS\Db::SELECT_FROM_WRITE_SERVER )->first();
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
@@ -157,7 +159,8 @@ class _BillingAgreement extends \IPS\nexus\Customer\BillingAgreement
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Db::i()->select( 't_id', 'nexus_transactions', array( 't_method=? AND t_gw_id=?', $this->method->id, $t['transaction_id'] ) )->first();
|
||||
/* @note SELECT_FROM_WRITE_SERVER transaction race condition */
|
||||
\IPS\Db::i()->select( 't_id', 'nexus_transactions', [ 't_gw_id=? AND t_method=?', $t['transaction_id'], $this->method->id ], flags: \IPS\Db::SELECT_FROM_WRITE_SERVER )->first();
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
|
||||
@@ -94,7 +94,7 @@ class _Exception extends \DomainException
|
||||
break;
|
||||
|
||||
default:
|
||||
if( isset( $details ) AND $details[0]['issue'] === 'INSTRUMENT_DECLINED' )
|
||||
if( isset( $details[0] ) AND $details[0]['issue'] === 'INSTRUMENT_DECLINED' )
|
||||
{
|
||||
$message = \IPS\Member::loggedIn()->language()->get( 'payment_refused' );
|
||||
}
|
||||
|
||||
@@ -623,6 +623,19 @@ class _PayPal extends \IPS\nexus\Gateway
|
||||
'return_url' => \IPS\Settings::i()->base_url . 'applications/nexus/interface/gateways/paypal.php?subscription=1&nexusTransactionId=' . $transaction->id,
|
||||
)
|
||||
) );
|
||||
|
||||
/* PayPal sometimes does not include the subscription ID in the webhook. This causes a race condition
|
||||
and we can't properly link the transaction. So let's create the Billing Agreement record now. */
|
||||
$billingAgreement = new \IPS\nexus\Gateway\PayPal\BillingAgreement;
|
||||
$billingAgreement->gw_id = $subscription['id'];
|
||||
$billingAgreement->method = $transaction->method;
|
||||
$billingAgreement->member = $transaction->member;
|
||||
$billingAgreement->started = \IPS\DateTime::create();
|
||||
$billingAgreement->next_cycle = \IPS\DateTime::create()->add( $term->interval );
|
||||
$billingAgreement->save();
|
||||
|
||||
$transaction->billing_agreement = $billingAgreement;
|
||||
$transaction->save();
|
||||
|
||||
/* Redirect */
|
||||
foreach ( $subscription['links'] as $link )
|
||||
|
||||
Reference in new issue
Block a user