Skip to content

Instantly share code, notes, and snippets.

@btoone

btoone/mp-zap.py

Created May 12, 2016
Embed
What would you like to do?
Script to pull data from MemberPress using the WordPress Rest API
import json
if input['desc'] == 'MP Test':
membership = 14
elif input['desc'] == 'MP Example':
membership = 99
else:
return {'status': 'Invalid button'}
# Get member_id
r = requests.get('http://username:password@membership-site.com/wp-json/mp/v1/members?search=' + input['email'])
r.raise_for_status()
members = json.loads(r.text)
member = members[0]
# Create new transaction (POST)
r = requests.post('http://username:password@membership-site.com/wp-json/mp/v1/transactions', json={"member":member['id'],"membership":membership,"trans_num":input["trans_num"],"amount":input["amount"],"status":"complete","gateway":input["gateway"]})
# r.raise_for_status()
transaction = json.loads(r.text)
return {'member':member,'membership':membership,'transaction':transaction}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.