示例#1
0
def get_yandex_instance_id_key(yandex_client_id):
    yandex_instance_id_key = os.environ.get('YANDEX_MONEY_INSTANCE_ID_KEY', None)

    if yandex_instance_id_key is None:
        response_payment_instance = ExternalPayment.get_instance_id(yandex_client_id)
        yandex_instance_id_key = response_payment_instance['instance_id']
        os.environ['YANDEX_MONEY_INSTANCE_ID_KEY'] = yandex_instance_id_key

    return yandex_instance_id_key
    def makeRequest(self):
        instance_id = ExternalPayment.get_instance_id(CLIENT_ID)['instance_id']

        api = ExternalPayment(instance_id)
        options = {
            "instance_id": instance_id,
            "pattern_id": "p2p",
            "to": "410011161616877",
            "amount_due": "0.02",
            "comment": "test payment comment from yandex-money-python",
            "message": "test payment message from yandex-money-python",
            "label": "testPayment",
            "test_payment": True,
            "test_result": "success"
        }
        return api.request(options), api
    def makeRequest(self):
        instance_id = ExternalPayment.get_instance_id(CLIENT_ID)['instance_id']

        api = ExternalPayment(instance_id)
        options = {
            "instance_id": instance_id,
            "pattern_id": "p2p",
            "to": "410011161616877",
            "amount_due": "0.02",
            "comment": "test payment comment from yandex-money-python",
            "message": "test payment message from yandex-money-python",
            "label": "testPayment",
            "test_payment": True,
            "test_result": "success"
        }
        return api.request(options), api
 def testGetInstanceId(self):
     response = ExternalPayment.get_instance_id(CLIENT_ID)
     self.assertEqual(response['status'], "success")
 def testGetInstanceId(self):
     response = ExternalPayment.get_instance_id(CLIENT_ID)
     self.assertEqual(response['status'], "success")
示例#6
0
sHandler.setFormatter(logging.Formatter(FORMAT))

from app.configuration import ProductionConfig, DevelopmentConfig, Config

#!PRODUCTION CONFIGURATION
if os.environ.get('PRODUCTION'):
    app.config.from_object(ProductionConfig())
    sHandler.setLevel(logging.INFO)
    root.addHandler(sHandler)

#! DEBUG CONFIGURATION
else:
    app.config.from_object(DevelopmentConfig())
    sHandler.setLevel(logging.DEBUG)
    root.addHandler(sHandler)

INSTANCE_ID = None
response = ExternalPayment.get_instance_id(app.config['CLIENT_ID'])
if response['status'] == "success":
    INSTANCE_ID = response['instance_id']
else:
    raise Exception('Failed to get instance_id. Reason: {0}'.format(response['error']))    

db = SQLAlchemy(app)
db_session = db.session

from app.models import *
migrate = Migrate(app, db)

from app.views import *
示例#7
0
from yandex_money.api import Wallet, ExternalPayment

client_id = '6D3FD82502F95CC490D4297F871AB2B934597432FE48B681025011F50C079'

response = ExternalPayment.get_instance_id(client_id)
if reponse.status == "success":
    instance_id = response.instance_id;
else:
    # throw exception with reponse->error message

# make instance
external_payment = ExternalPayment(instance_id);

payment_options = {
    # pattern_id, etc..
}
response = external_payment.request(payment_options)
if response.status == "success":
    request_id = response.request_id
else:
    # throw exception with response->message

process_options = {
    "request_id": request_id
    # other params..
}
result = external_payment.process(process_options)
# process result according to docs