|
|
@ -36,10 +36,6 @@ def pricing(request, *args, **kwargs):
|
|
|
|
return render(request, 'pricing.html', context)
|
|
|
|
return render(request, 'pricing.html', context)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import requests
|
|
|
|
|
|
|
|
import base64
|
|
|
|
|
|
|
|
import uuid
|
|
|
|
|
|
|
|
from django.http import JsonResponse
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@customer_login_required
|
|
|
|
@customer_login_required
|
|
|
|
def initiate_checkout(request):
|
|
|
|
def initiate_checkout(request):
|
|
|
@ -54,6 +50,8 @@ def initiate_checkout(request):
|
|
|
|
# Data for Initiate Checkout operation
|
|
|
|
# Data for Initiate Checkout operation
|
|
|
|
data = {
|
|
|
|
data = {
|
|
|
|
"apiOperation": "INITIATE_CHECKOUT",
|
|
|
|
"apiOperation": "INITIATE_CHECKOUT",
|
|
|
|
|
|
|
|
"apiUsername": api_username,
|
|
|
|
|
|
|
|
"apiPassword": api_password,
|
|
|
|
"merchant": merchant_id,
|
|
|
|
"merchant": merchant_id,
|
|
|
|
"interaction.operation": "PURCHASE",
|
|
|
|
"interaction.operation": "PURCHASE",
|
|
|
|
"interaction.merchant.name": merchant_name,
|
|
|
|
"interaction.merchant.name": merchant_name,
|
|
|
@ -63,18 +61,9 @@ def initiate_checkout(request):
|
|
|
|
"order.description": "description_of_order"
|
|
|
|
"order.description": "description_of_order"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
# Encode the username and password in Base64 format
|
|
|
|
|
|
|
|
credentials = f"{api_username}:{api_password}"
|
|
|
|
|
|
|
|
encoded_credentials = base64.b64encode(credentials.encode()).decode()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Construct the headers with the Authorization header
|
|
|
|
|
|
|
|
headers = {
|
|
|
|
|
|
|
|
"Authorization": f"Basic {encoded_credentials}",
|
|
|
|
|
|
|
|
"Content-Type": "application/json"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
response = requests.post("https://creditlibanais-netcommerce.gateway.mastercard.com/api/nvp/version/72", json=data, headers=headers)
|
|
|
|
try:
|
|
|
|
|
|
|
|
response = requests.post("https://creditlibanais-netcommerce.gateway.mastercard.com/api/nvp/version/72", data=data)
|
|
|
|
|
|
|
|
|
|
|
|
print("Response Content:", response.content.decode()) # Print response content
|
|
|
|
print("Response Content:", response.content.decode()) # Print response content
|
|
|
|
|
|
|
|
|
|
|
|