This repository has been archived by the owner on Feb 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create coinbase order and place iframe
- Loading branch information
1 parent
85a1b07
commit 170d7f6
Showing
3 changed files
with
37 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,26 @@ | ||
from decimal import Decimal, InvalidOperation | ||
|
||
from gratipay.utils import get_participant | ||
from aspen import Response | ||
from aspen import log_dammit | ||
from coinbase.error import APIError | ||
from gratipay.utils import get_participant | ||
|
||
[---] | ||
|
||
request.allow('POST') | ||
|
||
get_participant(state, restrict=True) | ||
participant = get_participant(state, restrict=True) | ||
account = website.coinbase.get_account('primary') | ||
|
||
amount = request.body['amount'] | ||
try: | ||
amount = Decimal(amount) | ||
except InvalidOperation: | ||
raise Response(400, "Invalid Amount!") | ||
out = {} | ||
|
||
accounts = website.coinbase.get_authorization() | ||
try: | ||
out = account.create_button( | ||
"Gratipay (%s)" % participant.username, # name | ||
"100", # price_string | ||
"USD", # price_currency_iso | ||
description="Gratipay Bitcoin Payin", | ||
choose_price=True | ||
) | ||
except APIError: | ||
raise Response(500, "We're having trouble communicating with Coinbase, please try again.") | ||
[---] | ||
{{ accounts }} | ||
out |