Exemplo n.º 1
0
def create_second_card(request):
    options = {
        'api_key': settings.IYZIPAY_API_KEY,
        'secret_key': settings.IYZIPAY_API_SECRET,
        'base_url': settings.IYZIPAY_API_BASE_URL
    }

    data = {
        'locale': 'tr',
        'conversationId': "1995",
        'cardUserKey': "PQ9p7RGMi5sfYYa/49XT+lmZWJo=",
        'card': {
            'cardAlias': 'card alias',
            'cardHolderName': 'John Doe',
            'cardNumber': '5528790000000008',
            'expireMonth': '12',
            'expireYear': '2030'
        }
    }

    card = iyzipay.Card()
    card_response = card.create(data, options)
    response = json.loads(card_response.read().decode('utf-8'))

    print(response)
    if response['status'] == "success":
        UserPaymentCard.objects.create(
            user_id=1,
            card_user_key=response["cardUserKey"],
            card_token=response["cardToken"]
        )

    return JsonResponse(data=response)
Exemplo n.º 2
0
def delete_payment_card(request):
    # this card will be deleted on iyzico
    payment_card = UserPaymentCard.objects.first()

    options = {
        'api_key': settings.IYZIPAY_API_KEY,
        'secret_key': settings.IYZIPAY_API_SECRET,
        'base_url': settings.IYZIPAY_API_BASE_URL
    }

    data = {
        'locale': "tr",
        'cardToken': payment_card.card_token,
        'cardUserKey': payment_card.card_user_key,
        'conversationId': "1995"
    }

    card = iyzipay.Card()
    card_response = card.delete(data, options)
    response = json.loads(card_response.read().decode('utf-8'))

    return JsonResponse(data=response)
Exemplo n.º 3
0
def create_card(request):
    options = {
        'api_key': settings.IYZIPAY_API_KEY,
        'secret_key': settings.IYZIPAY_API_SECRET,
        'base_url': settings.IYZIPAY_API_BASE_URL
    }

    card_information = {
        'cardAlias': 'card alias',
        'cardHolderName': 'John Doe',
        'cardNumber': '5528790000000008',
        'expireMonth': '12',
        'expireYear': '2030'
    }

    data = {
        'locale': 'tr',
        'conversationId': '123',
        'email': "*****@*****.**",
        'externalId': "1",
        'card': card_information
    }

    card = iyzipay.Card()
    card_response = card.create(data, options)
    response = json.loads(card_response.read().decode('utf-8'))

    print(response)
    if response['status'] == "success":
        UserPaymentCard.objects.create(
            user_id=1,
            card_user_key=response["cardUserKey"],
            card_token=response["cardToken"]
        )

    return JsonResponse(response)
Exemplo n.º 4
0
# coding=utf-8

import iyzipay

options = {
    'api_key': iyzipay.api_key,
    'secret_key': iyzipay.secret_key,
    'base_url': iyzipay.base_url
}

card_information = {
    'cardAlias': 'card alias',
    'cardHolderName': 'John Doe',
    'cardNumber': '5528790000000008',
    'expireMonth': '12',
    'expireYear': '2030'
}

request = {
    'locale': 'tr',
    'conversationId': '123456789',
    'cardUserKey': 'card user key',
    'card': card_information
}

card = iyzipay.Card().create(request, options)

print(card.read().decode('utf-8'))
Exemplo n.º 5
0
# coding=utf-8

import iyzipay

options = {
    'api_key': iyzipay.api_key,
    'secret_key': iyzipay.secret_key,
    'base_url': iyzipay.base_url
}

request = {
    'locale': 'tr',
    'conversationId': '123456789',
    'cardToken': 'card token',
    'cardUserKey': 'card user key'
}

card = iyzipay.Card().delete(request, options)

print(card.body)