Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8728227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:35:11+00:00 2026-06-13T08:35:11+00:00

I am using balanced payments to allow users to purchase services on my site.

  • 0

I am using balanced payments to allow users to purchase services on my site. When users are ready to checkout, they login/create an account on my site, then enter their credit card information. The card is charged and they are on their way.

As I mentioned above, my site offers a service so I charge their card every month automatically via a cronjob. I simply use the following one liner to grab the buyer:

buyer = balanced.Account.query.filter(email_address = emailAddress)[0]

Simple enough. However, credit cards are lost, they expire, users want to use a different credit card, etc. How do I go about allowing a user to edit their credit card or provide a new one? Do I simply create a separate page that allows them to enter their new credit card information via:

buyer = balanced.Marketplace.my_marketplace.create_buyer(emailAddress, card_uri = cardURI)

Finally, how does balanced decide which chard to use? How do I let users manage which credit card they would like to use? Do I simply store the card_uri and let them select which card URI to use?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T08:35:12+00:00Added an answer on June 13, 2026 at 8:35 am

    If you look at the source for the balanced-python library you can get hints about what parameters to use. I appreciate it may be a bit confusing for first-timers so thanks for asking a question.

    Adding a card to an existing account:

    card = balanced.Card(**card_payload)  # this could also just be a URI from a card tokenized with balanced.js
    account = balanced.Account.query.filter(email_address = emailAddress).one()
    account.add_card(card.uri)
    

    Charging a specific card:

    cards = account.cards
    # some magic here to select the correct card (e.g. prompt user for which card)
    card = magic_card_selection(cards)
    debit = account.debit(amount_in_cents, source_uri=card.uri)
    

    Displaying cards for a user

    cards = account.cards
    for card in cards:
        # display as you like, the card object has the following attributes:
        print card.__dict__.keys()
       ['expiration_month', 'account', 'hash', 'name', 'expiration_year', 'created_at', 'brand', 'uri', 'card_type', 'is_valid', 'meta', 'last_four', 'id']
    

    Here’s a complete example which may help:

    import balanced
    
    
    key = balanced.APIKey().save()
    balanced.configure(key.secret)
    balanced.Marketplace().save()
    
    buyer = balanced.Account(email_address='buyer@example.org').save()
    
    # add a new card
    card = balanced.Marketplace.my_marketplace.create_card(
        name='First card',
        card_number='5105105105105100',
        expiration_month='12',
        expiration_year='2020',
        security_code='123',
    )
    
    buyer.add_card(card.uri)
    
    # add another valid card 
    card = balanced.Marketplace.my_marketplace.create_card(
        name='Second card',
        card_number='5105105105105100',
        expiration_month='12',
        expiration_year='2020',
        security_code='123',
    )
    
    buyer.add_card(card.uri)
    
    amount_in_cents = 100  # $1.00
    
    first_card = buyer.cards[0]
    second_card = buyer.cards[1]
    
    # charge a specific card
    debit = buyer.debit(amount_in_cents, source_uri=first_card.uri)
    debit2 = buyer.debit(amount_in_cents, source_uri=second_card.uri)
    
    assert debit.source.uri == first_card.uri
    assert debit2.source.uri == second_card.uri
    
    # show all attributes on an object
    print first_card.__dict__.keys()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use ASP.NET and WCF services in a load balanced web server environment, using
I'm using balanced payments ruby api and accidentally created a couple of extra test
When using the Balanced Payments ruby gem (https://github.com/balanced/balanced-ruby), and using the Balanced::Hold#void method on
I have 2 load balanced web servers. My application is using the SQL Server
Here's the issue. I'm using ASP.NET Forms Authentication for an account balance type website.
I have a payments table that has a user_id and an amount. Users have
Using Damian Conway's Regexp::Grammars , I'm trying to match different balanced quoting ( 'foo'
We are working on an HTTP webservice load-balanced using haproxy. The webservice is accessed
We have three web servers in our web farm that are load balanced using
I have an MVC 2.0 application that requires a persistent login(if chosen) using forms

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.