예제 #1
0
    def access_token(mode, client_id, client_secret):
        api = Api({
            'mode': mode,
            'client_id': client_id,
            'client_secret': client_secret
        })

        return api.get_access_token()
예제 #2
0
 def get_sale(sale_id, paypal_mode, paypal_client_id, paypal_client_secret):
     return Sale.find(resource_id=sale_id,
                      api=Api({
                          'mode': paypal_mode,
                          'client_id': paypal_client_id,
                          'client_secret': paypal_client_secret
                      }))
예제 #3
0
 def get_payment(payment_id, paypal_mode, paypal_client_id,
                 paypal_client_secret):
     return Payment.find(resource_id=payment_id,
                         api=Api({
                             'mode': paypal_mode,
                             'client_id': paypal_client_id,
                             'client_secret': paypal_client_secret
                         }))
예제 #4
0
 def get_order(order_id, paypal_mode, paypal_client_id,
               paypal_client_secret):
     return Order.find(resource_id=order_id,
                       api=Api({
                           'mode': paypal_mode,
                           'client_id': paypal_client_id,
                           'client_secret': paypal_client_secret
                       }))
 def _get_paypal_api(self):
     keychain = self.env["keychain.account"]
     account = keychain.sudo().retrieve([("namespace", "=", "paypal")])
     if account:
         account = account[0]
     else:
         return False
     params = account.get_data()
     params["client_secret"] = account._get_password()
     return Api(params)
예제 #6
0
 def _get_paypal_api(self):
     keychain = self.env['keychain.account']
     account = keychain.sudo().retrieve([('namespace', '=', 'paypal')])
     if account:
         account = account[0]
     else:
         return False
     params = account.get_data()
     params['client_secret'] = account._get_password()
     return Api(params)
예제 #7
0
 def get_billing_agreement(billing_agreement_id, paypal_mode,
                           paypal_client_id, paypal_client_secret):
     return BillingAgreement.find(billing_agreement_id,
                                  api=Api({
                                      'mode':
                                      paypal_mode,
                                      'client_id':
                                      paypal_client_id,
                                      'client_secret':
                                      paypal_client_secret
                                  }))
예제 #8
0
 def paypal_api_refund(self, order, refund_amount=False):
     # 搜索出发票 支付过的一般来说 应该就只有一条
     invoice = order.invoice_ids.filtered(lambda x: x.state == 'paid')
     assert len(invoice) == 1, _('The inspection found that there were at least two paid invoices or the invoices were not paid for the order. The system could not identify which invoice was refunded.')
     txn = self.env['payment.transaction'].search([('reference', 'like', invoice.number)])
     txn = txn.filtered(lambda x: x.state == 'done')
     assert len(txn) == 1, _('Invoice number: "%s" Detected that payment has been made many times or has not been paid, the system cannot determine the serial number' % invoice.number)
     x_str = 'mode' if txn.acquirer_id.environment == 'prod' else 'sandbox'
     api = Api(mode=x_str, client_id=txn.acquirer_id.paypal_api_client_id, client_secret=txn.acquirer_id.paypal_api_client_secret)
     sale = Sale.find(txn.acquirer_reference, api=api)
     sale.refund({
         "amount": {
             "total": refund_amount if refund_amount else txn.amount,
             "currency": txn.currency_id.name
         }
     })
     return txn.acquirer_reference
예제 #9
0
    def create_webhook(events, url, mode, client_id, client_secret):
        webhook = Webhook(
            {
                'url': url,
                'event_types': [{
                    'name': event
                } for event in events]
            },
            api=Api({
                'mode': mode,
                'client_id': client_id,
                'client_secret': client_secret
            }))

        if webhook.create():
            print("Webhook[%s] created successfully" % (webhook.id))
        else:
            print(webhook.error)
예제 #10
0
파일: donabot.py 프로젝트: TankOs/donabot
def create_api(config):
  return Api({
      "mode": config.mode,
      "client_id": config.client_id,
      "client_secret": config.client_secret,
  })