mrdishant / Paytm-Flutter-Plugin

A Flutter plugin to use the Paytm as a gateway for accepting online paymnets in Flutter app.
Other
10 stars 6 forks source link

CheckSumHash Generated But Plugin says its invalid #13

Closed rdcoder33 closed 4 years ago

rdcoder33 commented 4 years ago

This is the url which generated the checksum: https://pubgavatar.000webhostapp.com/generateChecksum.php

Important Info from debug Console:

print('Response:' + response.body) gives:
Response :{"CHECKSUMHASH":"hFU35mVFXeHMdSnN0+epKW3bdRyiFbuTHML50YHbrh9mgZ1s6pcorIfAEzx0Xf3IcjKZ+Yo2GDhjqwb3K8T0smzOwuHuJ3ZS2DV+ijdZrOw=","ORDER_ID":"1569471278695","payt_STATUS":"1"}  

I used json.decode to get CheckSumHash which ended up like this:

hFU35mVFXeHMdSnN0+epKW3bdRyiFbuTHML50YHbrh9mgZ1s6pcorIfAEzx0Xf3IcjKZ+Yo2GDhjqwb3K8T0smzOwuHuJ3ZS2DV+ijdZrOw=

But, Still in paytmResponse I get: Bundle[{STATUS=TXN_FAILURE, ORDERID=1569471278695, TXNAMOUNT=10.00, MID=ParloS79006455919746, RESPCODE=330, BANKTXNID=, CURRENCY=INR, RESPMSG=Invalid checksum}]

my Main.dart where payment happens:

import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:paytm/paytm.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String paymentResponse = '';

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Paytm example app'),
        ),
        body: Padding(
          padding: EdgeInsets.all(10.0),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.stretch,
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Text('Running on: $paymentResponse\n'),
              RaisedButton(
                onPressed: () {
                  //Firstly Generate CheckSum bcoz Paytm Require this
                  generateCheckSum();
                },
                color: Colors.blue,
                child: Text(
                  "Pay Now",
                  style: TextStyle(color: Colors.white),
                ),
              )
            ],
          ),
        ),
      ),
    );
  }

  void generateCheckSum() async {
    var url = 'https://pubgavatar.000webhostapp.com/generateChecksum.php';
    // var url = 'https://us-central1-mrdishant-4819c.cloudfunctions.net/generateCheckSum';

    String orderId = DateTime.now().millisecondsSinceEpoch.toString();

    //Please use your parameters here
    //CHANNEL_ID etc provided to you by paytm

    final response = await http.post(url, headers: {
      "Content-Type": "application/x-www-form-urlencoded"
    }, body: {
      "mid": "ParloS79006455919746",
      "CHANNEL_ID": "WAP",
      'INDUSTRY_TYPE_ID': 'Retail',
      'WEBSITE': 'APPSTAGING',
      'PAYTM_MERCHANT_KEY': '380W#7mf&_SpEgsy',
      'TXN_AMOUNT': '10',
      'ORDER_ID': orderId,
      'CUST_ID': '122',
    });

    //for Testing(Stagging) use this

    //https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=

    //https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=

    String callBackUrl =
        'https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=' +
            orderId;

    print("Response :" + response.body);
    var newVar = json.decode(response.body);
    String checkSum = newVar['CHECKSUMHASH'];
    print(checkSum);

    //Parameters are like as per given below

    // Testing (Staging or Production) if true then Stagging else Production
    // MID provided by paytm
    // ORDERID your system generated order id
    // CUSTOMER ID
    // CHANNEL_ID provided by paytm
    // AMOUNT
    // WEBSITE provided by paytm
    // CallbackURL (As used above)
    // INDUSTRY_TYPE_ID provided by paytm
    // checksum generated now

    //Testing Credentials
    //Mobile number: 7777777777
    //OTP: 489871

    var paytmResponse = Paytm.startPaytmPayment(
        true,
        "ParloS79006455919746",
        orderId,
        "122",
        "WAP",
        "10",
        'APPSTAGING',
        callBackUrl,
        'Retail',
        checkSum);

    paytmResponse.then((value) {
      setState(() {
        paymentResponse = value.toString();
      });
      print(value);
    });
  }
}
mrdishant commented 4 years ago

Something must be wrong in your checksum generation code.

Kindy recheck!

yogiy commented 4 years ago

Please reopen this issue as I am also facing this issue.

prasanth2020 commented 4 years ago

I am also facing this issue.., Please help.