To be equivalent to the other one it should be:

result = authorize.Transaction.sale({'amount': 40.00, 'credit_card':
credit_card})

In this line:
result = authorize.Transaction.sale({40.00,credit_card})

You are not putting keys in the dictionary. If there are no keys Python
creates a 'set literal'. The error you are seeing is failing to create the
set (sets require all their elements to be hashable and dictionaries
aren't).

If you use the line at the beginning of the mail it should work.

On 13 June 2016 at 12:54, Arshpreet Singh <arsh...@gmail.com> wrote:

> I have to pass dictionary as function argument for following code:
>
> </code>
> import authorize
>
> authorize.Configuration.configure(
>     authorize.Environment.TEST,
>     'api_login_id',
>     'api_transaction_key',
> )
>
> result = authorize.Transaction.sale({
>     'amount': 40.00,
>
>     'credit_card': {
>         'card_number': '4111111111111111',
>         'expiration_date': '04/2014',
>         'card_code': '343',
>     }
>
> })
>
> result.transaction_response.trans_id
>
> </code>
>
> I want to define 'credit-card' dictionary as argument in the function as
> follows but it returns syntax error:
>
> </code>
>
> # define dictionary outside the function call:
> credit_card={
>         'card_number': '4111111111111111',
>         'expiration_date': '04/2014',
>         'card_code': '343',
>     }
>
> import authorize
>
> authorize.Configuration.configure(
>     authorize.Environment.TEST,
>     'api_login_id',
>     'api_transaction_key',
> )
>
> result = authorize.Transaction.sale({'amount': 40.00,credit_card})
>
> result.transaction_response.trans_id
>
> it returns following error:
>
> result = authorize.Transaction.sale({40.00,credit_card})
> TypeError: unhashable type: 'dict'
>
> Do I need to make changes in authorize.Transaction.sale() source code?
> --
> https://mail.python.org/mailman/listinfo/python-list
>



-- 
David Navarro Estruch
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to