<p>I asked this same question in a simpler way without mentioning bip 70 and got the answer <a href="https://stackoverflow.com/a/24298464/3335799" title="answer">here</a>.</p>
<p>The initial problem was that Django doesn't like people posting to your server who arent authorised so I used <code>from django.views.decorators.csrf import csrf_exempt</code> and the corresponding decorator <code>@csrf_exempt</code> as a short term work around for further debugging.</p>
<p>More detailed info can be found by following the link to the simplified question.</p>

CC BY-SA 3.0
2014-06-15T23:10:26.453Z
2014-06-27T22:46:40.233Z
2020-06-16T11:10:03.350Z
derrend
<p>I'm trying to check to see if the variables are being set correctly by the client and being received correctly by me.
I'm new to proto buffs and django and my code below doesn't seem to be working.
I'm using bitcoin 0.9
I'm trying to capture a refund address.</p>

<p>In views:</p>

<pre><code>from project import payments_pb2
def protoresponse(request):
    xpo = payments_pb2.Payment.ParseFromString(request)
    returnaddress = xpo.refund_to
    transactions = xpo.transactions
    memo = xpo.memo

    xpa = payments_pb2.PaymentACK
    xpa.payment = xpo.SerializeToString()
    xpa.memo = 'success'
    return HttpResponse(xpa.SerializeToString(), content_type="application/octet-stream")
</code></pre>

<p>Any pointers would be greatly appreciated :)</p>

CC BY-SA 3.0
2014-06-10T14:04:47.337Z
Any information *how* it doesn't work is necessary for answering the question.
Mikko Ohtamaa
CC BY-SA 3.0
2014-06-10T22:26:07.690Z
Thank you for the response :) I receive a 'forbidden access' error once I attempt to send the payment after initially opening the URI, (where to send the payment object is different to the initial URI address). Do I need to do something special to the object like `def protoresponse(request, content_type="application/octet-stream")`? Are there any obvious mistakes with the above code?
derrend
CC BY-SA 3.0
2014-06-11T07:52:18.607Z
Forbidden access is not related to the code above, but is most likely related to your web server. Please study how to setup a basic single web page through Django first, see it works and then try see that your `protoresponse` view gets called properly.
Mikko Ohtamaa
CC BY-SA 3.0
2014-06-11T07:52:45.533Z
It is unlikely the error is any way related to the code or the question above, unless shown otherwise.
Mikko Ohtamaa
CC BY-SA 3.0
2014-06-11T09:46:25.143Z
will the protobuffer object come through as a request that I must deserialize - edit - and reserialize before sending back? Please can you give me an example, I cannot find any documentation or forum posts specifically on this subject which is why I am posting here. Thanks :)
derrend
<bitcoind><bip70-payment-protocol>
How to receive and manipulate a bip 70 payment object in django python?
derrend
# How to receive and manipulate a bip 70 payment object in django python?

(Asked by: username_0 on 2014-06-10)

I'm trying to check to see if the variables are being set correctly by the client and being received correctly by me.
I'm new to proto buffs and django and my code below doesn't seem to be working.
I'm using bitcoin 0.9
I'm trying to capture a refund address.

In views:

```
from project import payments_pb2
def protoresponse(request):
    xpo = payments_pb2.Payment.ParseFromString(request)
    returnaddress = xpo.refund_to
    transactions = xpo.transactions
    memo = xpo.memo

    xpa = payments_pb2.PaymentACK
    xpa.payment = xpo.SerializeToString()
    xpa.memo = 'success'
    return HttpResponse(xpa.SerializeToString(), content_type="application/octet-stream")

```

Any pointers would be greatly appreciated :)

**Tags:** bitcoind, bip70-payment-protocol

> **Comments:**
> **username_1**: Any information *how* it doesn't work is necessary for answering the question.  
> **username_0**: Thank you for the response :) I receive a 'forbidden access' error once I attempt to send the payment after initially opening the URI, (where to send the payment object is different to the initial URI address). Do I need to do something special to the object like `def protoresponse(request, content_type="application/octet-stream")`? Are there any obvious mistakes with the above code?  
> **username_1**: Forbidden access is not related to the code above, but is most likely related to your web server. Please study how to setup a basic single web page through Django first, see it works and then try see that your `protoresponse` view gets called properly.  
> **username_1**: It is unlikely the error is any way related to the code or the question above, unless shown otherwise.  
> **username_0**: will the protobuffer object come through as a request that I must deserialize - edit - and reserialize before sending back? Please can you give me an example, I cannot find any documentation or forum posts specifically on this subject which is why I am posting here. Thanks :)  

---

## 1 answers

### Answer by username_0 on 2014-06-15. Score: 0 | Accepted answer

I asked this same question in a simpler way without mentioning bip 70 and got the answer [here](https://stackoverflow.com/a/24298464/3335799 "answer").

The initial problem was that Django doesn't like people posting to your server who arent authorised so I used `from django.views.decorators.csrf import csrf_exempt` and the corresponding decorator `@csrf_exempt` as a short term work around for further debugging.

More detailed info can be found by following the link to the simplified question.


---

