Skip to content

Instantly share code, notes, and snippets.

@adamlj
Created December 2, 2013 12:07
Show Gist options
  • Save adamlj/7748551 to your computer and use it in GitHub Desktop.
Save adamlj/7748551 to your computer and use it in GitHub Desktop.
PayMill Django Form
from decimal import Decimal
import pymill
p = pymill.Pymill(PRIVATE_KEY)
token = self.cleaned_data.get('token')
plan = {'initial_price': Decimal(0), 'external_id': 'ext_plan_id'}
price = int(plan.initial_price * Decimal(100))
email = '[email protected]'
try:
client = p.new_client(email=email)
payment = p.new_card(token, client=client)
subscription = p.new_subscription(client=client, offer=plan.external_id, payment=payment)
transaction = p.transact(price, payment=payment)
except:
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment