我希望能够将MPESA C2B Till Number支付功能与such集成到我正在开发的Django Web应用程序中,这样平台的用户就可以获得such通知,以支付给收款机号,并且事务通过一个模型存储在数据库中。
我已经看到了一些框架,人们已经在网上开发,但大多数似乎是迎合付费,而不是直到。任何框架的帮助,可以帮助我做到这一点,将不胜感激。
我发现来自django的官方文档很大,很难使用。
发布于 2019-11-20 11:14:03
工资单号和Till号之间没有很大的差别。根据Safaricom文档,对于CustomerPayBillOnline 安全C2B API,支付账单短代码的命令ID为CustomerBuyGoodsOnline,用于购买商品和服务的命令ID为CustomerBuyGoodsOnline
这样,您就可以在Django中为STK push执行这样的操作:
def lipa_na_mpesa_online(request):
access_token = MpesaAccessToken.validated_mpesa_access_token
api_url = "https://sandbox.safaricom.co.ke/mpesa/stkpush/v1/processrequest"
headers = {"Authorization": "Bearer %s" % access_token}
request = {
"BusinessShortCode": LipanaMpesaPpassword.Business_short_code,
"Password": LipanaMpesaPpassword.decode_password,
"Timestamp": LipanaMpesaPpassword.lipa_time,
"TransactionType": "CustomerBuyGoodsOnline",
"Amount": 1,
"PartyA": 254708374149, # replace with your phone number to get stk push
"PartyB": LipanaMpesaPpassword.Business_short_code,
"PhoneNumber": 254708374149, # replace with your phone number to get stk push
"CallBackURL": "https://sandbox.safaricom.co.ke/mpesa/",
"AccountReference": "Henry",
"TransactionDesc": "Testing stk push"
}
response = requests.post(api_url, json=request, headers=headers)
return HttpResponse('success')https://stackoverflow.com/questions/58580771
复制相似问题