def __init__(self): self.client_id = os.environ.get('PAYPAL_CLIENT_ID') self.client_secret = os.environ.get('PAYPAL_SECRET_KEY') self.environment = SandboxEnvironment(client_id=self.client_id, client_secret=self.client_secret) self.client = PayPalHttpClient(self.environment)
def __init__(self): self.client_id = settings.PAYPAL_CLIENT_ID self.client_secret = settings.PAYPAL_SECRET # TODO: do something with _production_ environment self.environment = SandboxEnvironment(client_id=self.client_id, client_secret=self.client_secret) self.client = PayPalHttpClient(self.environment)
def ready(self): try: from payment.models.main import PaymentProvider from payment.models.main import PaymentMethod prepayment, created = PaymentProvider.objects.get_or_create( api="Prepayment") bill, created = PaymentProvider.objects.get_or_create(api="Bill") paypal, created = PaymentProvider.objects.get_or_create( api="PayPal") pp_method, created = PaymentMethod.objects.get_or_create( name="Prepayment", provider=prepayment) bill_method, created = PaymentMethod.objects.get_or_create( name="Bill", provider=bill) paypal_method, created = PaymentMethod.objects.get_or_create( name="PayPal", provider=paypal) provider = PaymentProvider.objects.filter(api__contains="PayPal") if provider.count() > 0: if provider[0].use_sandbox: self.paypal_environment = SandboxEnvironment( client_id=provider[0].user_name, client_secret=provider[0].secret) else: self.paypal_environment = LiveEnvironment( client_id=provider[0].user_name, client_secret=provider[0].secret) self.paypal_client = PayPalHttpClient(self.paypal_environment) except: print("DB not migrated")
def setUp(self): client_id = os.environ[ "PAYPAL_CLIENT_ID"] if 'PAYPAL_CLIENT_ID' in os.environ else "<<PAYPAL-CLIENT-ID>>" client_secret = os.environ[ "PAYPAL_CLIENT_SECRET"] if 'PAYPAL_CLIENT_SECRET' in os.environ else "<<PAYPAL-CLIENT-SECRET>>" self.environment = SandboxEnvironment(client_id=client_id, client_secret=client_secret) self.client = PayPalHttpClient(self.environment)
def __init__(self): self.client_id = os.environ['PAYPAL_ID'] self.client_secret = os.environ['PAYPAL_SECRET'] """In production, use LiveEnvironment.""" self.environment = SandboxEnvironment(client_id = self.client_id, client_secret = self.client_secret) self.client = PayPalHttpClient(self.environment)
def __init__(self): self.client_id = "AQOM5xwx-dY-L3u_bFJF8lQMIJLJBa-uFwsoC1rsPjex_lqKiVzQkNdafP13X5bw_97h2u4FCRdnWKVq" self.client_secret = "ENLewOXqOI3FMi2YJXgT4XqWosGeF5V-7GaaMaHhij61Et5NgqCLeBzHEhCvkE-gjtcpNqvw3uyrJhHn" self.environment = SandboxEnvironment(client_id=self.client_id, client_secret=self.client_secret) self.client = PayPalHttpClient(self.environment)
def configuration(): client_id = settings.PAYPAL_CLIENT_ID client_secret = settings.PAYPAL_CLIENT_SECRET environment = SandboxEnvironment(client_id=client_id, client_secret=client_secret) client = PayPalHttpClient(environment) return client
def getClient(request): paypal_client_id = settings.PAYPAL_CLIENT_ID paypal_secret_id = settings.PAYPAL_SECRET_ID env = SandboxEnvironment(client_id=paypal_client_id, client_secret=paypal_secret_id) client = PayPalHttpClient(env) return client
def __init__(self) -> None: """Инициализирует сессию работы с системой PayPal.""" # Creating an environment environment = SandboxEnvironment(client_id=PAYPAL_CLIENT_ID, client_secret=PAYPAL_CLIENT_SECRET) self.client = PayPalHttpClient(environment) self.process_notification = { # todo should this be here? PayPalStrings.WEBHOOK_APPROVED.value: self.capture, PayPalStrings.WEBHOOK_COMPLETED.value: self.fulfill, }
def __init__(self): if PayPalSettings.USE_SANDBOX: self.environment = SandboxEnvironment( client_id=PayPalSettings.CLIENT_ID, client_secret=PayPalSettings.CLIENT_SECRET) else: self.environment = LiveEnvironment( client_id=PayPalSettings.CLIENT_ID, client_secret=PayPalSettings.CLIENT_SECRET) self.client = PayPalHttpClient(self.environment)
def __init__(self): sandbox = True if sandbox: self.client_id = '' self.client_secret = '' self.environment = SandboxEnvironment(client_id=self.client_id, client_secret=self.client_secret) else: self.client_id = '' self.client_secret = '' self.environment = LiveEnvironment(client_id=self.client_id, client_secret=self.client_secret) self.client = PayPalHttpClient(self.environment)
def __init__(self): self.client_id = "AT9MrrKnz-Ap6nKtesw7UWKFk5DgBNrytIa0Ea2_cjBAaKgU2g3_a-vUNZ-KArTt4CWf6fVsj8D2HBpP" self.client_secret = "EJnzejjJuoXfbGxLt-76nuDs55pmbLUXucQGqMArDn9zcl2NJI3M7cdja4NTFf6yJbQzvavvKLQnUsoc" """Set up and return PayPal Python SDK environment with PayPal access credentials. This sample uses SandboxEnvironment. In production, use LiveEnvironment.""" self.environment = SandboxEnvironment(client_id=self.client_id, client_secret=self.client_secret) """ Returns PayPal HTTP client instance with environment that has access credentials context. Use this instance to invoke PayPal APIs, provided the credentials have access. """ self.client = PayPalHttpClient(self.environment)
def __init__(self): self.client_id = "Ac5WPsCMuD4X3uu--d5hJ8c13mLF9b-JshG2sapdD4gqhUyMvZ_9_OXZ3XbIbnsDVCZr6FZ89LUi08Dn" self.client_secret = "EL06rcocvyIbGteIIpz1HkXRk2lsuxy8ZQsCmeVpWNobYEbQ-ZbIZDVx0JDzW0mL1CdgTzcEa2PkFT5z" """Set up and return PayPal Python SDK environment with PayPal access credentials. This sample uses SandboxEnvironment. In production, use LiveEnvironment.""" self.environment = SandboxEnvironment(client_id=self.client_id, client_secret=self.client_secret) """ Returns PayPal HTTP client instance with environment that has access credentials context. Use this instance to invoke PayPal APIs, provided the credentials have access. """ self.client = PayPalHttpClient(self.environment)
def __init__(self): self.client_id = "AZSM8h2MflxGM0iBCmrJMyTJFtlIn4WIwZS-J6OgU6VLX0S4lgNp8xhVv1RTwL5xfzjw6jRqHdT7iOrr" self.client_secret = "EMiJ2RjZa3iXHrTTiQhT2_RdzCQK-_IEzQV9S17EmuvEbOdJkMsbdzZuz4vR2aSsQYcvGchIxO4v2z4Z" """Set up and return PayPal Python SDK environment with PayPal access credentials. This sample uses SandboxEnvironment. In production, use LiveEnvironment.""" self.environment = SandboxEnvironment(client_id=self.client_id, client_secret=self.client_secret) """ Returns PayPal HTTP client instance with environment that has access credentials context. Use this instance to invoke PayPal APIs, provided the credentials have access. """ self.client = PayPalHttpClient(self.environment)
def __init__(self): self.client_id = "ASFQSWdaUNf4UQR99fImi867BckGMxRMfqgQEYbMM9z-OAt8368XH757eoYvn0A-CiZjK3dfWY78u4Wj" self.client_secret = "EM_b9-A1qphs-W38e0sPNtvRDYuad12nKk5yzA-gw1PFdWDalZWfTbR6jGhIGJdEYgZ6HETeikoDlT2C" """Set up and return PayPal Python SDK environment with PayPal access credentials. This sample uses SandboxEnvironment. In production, use LiveEnvironment.""" self.environment = SandboxEnvironment(client_id=self.client_id, client_secret=self.client_secret) """ Returns PayPal HTTP client instance with environment that has access credentials context. Use this instance to invoke PayPal APIs, provided the credentials have access. """ self.client = PayPalHttpClient(self.environment)
def __init__(self, data: dict): super(PayGateWay, self).__init__(data) _env_config = { 'client_id': self.config['client_id'], 'client_secret': self.config['client_secret'] } if self.config['sandbox']: environment = SandboxEnvironment(**_env_config) else: environment = LiveEnvironment(**_env_config) self.paypal = PayPalHttpClient(environment)
def __init__(self): self.client_id = settings.PAYPAL_CLIENT_ID self.client_secret = settings.PAYPAL_CLIENT_SECRET """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) """ Returns PayPal HTTP client instance with environment which has access credentials context. This can be used invoke PayPal API's provided the credentials have the access to do so. """ self.client = PayPalHttpClient(self.environment)
def __init__(self): self.client_id = "AREn1ZxGsFz36Q5jDcZo0Eia2VOEzvAyLDcrwvxiQAyH_yhiXRGgtLgNxUTG2bljtBlAZzIAFtnsghqz" self.client_secret = "EKDG736JjGPnoey51QlRBVc3oZJVuYyXDcKBANtR_5ULi00zOGMVeY0ptQQUp-vVbgoW38QJfp4BQxss" """Set up and return PayPal Python SDK environment with PayPal access credentials. This sample uses SandboxEnvironment. In production, use LiveEnvironment.""" self.environment = SandboxEnvironment(client_id=self.client_id, client_secret=self.client_secret) """ Returns PayPal HTTP client instance with environment that has access credentials context. Use this instance to invoke PayPal APIs, provided the credentials have access. """ self.client = PayPalHttpClient(self.environment)
def __init__(self): credentials = { 'client_id': settings.PAYPAL_CLIENT_ID, 'client_secret': settings.PAYPAL_CLIENT_SECRET, } if getattr(settings, 'PAYPAL_SANDBOX_MODE', True): environment = SandboxEnvironment(**credentials) else: environment = LiveEnvironment(**credentials) self.client = PayPalHttpClient(environment)
def __init__(self): self.client_id = os.getenv("PAYPAL_SANDBOX_CLIENT_ID") self.client_secret = os.getenv("PAYPAL_SANDBOX_CLIENT_SECRET") """Set up and return PayPal Python SDK environment with PayPal access credentials. This sample uses SandboxEnvironment. In production, use ProductionEnvironment.""" self.environment = SandboxEnvironment(client_id=self.client_id, client_secret=self.client_secret) """ Returns PayPal HTTP client instance with environment that has access credentials context. Use this instance to invoke PayPal APIs, provided the credentials have access. """ self.client = PayPalHttpClient(self.environment)
def __init__(self): self.client_id = PAYPAL_CLIENT_ID self.client_secret = PAYPAL_CLIENT_SECRET # choose live or sandbox Environment if PAYPAL_ENVIRONMENT == 'live': self.environment = LiveEnvironment( client_id=self.client_id, client_secret=self.client_secret) else: self.environment = SandboxEnvironment( client_id=self.client_id, client_secret=self.client_secret) self.client = PayPalHttpClient(self.environment)
def __init__(self): self.client_id = "AUSp21wTdzaQnRU0d5qmvYKbtNQiWV3c2E6_Ht39NQDN1mY3VgJ4WD_ZexD-48a39lKwjBHhQGvaQ-gz" self.client_secret = "EPtPGQXhdcUdUT1Z5sQtr2pQ1HsWggisaU9POVBIqF3LLb8poQxEveQcYcv3_kOieupHVy5jtO8GFezO" """Set up and return PayPal Python SDK environment with PayPal access credentials. This sample uses SandboxEnvironment. In production, use LiveEnvironment.""" self.environment = SandboxEnvironment(client_id=self.client_id, client_secret=self.client_secret) """ Returns PayPal HTTP client instance with environment that has access credentials context. Use this instance to invoke PayPal APIs, provided the credentials have access. """ self.client = PayPalHttpClient(self.environment)
def __init__(self): # self.client_id = "AQCX7hsi7c9wiHFuHzb8c-CWn7P6Y1tW0znMXpisx7Khlmh3FR81lbwqqQqk31WQqkvoRucgEPTyo0wZ" # self.client_secret = "EGX5KF7bx_awycoq0CI6KoupvUCPcyX1U8ZjCtMaoWQsDygcV_EKBzw60tfCCsAhI8ZwrwkHcPSZ-JJa" """Set up and return PayPal Python SDK environment with PayPal access credentials. This sample uses SandboxEnvironment. In production, use ProductionEnvironment.""" self.environment = SandboxEnvironment(client_id=self.client_id, client_secret=self.client_secret) """ Returns PayPal HTTP client instance with environment that has access credentials context. Use this instance to invoke PayPal APIs, provided the credentials have access. """ self.client = PayPalHttpClient(self.environment)
def __init__(self): self.client_id = settings.PAYPAL_API_KEY[0] self.client_secret = settings.PAYPAL_SECRET[0] """Set up and return PayPal Python SDK environment with PayPal access credentials. This sample uses SandboxEnvironment. In production, use LiveEnvironment.""" self.environment = SandboxEnvironment(client_id=self.client_id, client_secret=self.client_secret) """ Returns PayPal HTTP client instance with environment that has access credentials context. Use this instance to invoke PayPal APIs, provided the credentials have access. """ self.client = PayPalHttpClient(self.environment)
def pago(request): # Creating Access Token for Sandbox client_id = "AWKxRtjpmHR9Jd8n8fMGO77lqcIw7fFHML19xSzd1Scfv4Mk-XGwnjBYJIkaRaFa_y2LC2PXBulTMPFK" client_secret = "EGlVhQYGDzop2HftvmEqh726ChUjz4e7x_Ai4Hp900iA8troRX5feiS6ThlfB-HSVwzKNdHW2W3BzCyf" # Creating an environment environment = SandboxEnvironment(client_id=client_id, client_secret=client_secret) client = PayPalHttpClient(environment) # Construct a request object and set desired parameters # Here, OrdersCreateRequest() creates a POST request to /v2/checkout/orders requestPaypal = OrdersCreateRequest() sesion_id = request.session.session_key registro = Ventas_por_enviar.objects.filter(sesion=sesion_id) posicion = (len(registro)) total = registro[posicion - 1].total total_stripe = float(total) total_stripe = total_stripe * 100 requestPaypal.prefer('return=representation') requestPaypal.request_body({ "intent": "CAPTURE", "purchase_units": [{ "amount": { "currency_code": 'MXN', "value": float(total), } }], "application_context": { "return_url": "http://127.0.0.1:8000/checkout/exitoso", "cancel_url": "http://127.0.0.1:8000/checkout/cancelado", "brand_name": "Joyapan" } }) try: # Call API with your client and get a response for your call response = client.execute(requestPaypal) if response.result.status == 'CREATED': approval_url = str(response.result.links[1].href) print(approval_url) return render(request, 'checkout/pago.html',{#aqui es donde esta el boton 'approval_url':approval_url,'STRIPE_PUBLISHABLE_KEY':settings.STRIPE_PUBLISHABLE_KEY,'total':total,'total_stripe':total_stripe, }) except IOError as ioe: print(ioe) if isinstance(ioe, HttpError): # Something went wrong server-side return render(request, 'checkout/pago_cancelado.html')
def __init__(self): self.client_id = os.environ[ "PAYPAL_CLIENT_ID"] if 'PAYPAL_CLIENT_ID' in os.environ else "AZS0RdSzskmPsFObSmq1c_C7pLKTuDVZ8jvpczyudM-v57oiDvfcQ3RIfRcsoPpCNLkYW7Ok35cMqgM7" self.client_secret = os.environ[ "PAYPAL_CLIENT_SECRET"] if 'PAYPAL_CLIENT_SECRET' in os.environ else "EDarMyDvAxfecqAt7ufknBhiIio8nwsIigERY5lFLkGKQfP5aK1K825wpX4i61k8CAka_iUFBjM-a14j" """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) """ Returns PayPal HTTP client instance with environment which has access credentials context. This can be used invoke PayPal API's provided the credentials have the access to do so. """ self.client = PayPalHttpClient(self.environment)
def pago_exitoso(request): # Creating Access Token for Sandbox client_id = "AWKxRtjpmHR9Jd8n8fMGO77lqcIw7fFHML19xSzd1Scfv4Mk-XGwnjBYJIkaRaFa_y2LC2PXBulTMPFK" client_secret = "EGlVhQYGDzop2HftvmEqh726ChUjz4e7x_Ai4Hp900iA8troRX5feiS6ThlfB-HSVwzKNdHW2W3BzCyf" # Creating an environment environment = SandboxEnvironment(client_id=client_id, client_secret=client_secret) client = PayPalHttpClient(environment) ordenId = request.GET.get('token') payerId = request.GET.get('PayerID') requestPaypal = OrdersCaptureRequest(ordenId) print("RequestPaypal") print(requestPaypal) requestPaypal.prefer('return=representation') try: # Call API with your client and get a response for your call response = client.execute(requestPaypal) # If call returns body in response, you can get the deserialized version from the result attribute of the response print("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") order = response.result.id sesion_id = request.session.session_key registro = Ventas_por_enviar.objects.filter(sesion=sesion_id) posicion = (len(registro)) registro[posicion - 1].autorizacion = order registro[posicion - 1].verificacion = payerId diccionario = { 'nombre': registro[posicion - 1].nombre, 'email': registro[posicion - 1].email, } registro[posicion - 1].save() envio_email_confirmacion(diccionario) except IOError as ioe: if isinstance(ioe, HttpError): # Something went wrong server-side print("Algo salio mal :c") print(ioe.status_code) print(ioe.headers) print(ioe) return render(request, 'checkout/pago_cancelado.html') else: # Something went wrong client side print(ioe) return render(request, 'checkout/pago_cancelado.html') return render(request, 'checkout/pago_exitoso.html')
def __init__(self): if settings.PAYPAL_USE_SANDBOX: environment = SandboxEnvironment( client_id=settings.PAYPAL_SANDBOX_CLIENT_ID, client_secret=settings.PAYPAL_SANDBOX_SECRET_KEY, ) else: environment = LiveEnvironment( client_id=settings.PAYPAL_LIVE_CLIENT_ID, client_secret=settings.PAYPAL_LIVE_SECRET_KEY, ) # Returns PayPal HTTP client instance with environment that # has access credentials context. Use this instance to invoke # PayPal APIs, provided the credentials have access. self.client = PayPalHttpClient(environment)
def __init__(self, clientID, secretID, test=True): self.client_id = clientID self.client_secret = secretID """Set up and return PayPal Python SDK environment with PayPal access credentials. This sample uses SandboxEnvironment. In production, use ProductionEnvironment.""" if test: 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 that has access credentials context. Use this instance to invoke PayPal APIs, provided the credentials have access. """ self.client = PayPalHttpClient(self.environment)
def __init__(self): try: self.client_id = os.environ['CLIENT_ID'] self.client_secret = os.environ['CLIENT_SECRET'] self.environment = LiveEnvironment( client_id=self.client_id, client_secret=self.client_secret) except KeyError: self.client_id = config.get('main', 'CLIENT_ID') self.client_secret = config.get('main', 'CLIENT_SECRET') self.environment = SandboxEnvironment( client_id=self.client_id, client_secret=self.client_secret) """Set up and return PayPal Python SDK environment with PayPal access credentials. This sample uses SandboxEnvironment. In production, use LiveEnvironment.""" """ Returns PayPal HTTP client instance with environment that has access credentials context. Use this instance to invoke PayPal APIs, provided the credentials have access. """ self.client = PayPalHttpClient(self.environment)