++ hack
This commit is contained in:
parent
aa9548e753
commit
074efffaa7
6 changed files with 56 additions and 6 deletions
|
@ -6,4 +6,37 @@
|
||||||
https://account.ungleich.ch
|
https://account.ungleich.ch
|
||||||
* httpie installed (provides the http command)
|
* httpie installed (provides the http command)
|
||||||
|
|
||||||
### Get a membership
|
## Get a membership
|
||||||
|
|
||||||
|
|
||||||
|
## Registering a payment method
|
||||||
|
|
||||||
|
To be able to pay for the membership, you will need to register a
|
||||||
|
credit card or apply for payment on bill (TO BE IMPLEMENTED).
|
||||||
|
|
||||||
|
### Register credit card
|
||||||
|
|
||||||
|
```
|
||||||
|
http POST https://api.ungleich.ch/membership \
|
||||||
|
username=nico password=yourpassword \
|
||||||
|
cc_number=.. \
|
||||||
|
cc_
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Request payment via bill
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Create the membership
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
http POST https://api.ungleich.ch/membership username=nico password=yourpassword
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
## List available products
|
||||||
|
|
|
@ -5,6 +5,9 @@ from ldap_manager import LdapManager
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read('pay.conf')
|
config.read('pay.conf')
|
||||||
|
|
||||||
|
# Note 2020-02-15: this stuff clearly does not belong here,
|
||||||
|
# if config.py is used everywhere.
|
||||||
|
|
||||||
etcd_client = EtcdWrapper(host=config['etcd']['host'], port=config['etcd']['port'])
|
etcd_client = EtcdWrapper(host=config['etcd']['host'], port=config['etcd']['port'])
|
||||||
|
|
||||||
ldap_manager = LdapManager(server=config['ldap']['server'], admin_dn=config['ldap']['admin_dn'],
|
ldap_manager = LdapManager(server=config['ldap']['server'], admin_dn=config['ldap']['admin_dn'],
|
||||||
|
|
5
hack.py
5
hack.py
|
@ -70,6 +70,11 @@ class Membership(Resource):
|
||||||
print("{} {}".format(data, config))
|
print("{} {}".format(data, config))
|
||||||
return {'message': 'Order successful' }, 200
|
return {'message': 'Order successful' }, 200
|
||||||
|
|
||||||
|
def post(self):
|
||||||
|
data = request.get_json(silent=True) or {}
|
||||||
|
print("{} {}".format(data, config))
|
||||||
|
return {'message': 'Order 2x successful' }, 200
|
||||||
|
|
||||||
|
|
||||||
class Order(Resource):
|
class Order(Resource):
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
flask-restful
|
flask-restful
|
||||||
ldap3
|
ldap3
|
||||||
etcd3
|
etcd3
|
||||||
|
stripe
|
||||||
|
|
7
stripe_hack.py
Normal file
7
stripe_hack.py
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
import stripe_utils
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
s = stripe_utils.StripeUtils(os.environ['STRIPE_PRIVATE_KEY'])
|
||||||
|
print(s.get_stripe_customer_from_email('coder.purple+2002@gmail.com'))
|
|
@ -4,9 +4,9 @@ import stripe
|
||||||
import stripe.error
|
import stripe.error
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from config import etcd_client as client, config as config
|
# FIXME: way too many dependencies in this import
|
||||||
|
# Most of them are not needed for stripe
|
||||||
stripe.api_key = config['stripe']['private_key']
|
#from config import etcd_client as client, config as config
|
||||||
|
|
||||||
|
|
||||||
def handle_stripe_error(f):
|
def handle_stripe_error(f):
|
||||||
|
@ -73,8 +73,9 @@ class StripeUtils(object):
|
||||||
PLAN_EXISTS_ERROR_MSG = 'Plan {} exists already.\nCreating a local StripePlan now.'
|
PLAN_EXISTS_ERROR_MSG = 'Plan {} exists already.\nCreating a local StripePlan now.'
|
||||||
PLAN_DOES_NOT_EXIST_ERROR_MSG = 'Plan {} does not exist.'
|
PLAN_DOES_NOT_EXIST_ERROR_MSG = 'Plan {} does not exist.'
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, private_key):
|
||||||
self.stripe = stripe
|
self.stripe = stripe
|
||||||
|
stripe.api_key = private_key
|
||||||
|
|
||||||
@handle_stripe_error
|
@handle_stripe_error
|
||||||
def card_exists(self, customer, cc_number, exp_month, exp_year, cvc):
|
def card_exists(self, customer, cc_number, exp_month, exp_year, cvc):
|
||||||
|
|
Loading…
Reference in a new issue