Version 4.3.6
This commit is contained in:
1 parent
fe1acf984a
commit
1a0c7fd3c2
609 files changed
+14707
-5726
No files matched your search
@@ -90,7 +90,7 @@ class _BillingAgreement extends \IPS\nexus\Customer\BillingAgreement
|
||||
* @return \IPS\nexus\Transaction
|
||||
* @throws \IPS\nexus\Gateway\PayPal\Exception
|
||||
* @throws \OutOfRangeException
|
||||
* @throws \IPS\Http\Exception
|
||||
* @throws \IPS\Http\Url\Exception
|
||||
*/
|
||||
public function latestUnclaimedTransaction()
|
||||
{
|
||||
@@ -121,7 +121,7 @@ class _BillingAgreement extends \IPS\nexus\Customer\BillingAgreement
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( \IPS\Http\Exception $e )
|
||||
catch ( \IPS\Http\Url\Exception $e )
|
||||
{
|
||||
throw $e;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,8 @@ class _PayPal extends \IPS\nexus\Gateway
|
||||
/* Card payments can only be certain currency amounts and require name and billing address */
|
||||
if ( $settings['type'] === 'card' )
|
||||
{
|
||||
if ( !in_array( $amount->currency, array( 'USD', 'GBP', 'CAD', 'EUR', 'JPY' ) ) or !$customer->cm_first_name or !$customer->cm_last_name or !$billingAddress )
|
||||
/* Supported Currencies via https://developer.paypal.com/docs/integration/direct/rest/currency-codes/ */
|
||||
if ( !\in_array( $amount->currency, array( 'AUD', 'USD', 'CZK', 'DKK', 'HKD', 'ILS', 'CAD', 'EUR', 'MXN', 'NZD', 'NOK', 'PHP', 'PLN', 'JPY', 'GBP', 'RUB', 'SGD', 'SEK', 'CHF', 'THB' ) ) or !$customer->cm_first_name or !$customer->cm_last_name or !$billingAddress )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -465,6 +465,10 @@ class _Stripe extends \IPS\nexus\Gateway
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if ( $billingAddress and !in_array( $billingAddress->country, array( 'AT', 'AU', 'BE', 'BR', 'CA', 'CH', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'HK', 'IE', 'IN', 'IT', 'JP', 'LT', 'LU', 'LV', 'MX', 'NL', 'NZ', 'NO', 'PH', 'PL', 'PT', 'RO', 'SE', 'SG', 'SK', 'US' ) ) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Still here? Do normal checks */
|
||||
@@ -659,7 +663,7 @@ class _Stripe extends \IPS\nexus\Gateway
|
||||
$maxMind->setTransactionType('creditcard');
|
||||
}
|
||||
}
|
||||
|
||||
$transaction->save();
|
||||
/* Build data */
|
||||
$data = array(
|
||||
'amount' => static::_amountAsCents( $transaction->amount ),
|
||||
@@ -669,7 +673,7 @@ class _Stripe extends \IPS\nexus\Gateway
|
||||
'metadata' => array(
|
||||
"Transaction ID" => $transaction->id,
|
||||
"Invoice ID" => $transaction->invoice->id,
|
||||
"Customer ID" => $transaction->member->id,
|
||||
"Customer ID" => $transaction->member->member_id,
|
||||
"Customer Email" => $transaction->member->email,
|
||||
),
|
||||
);
|
||||
@@ -728,6 +732,8 @@ class _Stripe extends \IPS\nexus\Gateway
|
||||
{
|
||||
$transaction->save();
|
||||
|
||||
/* Create the 3DSecure source */
|
||||
$returnUrl = \IPS\Settings::i()->base_url . 'applications/nexus/interface/gateways/stripe-redirector.php?nexusTransactionId=' . $transaction->id;
|
||||
$response = $this->api( "sources", array(
|
||||
'type' => 'three_d_secure',
|
||||
'amount' => static::_amountAsCents( $transaction->amount ),
|
||||
@@ -736,14 +742,30 @@ class _Stripe extends \IPS\nexus\Gateway
|
||||
'card' => $card->token
|
||||
),
|
||||
'redirect' => array(
|
||||
'return_url' => \IPS\Settings::i()->base_url . 'applications/nexus/interface/gateways/stripe-redirector.php?nexusTransactionId=' . $transaction->id
|
||||
'return_url' => $returnUrl
|
||||
),
|
||||
) );
|
||||
|
||||
/* If it's ready for them, send the customer over to the URL */
|
||||
if ( $response['status'] == 'pending' )
|
||||
{
|
||||
\IPS\Output::i()->redirect( $response['redirect']['url'] );
|
||||
}
|
||||
|
||||
/* It it's already chargeable (from Stripe: "This can happen if the customer's card has not yet
|
||||
been enrolled in 3D Secure") then we don't need to redirect them, but the webhooks will handle
|
||||
it from here, as if the customer had been redirected and authorized. Therefore, we can redirect
|
||||
the customer to the return URL where they would have been redirected had they actually authorized */
|
||||
elseif ( $response['status'] == 'chargeable' )
|
||||
{
|
||||
\IPS\Output::i()->redirect( $returnUrl );
|
||||
}
|
||||
|
||||
// If it failed (the only other possible value for $response['status']) Stripe advises "you can either
|
||||
// continue with a regular card payment, interrupt the payment flow, or attempt to create a 3D Secure
|
||||
// source later". We'll opt for continuing with a regular card payment, which means there's no else
|
||||
// clause here, we're just letting the code fall through below as if 3DSecure had been detected as not
|
||||
// being required.
|
||||
}
|
||||
|
||||
/* Are we saving it? */
|
||||
@@ -853,7 +875,20 @@ class _Stripe extends \IPS\nexus\Gateway
|
||||
return;
|
||||
}
|
||||
|
||||
$this->api( "charges/{$transaction->gw_id}/capture" );
|
||||
try
|
||||
{
|
||||
$this->api( "charges/{$transaction->gw_id}/capture" );
|
||||
}
|
||||
catch( \IPS\nexus\Gateway\Stripe\Exception $e )
|
||||
{
|
||||
/* If we have already captured/refunded the charge we don't need to let an exception bubble up */
|
||||
if( $e->details['code'] == 'charge_already_captured' or $e->details['code'] == 'charge_already_refunded' )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -929,6 +964,10 @@ class _Stripe extends \IPS\nexus\Gateway
|
||||
return \IPS\Theme::i()->getTemplate( 'transactions', 'nexus', 'admin' )->stripeData( $response, 'error' );
|
||||
}
|
||||
}
|
||||
elseif ( $response['source']['object'] === 'card' and isset( $response['card'] ) ) // For cards stored in older versions
|
||||
{
|
||||
$response['source']['card'] = $response['card'];
|
||||
}
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'transactions', 'nexus', 'admin' )->stripeData( $response );
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user