Set proper Paypal environment for production

This commit is contained in:
Nathan Chapman 2022-04-30 15:31:17 -06:00
parent 03a2a8a417
commit 7e5985fdc7

View File

@ -3,7 +3,7 @@ import sys
import json
import logging
from paypalcheckoutsdk.core import PayPalHttpClient, SandboxEnvironment
from paypalcheckoutsdk.core import PayPalHttpClient, SandboxEnvironment, LiveEnvironment
from paypalcheckoutsdk.orders import OrdersCreateRequest, OrdersCaptureRequest
from paypalhttp.serializers.json_serializer import Json
@ -23,7 +23,10 @@ class PayPalClient:
"""Setting up and Returns PayPal SDK environment with PayPal Access credentials.
For demo purpose, we are using SandboxEnvironment. In production this will be
LiveEnvironment."""
self.environment = SandboxEnvironment(client_id=self.client_id, client_secret=self.client_secret)
if settings.DEBUG:
self.environment = SandboxEnvironment(client_id=self.client_id, client_secret=self.client_secret)
else:
self.environment = LiveEnvironment(client_id=self.client_id, client_secret=self.client_secret)
""" Returns PayPal HTTP client instance with environment which has access
credentials context. This can be used invoke PayPal API's provided the