Skip to content

Instantly share code, notes, and snippets.

@adamlj
adamlj / send_mailgun_attachments.py
Created January 23, 2014 10:53
MailGun API Python Requests multiple Attachments Send mail with multiple files/attachments with custom file names
requests.post("https://api.mailgun.net/v2/DOMAIN/messages",
auth=("api", "key-SECRET"),
files={
"attachment[0]": ("FileName1.ext", open(FILE_PATH_1, 'rb')),
"attachment[1]": ("FileName2.ext", open(FILE_PATH_2, 'rb'))
},
data={"from": "FROM_EMAIL",
"to": [TO_EMAIL],
"subject": SUBJECT,
"html": HTML_CONTENT
@adamlj
adamlj / paymill-form.js
Created December 2, 2013 12:10
PayMill Form JQuery JS
$(function() {
function paymillResponseHandler(error, result) {
if (error) {
$(".alert-danger").removeClass('hidden');
$(".alert-danger").append('<p>' + error.apierror + '</p>');
$("button.btn-success").removeAttr("disabled");
} else {
$("#id_token").val(result.token)
$("form").get(0).submit();
}
@adamlj
adamlj / paymill_form.py
Created December 2, 2013 12:07
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: