Example #1
0
    def testBitpayNotifications(self):
        self.expectSubscribe()
        self.mockery.ReplayAll()

        temp_pledge = model.TempPledge(
            model_version=model.MODEL_VERSION,
            email=self.pledge["email"],
            phone=self.pledge["phone"],
            name=self.pledge["name"],
            firstName=u'Pik\u00E1',
            lastName=u'Chu',
            occupation=self.pledge["occupation"],
            employer=self.pledge["employer"],
            subscribe=True,
            amountCents=4200,
        )
        temp_key = temp_pledge.put()
        temp_key_str = str(temp_key)

        notification = {
            'status': 'confirmed',
            'url': 'https://bitpay.com/invoice?id=aASDF2jh4ashkASDfh234',
            'price': 42,
            'btcPrice': '1.0000',
            'currency': 'BTC',
            'posData': temp_key_str,
            'expirationTime': 1393950946292,
            'id': 'aASDF2jh4ashkASDfh234'
        }
        resp = self.app.post_json('/r/bitcoin_notifications', notification)
Example #2
0
            validictory.validate(data, PLEDGE_SCHEMA)
        except ValueError, e:
            logging.warning('Schema check failed: %s', str(e))
            self.error(400)
            self.response.write('Invalid request')
            return

        temp_pledge = model.TempPledge(model_version=model.MODEL_VERSION,
                                       email=data["email"],
                                       name=data["name"],
                                       phone=data["phone"],
                                       occupation=data["occupation"],
                                       employer=data["employer"],
                                       target=data["target"],
                                       subscribe=data["subscribe"],
                                       amountCents=data["amountCents"],
                                       firstName=data["firstName"],
                                       lastName=data["lastName"],
                                       address=data["address"],
                                       city=data["city"],
                                       state=data["state"],
                                       zipCode=data["zip"],
                                       bitcoinConfirm=data["bitcoinConfirm"],
                                       team=data["team"],
                                       source=data["source"])
        temp_key = temp_pledge.put()
        temp_key_str = str(temp_key)

        try:
            resp_dict = self._send_to_bitpay(data["amountCents"], temp_key_str)
            json.dump({"bitpay_url": resp_dict["url"]}, self.response)
            temp_pledge.bitpay_invoice_id = resp_dict["id"]