Пример #1
0
def get_interface_obj():
    """
    Use this function to get a PayPalInterface object with your test API
    credentials (as specified in api_details.py). Create new interfaces for
    each unit test module to avoid potential variable pollution. 
    """
    return PayPalInterface(config=api_details.CONFIG)
Пример #2
0
def get_paypal_interface():
    '''
	Returns a paypal interface handle
	'''
    CONFIG = PayPalConfig(API_USERNAME=PAYPAL_API_USERNAME,
                          API_PASSWORD=PAYPAL_API_PASSWORD,
                          API_SIGNATURE=PAYPAL_API_SIGNATURE,
                          API_ENVIRONMENT="production",
                          DEBUG_LEVEL=0)

    return PayPalInterface(config=CONFIG)
Пример #3
0
    def handle(self, *args, **options):
        now = datetime.now() - timedelta(days=30)

        try:
            latest = Transaction.objects.latest('timestamp').timestamp
        except Transaction.DoesNotExist:
            latest = datetime.now() - timedelta(days=365 * 5)

        pprint(latest)
        paypal = PayPalInterface(CONFIG)
        result = paypal.transaction_search(startdate=latest)
        print "grabbed %d items" % len(result.items())
        for item in result.items():
            error = False
            transaction = Transaction(id=item['TRANSACTIONID'])
            transaction.timestamp = datetime.strptime(
                item[u'TIMESTAMP'],
                '%Y-%m-%dT%H:%M:%SZ').replace(tzinfo=pytz.UTC)
            transaction.type = item[u'TYPE']
            try:
                transaction.email = item[u'EMAIL']
            except KeyError:
                error = True
            transaction.name = item[u'NAME']
            transaction.status = item[u'STATUS']
            try:
                transaction.amount = Money(item[u'AMT'], item[u'CURRENCYCODE'])
            except KeyError:
                error = True
            try:
                transaction.fee_amount = Money(item[u'FEEAMT'],
                                               item[u'CURRENCYCODE'])
            except KeyError:
                error = True
            try:
                transaction.net_amount = Money(item[u'NETAMT'],
                                               item[u'CURRENCYCODE'])
            except KeyError:
                error = True

            if error:
                pprint(item)
            transaction.save()
Пример #4
0
    def get_paypal_interface_obj(self):
        context = self.context
        props = getToolByName(context, 'portal_properties').paypal_properties

        #TODO: Need to be moved in configlet with description
        # Enter your test account's API details here. You'll need the 3-token
        # credentials, not the certificate stuff.
        #CONFIG = PayPalConfig(API_USERNAME = "******",
        #                      API_PASSWORD = "******",
        #                      API_SIGNATURE = "AuyTYUFGIfqpMeM0seVte",
        #                      DEBUG_LEVEL=0)

        CONFIG = PayPalConfig(API_USERNAME=props.api_username,
                              API_PASSWORD=props.api_password,
                              API_SIGNATURE=props.api_signature,
                              API_ENVIRONMENT=props.test and 'SANDBOX'
                              or 'PRODUCTION',
                              DEBUG_LEVEL=0)

        return PayPalInterface(config=CONFIG)
from paypal import PayPalConfig
from paypal import PayPalInterface

config = PayPalConfig(
    API_USERNAME="******",
    API_PASSWORD="******",
    API_SIGNATURE="ARJ3i6R11uqkA7Oilyp9Gg-y3foBAXzMhlvgGUVkmd2KXZQsVtuWvNAy",
    DEBUG_LEVEL=0)

interface = PayPalInterface(config=config)
Пример #6
0
import discord, json, asyncio, requests, smtplib, random, string
from paypal import PayPalInterface
from datetime import datetime, timedelta
from email.mime.text import MIMEText
from discord.ext.commands import Bot

bot = Bot(command_prefix='!')
notifChannel = '<channel ID>'
serverID = '<server ID>'
paypal_api = PayPalInterface(API_USERNAME="******",
                             API_PASSWORD="******",
                             API_SIGNATURE="<paypal api signature>",
                             DEBUG_LEVEL=0,
                             HTTP_TIMEOUT=30)


@bot.event
async def on_ready():
    print('Logged in as')
    print(bot.user.name)
    print(bot.user.id)


async def send_mail(code, email):
    msg = MIMEText('<message contents> %s' % code)
    msg['From'] = '<from email>'
    msg['To'] = email
    msg['Subject'] = '<message subject>'
    mail = smtplib.SMTP('smtp.gmail.com', 587)
    mail.ehlo()
    mail.starttls()