django 2未找到 checkout 前令牌服务

ioekq8ef  于 2023-03-04  发布在  Go
关注(0)|答案(1)|浏览(91)

我正在尝试用我的django应用程序实现2checkout支付网关。我在2Checkout Documentation的帮助下创建了一个简单的django应用程序
这是我的javascript代码:

`window.onload=function(){
   var successCallback = function(data) {
   var myForm = document.getElementById('myCCForm');
   myForm.token.value = data.response.token.token;
   myForm.submit();
};
var errorCallback = function(data) {
alert("ERROR CODE:"+data.errorCode);
  if (data.errorCode === 200) {
        alert('success');
        tokenRequest();
  } 
  else {
   alert(data.errorMsg);
 }
};
  var tokenRequest = function() {
   var args = {
        sellerId: "#mysellerid",
        publishableKey: "mypublishkey",
        ccNo: $("#ccNo").val(),
        cvv: $("#cvv").val(),
        expMonth: $("#expMonth").val(),
        expYear: $("#expYear").val()
    };
    TCO.requestToken(successCallback, errorCallback, args);
};

$(function() {
 $.getScript('https://www.2checkout.com/checkout/api/2co.min.js',   
   function()
   {
     try {
            TCO.loadPubKey('sandbox');

     } 
     catch(e) 
     {
      alert(e.toSource());
     }
   });
   $("#myCCForm").submit(function(e) {
           tokenRequest();
           return false;
   });
});
}`

这是我处理订单的视图函数:

def order(request):
print('i am here')
# Setup credentials and environment
twocheckout.Api.auth_credentials({
    'private_key': 'privatekey',
    'seller_id': '#sellerid',
    'mode': 'sandbox'
})

# Setup arguments for authorization request
args = {
    'merchantOrderId': '123',
    'token': request.POST.get("token"),
    'currency': 'INR',
    'total': '1.00',
    'billingAddr': {
        'name': 'TEJKANWAR',
        'addrLine1': 'myaddressline1',
        'city': 'mycity',
        'state': 'mystate',
        'zipCode': 'pin',
        'country': 'IN',
        'email': 'testingadress12356@gmail.com',
        'phoneNumber': '+9199999999'
    }
}

# Make authorization request
try:
    result = twocheckout.Charge.authorize(args)
    return HttpResponse(result.responseMsg)
except TwocheckoutError as error:
    return HttpResponse(error.msg)

这里是www.example.comurls.py:

from django.conf.urls import patterns, url
    from twochek import views

urlpatterns = patterns('',
                       url(r'^$', views.index, name='index'),
                       url(r'^order/$', views.order, name='order'),

                       )

我制作了此表格以获取付款信息:

<form id="myCCForm" action="order/" method="post">
     {% csrf_token %}
    <div class="form-group">
    <input id="token" name="token"  class="form-control" value="">
    </div>
    <div class="form-group">
        <input  class="form-control" id="ccNo" type="text" size="20" value="" autocomplete="off" placeholder="Card number" required />
    </div>
    <div class="form-group form-inline">
        <input  class="form-control" type="text" size="25" id="expMonth" placeholder="Expiration Month(MM)" required />

        <input class="form-control" type="text" size="25" id="expYear" required placeholder="Expiration year(YYYY)"/>
    </div>
    <div class="form-group">
        <input class="form-control" id="cvv" size="4" type="text" value="" autocomplete="off" placeholder="CVC" required />
    </div>
    <input type="submit" value="Submit Payment" class="btn btn-success btn-md">
</form>

我已经包括jquery和2co.min.js正确,并测试他们在其他条件下工作.但只要我点击o提交付款,我在调试器中得到错误,我得到这个错误:www.example.com说[HTTP/1.1 404找不到]https://sandbox.2checkout.com/checkout/api/1/#10312645666554/rs/preTokenService? Saying [HTTP/1.1 404 Not found]

xu3bshqb

xu3bshqb1#

URL中不应包含“#”。商家ID不以#开始,这就是未找到路由的原因。
https://sandbox.2checkout.com/checkout/api/1/#10312645666554/rs/preTokenService
注:2checkout现在已经停止使用它的沙盒。

相关问题