Version 4.7.23
This commit is contained in:
1 parent
7124a02564
commit
25ddeb65d6
1791 files changed
+76990
-44452
No files matched your search
@@ -123,11 +123,40 @@ class _CreditCard extends \IPS\Patterns\ActiveRecord
|
||||
* @param bool $admin Set to TRUE if the *admin* (opposed to the customer themselves) wants to create a new payment method
|
||||
* @param bool $showSubmitButton Will be set to a bool indicating if the submit button should be shown
|
||||
* @param array $hiddenValues Hidden values to add to the form
|
||||
* @param array|null $allowedPaymentMethods Payment method IDs that should be included. Populated when called from checkout.
|
||||
* @return array
|
||||
*/
|
||||
public static function createFormElements( \IPS\nexus\Customer $customer, $admin, &$showSubmitButton, &$hiddenValues )
|
||||
public static function createFormElements( \IPS\nexus\Customer $customer, $admin, &$showSubmitButton, &$hiddenValues, $allowedPaymentMethods=null )
|
||||
{
|
||||
$gateways = \IPS\nexus\Gateway::cardStorageGateways( $admin );
|
||||
|
||||
/* Remove any gateways that can't be used here */
|
||||
if( !empty( $allowedPaymentMethods ) )
|
||||
{
|
||||
foreach( $gateways as $id => $gateway )
|
||||
{
|
||||
if( !\in_array( $id, $allowedPaymentMethods ) )
|
||||
{
|
||||
unset( $gateways[ $id ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif( $address = $customer->primaryBillingAddress() )
|
||||
{
|
||||
/* If we're not coming from the checkout, we're trying to manually add a card.
|
||||
Check the user's country, and if it's not available, skip it */
|
||||
foreach( $gateways as $id => $gateway )
|
||||
{
|
||||
/* @var \IPS\nexus\Gateway $gateway */
|
||||
if( $gateway->countries !== '*' )
|
||||
{
|
||||
if( !\in_array( $address->country, explode( ',', $gateway->countries ) ) )
|
||||
{
|
||||
unset( $gateways[ $id ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$elements = array();
|
||||
$paymentMethodsToggles = array();
|
||||
|
||||
Reference in new issue
Block a user