globalpayments / php-sdk

GNU General Public License v2.0
49 stars 66 forks source link

Refund payment transaction using sandbox credentials always return error #33

Closed acaballes closed 5 years ago

acaballes commented 5 years ago

Processing refund payments with sandbox credentials always returns Could Not Process Payment: currency cannot be null for this transaction type

acaballes commented 5 years ago

`GlobalPayments\Api\Entities\Exceptions\BuilderException Object ( [message:protected] => currency cannot be null for this transaction type. [string:Exception:private] => [code:protected] => 0 [file:protected] => /app/vendor/globalpayments/php-sdk/src/Builders/BaseBuilder.php [line:protected] => 90 [trace:Exception:private] => Array ( [0] => Array ( [function] => maybeRunValidationKeyRules [class] => GlobalPayments\Api\Builders\BaseBuilder [type] => -> [args] => Array ( [0] => 16 )

            )

        [1] => Array
            (
                [file] => /app/vendor/globalpayments/php-sdk/src/Builders/BaseBuilder.php
                [line] => 64
                [function] => array_map
                [args] => Array
                    (
                        [0] => Array
                            (
                                [0] => GlobalPayments\Api\Builders\ManagementBuilder Object
                                    (
                                        [amount] => 1
                                        [authAmount] => 
                                        [clientTransactionId] => 
                                        [currency] => 
                                        [description] => 
                                        [gratuity] => 
                                        [poNumber] => 
                                        [reasonCode] => 
                                        [taxAmount] => 
                                        [taxType] => 
                                        [paymentMethod] => GlobalPayments\Api\PaymentMethods\TransactionReference Object
                                            (
                                                [paymentMethodType] => 1
                                                [authCode] => 
                                                [transactionId] => 1230230242
                                                [orderId] => 
                                            )

                                        [alternativePaymentType] => 
                                        [payerAuthenticationResponse] => 
                                        [transactionType] => 16
                                        [transactionModifier] => 0
                                        [allowDuplicates] => 
                                        [validations:protected] => GlobalPayments\Api\Builders\BaseBuilder\Validations Object
                                            (
                                                [rules] => Array
                                                    (
                                                        [6291588] => Array
                                                            (
                                                                [0] => GlobalPayments\Api\Builders\BaseBuilder\ValidationTarget Object
                                                                    (
                                                                        [parent] => GlobalPayments\Api\Builders\BaseBuilder\Validations Object

RECURSION [type] => 6291588 [modifier] => 0 [property] => transactionId [clause] => GlobalPayments\Api\Builders\BaseBuilder\ValidationClause Object ( [parent] => GlobalPayments\Api\Builders\BaseBuilder\Validations Object RECURSION [target] => GlobalPayments\Api\Builders\BaseBuilder\ValidationTarget Object RECURSION [precondition] => [callback] => Closure Object ( [static] => Array ( [subProperty] => )

                                                                                        [this] => GlobalPayments\Api\Builders\BaseBuilder\ValidationClause Object

RECURSION [parameter] => Array ( [$builder] => )

                                                                                    )

                                                                                [message] => transactionId cannot be null for this transaction type.
                                                                            )

                                                                    )

                                                                [1] => GlobalPayments\Api\Builders\BaseBuilder\ValidationTarget Object
                                                                    (
                                                                        [parent] => GlobalPayments\Api\Builders\BaseBuilder\Validations Object

RECURSION [type] => 6291588 [modifier] => 0 [property] => [clause] => )

                                                            )

                                                        [128] => Array
                                                            (
                                                                [0] => GlobalPayments\Api\Builders\BaseBuilder\ValidationTarget Object
                                                                    (
                                                                        [parent] => GlobalPayments\Api\Builders\BaseBuilder\Validations Object

RECURSION [type] => 128 [modifier] => 4 [property] => taxType [clause] => GlobalPayments\Api\Builders\BaseBuilder\ValidationClause Object ( [parent] => GlobalPayments\Api\Builders\BaseBuilder\Validations Object RECURSION [target] => GlobalPayments\Api\Builders\BaseBuilder\ValidationTarget Object RECURSION [precondition] => [callback] => Closure Object ( [static] => Array ( [subProperty] => )

                                                                                        [this] => GlobalPayments\Api\Builders\BaseBuilder\ValidationClause Object

RECURSION [parameter] => Array ( [$builder] => )

                                                                                    )

                                                                                [message] => taxType cannot be null for this transaction type.
                                                                            )

                                                                    )

                                                                [1] => GlobalPayments\Api\Builders\BaseBuilder\ValidationTarget Object
                                                                    (
                                                                        [parent] => GlobalPayments\Api\Builders\BaseBuilder\Validations Object

RECURSION [type] => 128 [modifier] => 4 [property] => [clause] => )

                                                            )

                                                        [16] => Array
                                                            (
                                                                [0] => GlobalPayments\Api\Builders\BaseBuilder\ValidationTarget Object
                                                                    (
                                                                        [parent] => GlobalPayments\Api\Builders\BaseBuilder\Validations Object

RECURSION [type] => 16 [modifier] => 0 [property] => currency [clause] => GlobalPayments\Api\Builders\BaseBuilder\ValidationClause Object ( [parent] => GlobalPayments\Api\Builders\BaseBuilder\Validations Object RECURSION [target] => GlobalPayments\Api\Builders\BaseBuilder\ValidationTarget Object RECURSION [precondition] => [callback] => Closure Object ( [static] => Array ( [subProperty] => )

                                                                                        [this] => GlobalPayments\Api\Builders\BaseBuilder\ValidationClause Object

RECURSION [parameter] => Array ( [$builder] => )

                                                                                    )

                                                                                [message] => currency cannot be null for this transaction type.
                                                                            )

                                                                    )

                                                                [1] => GlobalPayments\Api\Builders\BaseBuilder\ValidationTarget Object
                                                                    (
                                                                        [parent] => GlobalPayments\Api\Builders\BaseBuilder\Validations Object

RECURSION [type] => 16 [modifier] => 0 [property] => [clause] => )

                                                            )

                                                        [33554432] => Array
                                                            (
                                                                [0] => GlobalPayments\Api\Builders\BaseBuilder\ValidationTarget Object
                                                                    (
                                                                        [parent] => GlobalPayments\Api\Builders\BaseBuilder\Validations Object

RECURSION [type] => 33554432 [modifier] => 0 [property] => payerAuthenticationResponse [clause] => GlobalPayments\Api\Builders\BaseBuilder\ValidationClause Object ( [parent] => GlobalPayments\Api\Builders\BaseBuilder\Validations Object RECURSION [target] => GlobalPayments\Api\Builders\BaseBuilder\ValidationTarget Object RECURSION [precondition] => [callback] => Closure Object ( [static] => Array ( [subProperty] => )

                                                                                        [this] => GlobalPayments\Api\Builders\BaseBuilder\ValidationClause Object

RECURSION [parameter] => Array ( [$builder] => )

                                                                                    )

                                                                                [message] => payerAuthenticationResponse cannot be null for this transaction type.
                                                                            )

                                                                    )

                                                                [1] => GlobalPayments\Api\Builders\BaseBuilder\ValidationTarget Object
                                                                    (
                                                                        [parent] => GlobalPayments\Api\Builders\BaseBuilder\Validations Object

RECURSION [type] => 33554432 [modifier] => 0 [property] => amount [clause] => GlobalPayments\Api\Builders\BaseBuilder\ValidationClause Object ( [parent] => GlobalPayments\Api\Builders\BaseBuilder\Validations Object RECURSION [target] => GlobalPayments\Api\Builders\BaseBuilder\ValidationTarget Object RECURSION [precondition] => [callback] => Closure Object ( [static] => Array ( [subProperty] => )

                                                                                        [this] => GlobalPayments\Api\Builders\BaseBuilder\ValidationClause Object

RECURSION [parameter] => Array ( [$builder] => )

                                                                                    )

                                                                                [message] => amount cannot be null for this transaction type.
                                                                            )

                                                                    )

                                                                [2] => GlobalPayments\Api\Builders\BaseBuilder\ValidationTarget Object
                                                                    (
                                                                        [parent] => GlobalPayments\Api\Builders\BaseBuilder\Validations Object

RECURSION [type] => 33554432 [modifier] => 0 [property] => currency [clause] => GlobalPayments\Api\Builders\BaseBuilder\ValidationClause Object ( [parent] => GlobalPayments\Api\Builders\BaseBuilder\Validations Object RECURSION [target] => GlobalPayments\Api\Builders\BaseBuilder\ValidationTarget Object RECURSION [precondition] => [callback] => Closure Object ( [static] => Array ( [subProperty] => )

                                                                                        [this] => GlobalPayments\Api\Builders\BaseBuilder\ValidationClause Object

RECURSION [parameter] => Array ( [$builder] => )

                                                                                    )

                                                                                [message] => currency cannot be null for this transaction type.
                                                                            )

                                                                    )

                                                                [3] => GlobalPayments\Api\Builders\BaseBuilder\ValidationTarget Object
                                                                    (
                                                                        [parent] => GlobalPayments\Api\Builders\BaseBuilder\Validations Object

RECURSION [type] => 33554432 [modifier] => 0 [property] => orderId [clause] => GlobalPayments\Api\Builders\BaseBuilder\ValidationClause Object ( [parent] => GlobalPayments\Api\Builders\BaseBuilder\Validations Object RECURSION [target] => GlobalPayments\Api\Builders\BaseBuilder\ValidationTarget Object RECURSION [precondition] => [callback] => Closure Object ( [static] => Array ( [subProperty] => )

                                                                                        [this] => GlobalPayments\Api\Builders\BaseBuilder\ValidationClause Object

RECURSION [parameter] => Array ( [$builder] => )

                                                                                    )

                                                                                [message] => orderId cannot be null for this transaction type.
                                                                            )

                                                                    )

                                                                [4] => GlobalPayments\Api\Builders\BaseBuilder\ValidationTarget Object
                                                                    (
                                                                        [parent] => GlobalPayments\Api\Builders\BaseBuilder\Validations Object

RECURSION [type] => 33554432 [modifier] => 0 [property] => [clause] => )

                                                            )

                                                        [2214592512] => Array
                                                            (
                                                                [0] => GlobalPayments\Api\Builders\BaseBuilder\ValidationTarget Object
                                                                    (
                                                                        [parent] => GlobalPayments\Api\Builders\BaseBuilder\Validations Object

RECURSION [type] => 2214592512 [modifier] => 0 [property] => paymentMethod [clause] => GlobalPayments\Api\Builders\BaseBuilder\ValidationClause Object ( [parent] => GlobalPayments\Api\Builders\BaseBuilder\Validations Object RECURSION [target] => GlobalPayments\Api\Builders\BaseBuilder\ValidationTarget Object RECURSION [precondition] => [callback] => Closure Object ( [static] => Array ( [subProperty] => )

                                                                                        [this] => GlobalPayments\Api\Builders\BaseBuilder\ValidationClause Object

RECURSION [parameter] => Array ( [$builder] => )

                                                                                    )

                                                                                [message] => paymentMethod cannot be null for this transaction type.
                                                                            )

                                                                    )

                                                                [1] => GlobalPayments\Api\Builders\BaseBuilder\ValidationTarget Object
                                                                    (
                                                                        [parent] => GlobalPayments\Api\Builders\BaseBuilder\Validations Object

RECURSION [type] => 2214592512 [modifier] => 0 [property] => paymentMethod [clause] => GlobalPayments\Api\Builders\BaseBuilder\ValidationClause Object ( [parent] => GlobalPayments\Api\Builders\BaseBuilder\Validations Object RECURSION [target] => GlobalPayments\Api\Builders\BaseBuilder\ValidationTarget Object RECURSION [precondition] => [callback] => Closure Object ( [static] => Array ( [clazz] => GlobalPayments\Api\PaymentMethods\Interfaces\ITokenizable )

                                                                                        [this] => GlobalPayments\Api\Builders\BaseBuilder\ValidationClause Object

RECURSION [parameter] => Array ( [$builder] => )

                                                                                    )

                                                                                [message] => paymentMethod must be an instance of the GlobalPayments\Api\PaymentMethods\Interfaces\ITokenizable class.
                                                                            )

                                                                    )

                                                                [2] => GlobalPayments\Api\Builders\BaseBuilder\ValidationTarget Object
                                                                    (
                                                                        [parent] => GlobalPayments\Api\Builders\BaseBuilder\Validations Object

RECURSION [type] => 2214592512 [modifier] => 0 [property] => [clause] => )

                                                            )

                                                        [2147483648] => Array
                                                            (
                                                                [0] => GlobalPayments\Api\Builders\BaseBuilder\ValidationTarget Object
                                                                    (
                                                                        [parent] => GlobalPayments\Api\Builders\BaseBuilder\Validations Object

RECURSION [type] => 2147483648 [modifier] => 0 [property] => paymentMethod [clause] => GlobalPayments\Api\Builders\BaseBuilder\ValidationClause Object ( [parent] => GlobalPayments\Api\Builders\BaseBuilder\Validations Object RECURSION [target] => GlobalPayments\Api\Builders\BaseBuilder\ValidationTarget Object RECURSION [precondition] => [callback] => Closure Object ( [static] => Array ( [clazz] => GlobalPayments\Api\PaymentMethods\CreditCardData )

                                                                                        [this] => GlobalPayments\Api\Builders\BaseBuilder\ValidationClause Object

RECURSION [parameter] => Array ( [$builder] => )

                                                                                    )

                                                                                [message] => paymentMethod must be an instance of the GlobalPayments\Api\PaymentMethods\CreditCardData class.
                                                                            )

                                                                    )

                                                                [1] => GlobalPayments\Api\Builders\BaseBuilder\ValidationTarget Object
                                                                    (
                                                                        [parent] => GlobalPayments\Api\Builders\BaseBuilder\Validations Object

RECURSION [type] => 2147483648 [modifier] => 0 [property] => [clause] => )

                                                            )

                                                    )

                                            )

                                        [executed:protected] => 
                                    )

                                [1] => maybeRunValidationKeyRules
                            )

                        [1] => Array
                            (
                                [0] => 6291588
                                [1] => 128
                                [2] => 16
                                [3] => 33554432
                                [4] => 2214592512
                                [5] => 2147483648
                            )

                    )

            )

        [2] => Array
            (
                [file] => /app/vendor/globalpayments/php-sdk/src/Builders/BaseBuilder.php
                [line] => 44
                [function] => validate
                [class] => GlobalPayments\Api\Builders\BaseBuilder
                [type] => ->
                [args] => Array
                    (
                    )

            )

        [3] => Array
            (
                [file] => /app/vendor/globalpayments/php-sdk/src/Builders/ManagementBuilder.php
                [line] => 173
                [function] => execute
                [class] => GlobalPayments\Api\Builders\BaseBuilder
                [type] => ->
                [args] => Array
                    (
                    )

            )

        [4] => Array
            (
                [file] => /app/application/libraries/Heartland_payment.php
                [line] => 118
                [function] => execute
                [class] => GlobalPayments\Api\Builders\ManagementBuilder
                [type] => ->
                [args] => Array
                    (
                    )

            )

        [5] => Array
            (
                [file] => /app/application/controllers/Invoices.php
                [line] => 1323
                [function] => processPayment
                [class] => Heartland_payment
                [type] => ->
                [args] => Array
                    (
                        [0] => supt_V0K5n4cKgrJGdtYzaK7bSBf8
                    )

            )

        [6] => Array
            (
                [file] => /app/application/core/Base_Controller.php
                [line] => 19
                [function] => process_payment
                [class] => Invoices
                [type] => ->
                [args] => Array
                    (
                    )

            )

        [7] => Array
            (
                [file] => /app/system/core/CodeIgniter.php
                [line] => 532
                [function] => _remap
                [class] => Base_Controller
                [type] => ->
                [args] => Array
                    (
                        [0] => process_payment
                        [1] => Array
                            (
                            )

                    )

            )

        [8] => Array
            (
                [file] => /var/www/html/ally/index.php
                [line] => 295
                [args] => Array
                    (
                        [0] => /app/system/core/CodeIgniter.php
                    )

                [function] => require_once
            )

    )

[previous:Exception:private] => 

)`

eric-vest commented 5 years ago

Hi acaballes,

Thank you for the PR regarding this, but rather than passing in the currency as a parameter to refund, you would use the builder, like so:

$response = $card->refund(10) ->withCurrency('USD') ->execute();

Thanks, Eric

acaballes commented 5 years ago

Hi eric-vest, that works. Thanks