Giter Site home page Giter Site logo

Comments (4)

biplab-khalti avatar biplab-khalti commented on June 30, 2024 1

@cimplesid-tekkon thank you for your feedback. We are still working on improving our docs and shall do so through your inputs.
About conveying messages, please check all the information being passed via onMessage callback. It also sends info about whether or not the client should re-verify the payment status on their own in certain scenarios. This was done with security concerns in mind.

Thank you.

from checkout-sdk-flutter.

cimplesid-tekkon avatar cimplesid-tekkon commented on June 30, 2024

Another code sample to reproduce:

//get pidx and store in pixres
      var pidx = pixres["pidx"];
      if (pidx != null) {
        final payConfig = KhaltiPayConfig(
          publicKey: somekey,
          pidx: pidx,
          openInKhalti: false,
          returnUrl: Uri.parse('https://hamoshare.com.np'),
          environment: kDebugMode ? Environment.test : Environment.prod,
        );
        var khalti = Khalti.init(
          enableDebugging: kDebugMode,
          payConfig: payConfig,
          onPaymentResult: (paymentResult, khalti) {
            hprint("onPaymentResult", "payment");
            hprint(paymentResult.toString());
            setState(() {
              this.paymentResult = paymentResult;
            });
            khalti.close(context);
          },
          onMessage: (
            khalti, {
            description,
            statusCode,
            event,
            needsPaymentConfirmation,
          }) async {
            hprint("onMessage:", "payment");
            hprint(
                'Description: $description, Status Code: $statusCode, Event: $event, NeedsPaymentConfirmation: $needsPaymentConfirmation',
                "payment");
            khalti.close(context);
          },
          onReturn: () =>
              hprint('Successfully redirected to return_url.', "payment"),
        );
        var cart = await khalti;
        cart.open(context);
        ```

from checkout-sdk-flutter.

cimplesid-tekkon avatar cimplesid-tekkon commented on June 30, 2024

Update on ^1.0.0-dev.4

  • Issue 1: encounters unnecessary networkFailure event causing no network UI even when network available
  • issue 2: no onPaymentResult callback is fired (unable to track a payment)
final payConfig = KhaltiPayConfig(
          publicKey: "",
          pidx: pidx,
          openInKhalti: false,
          returnUrl: Uri.parse('https://hamroshare.com.np'),
          environment: kDebugMode ? Environment.test : Environment.prod,
        );
        var khalti = Khalti.init(
          enableDebugging: kDebugMode,
          payConfig: payConfig,
          onPaymentResult: (paymentResult, khalti) {
            hprint("onPaymentResult", "HSpaymentModule");
            hprint(paymentResult.toString());
            setState(() {
              this.paymentResult = paymentResult;
            });
            khalti.close(context);
          },
          onMessage: (
            khalti, {
            description,
            statusCode,
            event,
            needsPaymentConfirmation,
          }) async {
            hprint("onMessage:", "HSpaymentModule");
            hprint(
                'Description: $description, Status Code: $statusCode, Event: $event, NeedsPaymentConfirmation: $needsPaymentConfirmation',
                "HSpaymentModule");
            khalti.close(context);
          },
          onReturn: () => hprint(
              'Successfully redirected to return_url.', "HSpaymentModule"),
        );`
        

-----------------------------------
        Log after complete flow
  -----------------------------------

   [HSpaymentModule] Successfully redirected to return_url.
[HSpaymentModule] onMessage:
[HSpaymentModule] Description: null, Status Code: 0, Event: KhaltiEvent.networkFailure, NeedsPaymentConfirmation: true
[HSpaymentModule] onMessage:
[HSpaymentModule] Description: Khalti payment page disposed, Status Code: null, Event: KhaltiEvent.kpgDisposed, NeedsPaymentConfirmation: true

from checkout-sdk-flutter.

cimplesid-tekkon avatar cimplesid-tekkon commented on June 30, 2024

@biplab-khalti Yeah issue was on my end and I think doc can be improved so that others do not encounter the same issue

  • Return URL current documentation (The URL to redirect after payment is successful.) but it does not say, it should be the same as in the backend param
  • use https URL and do not have "/" at the end of the URL causes a crash while redirecting and exposes the API on 404 page

possible package improments

  • injectable payconfig (not needed in initialization of Configuration
  • separate callback for error cases because when something is wrong and onPaymentResult is not fired it's hard to figure out what is wrong. Example: when publicKey is mismatched and lookup API fails. the payment is completed but will not get success callback

from checkout-sdk-flutter.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.