cornershop / python-tbk

Unofficial TBK Web Services Python SDK
MIT License
42 stars 27 forks source link

Error when redirecting from return URL #7

Closed flizana closed 5 years ago

flizana commented 5 years ago

I have successfully implemented WebpayPlus with the help of this repo. Although when I tell the server to redirect to the URL provided by Transbank (with token_ws=blabla as a query parameter) after get_transaction_result call, the following page is displayed:

screen shot 2019-02-27 at 21 24 34

BTW, I am already calling acknowledge_transaction before telling the server to redirect. The odd thing is if I click on the link it leads me to my final URL.

israelgp24 commented 5 years ago

Hi @flizana , I'am getting the same problem Did you figure it out ?

flizana commented 5 years ago

@israelgp24 Even though this page is displayed, the transaction is approved (by checking the authorization code). I think it must be a bug inside Webpay (Transbank). I'm still looking for the solution.

nanocatdemen commented 5 years ago

I had the same problem. It turns out that the form element didn't have method="post", so it was a GET request, not a POST request

nanocatdemen commented 5 years ago

Note: My "redirect" it just a form with a hidden token_ws element, submitted programmatically with js

israelgp24 commented 5 years ago

@flizana , really ? do you get a transaction approved ?, i used inittransaction and i got a token and a url , but when i made gettransactionresult using that token i got a timeout error

israelgp24 commented 5 years ago

@nanocatdemen when you say form you mean the webpay form ?

flizana commented 5 years ago

Note: My "redirect" it just a form with a hidden token_ws element, submitted programmatically with js

I know, my redirect is the same, a form with hidden token_ws input element. @nanocatdemen did you solve this problem?

nanocatdemen commented 5 years ago

Using django. The "success" view

result = webpay.get_transaction_result(request.POST['token_ws'])
redirect_url = result['urlRedirection']
webpay.acknowledge_transaction(request.POST['token_ws'])
...
return render(request, 'payments/success.html', {'redirect_url': redirect_url, 'token_ws': request.POST['token_ws']})

Renders this html template

<form method="POST" action="{{ redirect_url }}" >
  <input type="hidden" name="token_ws" value="{{ token_ws }}" />
</form>
<script>
setTimeout(function(){
    document.getElementsByTagName('form')[0].submit();
}, 3000);
</script>
pedroburon commented 5 years ago

this issues should be resolved with documentation #3