当前位置: 首页>>代码示例>>Python>>正文


Python wepay.WePay类代码示例

本文整理汇总了Python中wepay.WePay的典型用法代码示例。如果您正苦于以下问题:Python WePay类的具体用法?Python WePay怎么用?Python WePay使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了WePay类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

	def post(self, request, *args, **kwargs):
		access_token = 'STAGE_25361b68e606cc342a7e4ec982fac2139f9f72dd42156237da9468c832f56dce'
		production = False
		client_id = 167754
		client_secret = "da07303f7e"
		email = self.request.user.email
		first_name = self.request.user.name
		last_name = "WeParty"
		wepay = WePay(production, access_token)
		response = wepay.call('/user/register', {
			"client_id":client_id,
			"client_secret":client_secret,
			"email":email,
			"scope":"manage_accounts,view_balance,collect_payments,view_user",
			"first_name":first_name,
			"last_name":last_name,
			"original_ip":"74.125.224.84",
			"original_device":"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; en-US) AppleWebKit/534.13 (KHTML, like Gecko) Chrome/9.0.597.102 Safari/534.13"
		})
		print type(response)
		print response
		user_access_token = response[u'access_token']
		wepay2 = WePay(production, user_access_token)
		response2 = wepay.call('/account/create', {
			"name": first_name + " WeParty",
			"description": "WeParty account"
		})
		print response2
		user = User.objects.get(id=request.user.id)
		user.wepayUserId = response[u'user_id']
		user.wepayAccountId = response2[u'account_id']
		user.wepayAccessToken = response[u'access_token']
		user.save()
		return HttpResponseRedirect('/dashboard/')
开发者ID:spelman7,项目名称:weparty,代码行数:34,代码来源:views.py

示例2: create_checkout

    def create_checkout(self, redirect_uri):
        """
        Performs WePay checkout/create API call request.
        Returns checkout_uri to create checkout form.
        """
        production = settings.WEPAY['in_production']
        access_token = self.wepay_access_token

        wepay = WePay(production, access_token)

        name = self.user.first_name + " " + self.user.last_name
        desc = "Purchasing " + self.produce + " from " + name
        price = str(self.produce_price)
        account_id = str(self.get_account_id())
        app_fee = str(Decimal('0.1') * self.produce_price)

        params = {
            'account_id': account_id,
            'short_description': desc,
            'type': 'GOODS',
            'app_fee': app_fee,
            'amount': price,
            'mode': 'iframe'
        }

        try:
            create_response = wepay.call('/checkout/create', params)
            checkout_uri = create_response['checkout_uri']

            return True, checkout_uri

        except WePayError as e:
            return False, e
开发者ID:naissa12,项目名称:wefarmdjango,代码行数:33,代码来源:models.py

示例3: profile

def profile(request, pk):
    user = get_object_or_404(User, pk=pk)
    farmer = get_object_or_404(Farmer, user=user)

    production = settings.WEPAY['in_production']
    wepay = WePay(production)

    redirect_uri = settings.WEPAY['authorize_url']

    auth_url = None
    show_edit = False
    if farmer.user.pk == request.user.pk:
        show_edit = True

        if not farmer.has_access_token:
            auth_url = wepay.get_authorization_url(
                redirect_uri, settings.WEPAY['client_id'])

    context = {
        'farmer': farmer,
        'auth_url': auth_url,
        'show_edit': show_edit
    }

    return render(request, 'profile.html', context)
开发者ID:naissa12,项目名称:wefarmdjango,代码行数:25,代码来源:views.py

示例4: wepay_membership_response

def wepay_membership_response(user):
  """
  Make a WePay API call for membership payment and return the response.
  """
  # Generate verification_key for wepay payment.
  random_string = base64.urlsafe_b64encode(os.urandom(30))
  verification_key = hashlib.sha224(random_string + user.email +
                                    user.name).hexdigest()

  user.wepay_verification = verification_key
  db.session.commit()

  # WePay Application settings
  account_id = app.config['WEPAY_ACCT_ID']
  access_token = app.config['WEPAY_ACC_TOK']
  production = app.config['WEPAY_IN_PROD']

  wepay = WePay(production, access_token)
  redirect_url = app.config['HOST_URL'] + '/verify/' + verification_key

  response = wepay.call('/checkout/create', {
      'account_id': account_id,
      'amount': '20.00',
      'short_description': '1 year ACM Club Membership',
      'mode': 'regular',
      'type': 'SERVICE',
      'redirect_uri': redirect_url
  })

  return response
开发者ID:animekraxe,项目名称:acm-phoenix,代码行数:30,代码来源:views.py

示例5: wepay_membership_response

def wepay_membership_response(user):
  """
  Make a WePay API call for membership payment and return the response.
  """
  random_string = base64.urlsafe_b64encode(os.urandom(30))
  verification_key = hashlib.sha224(random_string + user.email +
                                    user.name).hexdigest()

  user.wepay_verification = verification_key
  db.session.commit()

  # Application settings
  account_id = 319493
  access_token = '6dd6802f8ebef4992308a0e4f7698c275781ac36854f9451127115d995d8cda7'
  production = False

  wepay = WePay(production, access_token)
  redirect_url = 'http://acm.frvl.us:5000/verify/' + verification_key

  response = wepay.call('/checkout/create', {
      'account_id': account_id,
      'amount': '20.00',
      'short_description': '1 year ACM Club Membership',
      'mode': 'regular',
      'type': 'SERVICE',
      'redirect_uri': redirect_url
  })

  return response
开发者ID:Fernie-Hacks,项目名称:acm-phoenix,代码行数:29,代码来源:views.py

示例6: test_default_timeout_is_passed_to_requests

def test_default_timeout_is_passed_to_requests():
    api = WePay()
    api.requests = Mock()
    api.call('/some_uri')
    eq_([call('https://wepayapi.com/v2/some_uri',
              headers={'Content-Type': 'application/json',
                       'User-Agent': 'WePay Python SDK'},
              data=None, timeout=30)],
        api.requests.post.call_args_list)
开发者ID:StitchSizzler,项目名称:Python-SDK,代码行数:9,代码来源:test_api.py

示例7: create_wepay_account

def create_wepay_account(access_token):
    # set production to True for live environments
    production = settings.WEPAY_PRODUCTION
    # Use access token to create account for a user.
    wepay = WePay(production, access_token)
    response = wepay.call('/account/create', {
    'name': 'CrowdEmpowered Project Contribution',
    'description': 'Crowdfunding Platform'
    })
    return response
开发者ID:joejean,项目名称:codo_django,代码行数:10,代码来源:payment_utils.py

示例8: create_wepay_merchant

def create_wepay_merchant(code):
    redirect_uri = settings.WEPAY_REDIRECT_URI
    client_id = settings.WEPAY_CLIENT_ID
    client_secret = settings.WEPAY_CLIENT_SECRET
    production = settings.WEPAY_PRODUCTION
    # set production to True for live environments
    wepay = WePay(production, None)
    # Get a Token to later create an account for a user
    try:
        response = wepay.get_token(redirect_uri, client_id, client_secret, code)
    except:
        response = "Error"
    
    return response
开发者ID:joejean,项目名称:codo_django,代码行数:14,代码来源:payment_utils.py

示例9: get

    def get(self, request, *args, **kwargs):
        if self.request.GET.get('checkout_id'):
            wepay = WePay(settings.WEPAY_IN_PRODUCTION, settings.WEPAY_ACCESS_TOKEN)
            wepay_data = wepay.call('/checkout/', {
                'checkout_id': self.request.GET.get('checkout_id'),
            })

            for obj in serializers.deserialize("xml", wepay_data['long_description'], ignorenonexistent=True):
                obj.object.created = datetime.datetime.now()
                obj.object.checkout_id = self.request.GET.get('checkout_id')
                obj.save()
                action.send(self.request.user, verb='placed a $' + str(obj.object.price) + ' bounty on ', target=obj.object.issue)
                post_to_slack(obj.object)

        return super(IssueDetailView, self).get(request, *args, **kwargs)
开发者ID:Lindar90,项目名称:coderbounty,代码行数:15,代码来源:views.py

示例10: get

    def get(self, request, *args, **kwargs):
        try:
            self.object = self.get_object()
        except Http404:
            messages.error(self.request, 'That issue was not found.')
            return redirect("/")
        context = self.get_context_data(object=self.object)
        return self.render_to_response(context)
        if self.request.GET.get('paymentId'):
            import paypalrestsdk
            paypalrestsdk.configure({
                'mode': settings.MODE,
                'client_id': settings.CLIENT_ID,
                'client_secret': settings.CLIENT_SECRET
            })

            payment = paypalrestsdk.Payment.find(self.request.GET.get('paymentId'))

            custom = payment.transactions[0].custom

            if payment.execute({"payer_id": self.request.GET.get('PayerID')}):
                for obj in serializers.deserialize("json", custom, ignorenonexistent=True):
                    obj.object.created = datetime.datetime.now()
                    obj.object.checkout_id = self.request.GET.get('checkout_id')
                    obj.save()
                    action.send(self.request.user, verb='placed a $' + str(obj.object.price) + ' bounty on ', target=obj.object.issue)
                    post_to_slack(obj.object)
                    if not settings.DEBUG:
                        create_comment(obj.object.issue)
            else:
                messages.error(request, payment.error)

        if self.request.GET.get('checkout_id'):
            wepay = WePay(settings.WEPAY_IN_PRODUCTION, settings.WEPAY_ACCESS_TOKEN)
            wepay_data = wepay.call('/checkout/', {
                'checkout_id': self.request.GET.get('checkout_id'),
            })

            for obj in serializers.deserialize("xml", wepay_data['long_description'], ignorenonexistent=True):
                obj.object.created = datetime.datetime.now()
                obj.object.checkout_id = self.request.GET.get('checkout_id')
                obj.save()
                action.send(self.request.user, verb='placed a $' + str(obj.object.price) + ' bounty on ', target=obj.object.issue)
                post_to_slack(obj.object)
                if not settings.DEBUG:
                    create_comment(obj.object.issue)

        return super(IssueDetailView, self).get(request, *args, **kwargs)
开发者ID:lteacher,项目名称:coderbounty,代码行数:48,代码来源:views.py

示例11: __init__

    def __init__(self):
        PaymentPlatform.__init__(self)

        self.wepay = WePay(
            production=settings.FRUCTUS_KEYS.WEPAY_PRODUCTION,
            store_token=False
        )
开发者ID:FructusCode,项目名称:website,代码行数:7,代码来源:wepay.py

示例12: periodic

def periodic():
    global wake_time, checkout_uri
    if wake_time and wake_time < time.time():
        print "Trigger capture."
        wake_time = None

        wepay = WePay(IN_PRODUCTION, ACCESS_TOKEN)
        response = wepay.call('/checkout/create', {
            'account_id': ACCOUNT_ID,
            'amount': saved_data['amount'],
            'short_description': saved_data['desc'],
            'type': 'GOODS',
            'preapproval_id': preapproval_id
        })

        checkout_uri = response['checkout_uri']
开发者ID:azala,项目名称:smallbizdev,代码行数:16,代码来源:server.py

示例13: __init__

 def __init__(self):
     merchant_settings = getattr(settings, "MERCHANT_SETTINGS")
     if not merchant_settings or not merchant_settings.get("we_pay"):
         raise GatewayNotConfigured("The '%s' gateway is not correctly "
                                    "configured." % self.display_name)
     super(WePayGateway, self).__init__()
     production = not self.test_mode
     self.we_pay = WePay(production)
     self.we_pay_settings = merchant_settings["we_pay"]
开发者ID:IbnSaeed,项目名称:merchant,代码行数:9,代码来源:we_pay_gateway.py

示例14: create_account

    def create_account(self):
        """
        Create a WePay account to deposit any money for produce.
        """
        name = self.user.first_name + ' ' + self.user.last_name
        desc = name + ' account'
        production = settings.WEPAY['in_production']
        access_token = self.wepay_access_token

        wepay = WePay(production, access_token)

        try:
            create_response = wepay.call('/account/create',
                                         {'name': name, 'description': desc})
            self.wepay_account_id = create_response['account_id']
            self.save()

            return True, create_response
        except WePayError as e:
            return False, e
开发者ID:naissa12,项目名称:wefarmdjango,代码行数:20,代码来源:models.py

示例15: wepay_checkout

def wepay_checkout(access_token, account_id, amount, campaign_title,redirect_uri=None):
    # = settings.WEPAY_DONATION_SUCCESS_REDIRECT_URI
    # set production to True for live environments
    production = settings.WEPAY_PRODUCTION
    wepay = WePay(production, access_token)
    parameters = {
    'account_id': account_id,
    'amount': amount,
    'short_description': 'Contribution to CrowdEmpowered\'s {}'.format(campaign_title),
    'type': 'donation',
    'currency': 'USD',
    'hosted_checkout':  {
        "mode": "iframe"
        },
    }
    # Wepay won't redirect to localhost so we check for that here
    # in case we are running the project on localhost
    if redirect_uri is not None and "localhost" not in redirect_uri:
        parameters['callback_uri'] = redirect_uri
    response = wepay.call('/checkout/create', parameters)
    return response
开发者ID:joejean,项目名称:codo_django,代码行数:21,代码来源:payment_utils.py


注:本文中的wepay.WePay类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。