paytabscom / flutter-sdk-bridge

MIT License
12 stars 11 forks source link

Request must be in JSON format with content type application/json #17

Closed Aziz-cs closed 2 years ago

Aziz-cs commented 2 years ago

Hello, I've followed the steps of the documentation and when I (startCardPayment) and click PAY NOW button, this toast message appears "Request must be in JSON format with content type application/json".

mohamedkhairy953 commented 2 years ago

Please contact customercare@paytabs.com to make sure that you're using the valid sdk client and server key.

Aziz-cs commented 2 years ago

I am sure that I've copied the right valid keys (Server & Client keys) from this page: https://merchant.paytabs.com/merchant/developers/keys And I think this message "Request must be in JSON format with content type application/json" have nothing to deal with the entered client & server keys as long they are strings. I am testing on Android real device by the way. I think it's a bug. This is the console log when this message appears: I/System.out(16488): payment_sdk_Logs : {"callback":"none","card_details":{"cvv":"111","expiry_month":11,"expiry_year":2021,"pan":"4111111111111111"},"cart_amount":42.0,"cart_currency":"AED","cart_description":"Premium membership","cart_id":"12433","customer_details":{"city":"Egypt","country":"eg","email":"email@domain.com","ip":"255.255.255.255","name":"Muhammad Aziz","phone":"+01067984002","state":"Cairo","street1":"st. 20","zip":"12345"},"paypage_lang":"EN","profile_id":"57141","return":"https://ptsdk-return.paytabs.com/1634726415191","shipping_details":{"city":"Egypt","country":"eg","email":"email@domain.com","ip":"","name":"","phone":"+01067984002","state":"Cairo","street1":"st. 20","zip":"12345"},"tran_class":"ecom","tran_type":"sale","device_info":{"device_id":"","app_id":"com.example.wein","platform":"Android","brand":"Xiaomi","model":"M2007J20CG","carrier":"","os":"11","version":"11","app_version":"1.0.0","sdk_version":"6.1.2","timestamp":"1634726400029","screen_width":"1080","screen_height":"2400","app_lang":"en","device_lang":"ar","connection":"wifi"}} D/CompatibilityChangeReporter(16488): Compat change id reported: 147798919; UID 10410; state: ENABLED

Aziz-cs commented 2 years ago
    var configuration = PaymentSdkConfigurationDetails(
      profileId: "*MY PROFILE ID*",
      serverKey: "*MY SERVER KEY*",
      clientKey: "*MY CLIENT KEY*",
      cartId: "12433",
      cartDescription: "Premium membership",
      merchantName: "Biative FZCO",
      screentTitle: "Wein\nPay with credit card",
      billingDetails: billingDetails,
      shippingDetails: shippingDetails,
      amount: amount,
      currencyCode: "AED",
      locale: PaymentSdkLocale.EN,
      merchantCountryCode: "AE",
    );
    return configuration;
  }

Then I call this method:

FlutterPaytabsBridge.startCardPayment(configuration, (event) {
      setState(() {
        if (event["status"] == "success") {
          // Handle transaction details here.
          var transactionDetails = event["data"];
          print(transactionDetails);
        } else if (event["status"] == "error") {
          // Handle error here.
        } else if (event["status"] == "event") {
          // Handle events here.
        }
      });
    });

When I click (PAY NOW) button after filling details, this message appears "Request must be in JSON format with content type application/json".

mohamedkhairy953 commented 2 years ago

Please contact @.*** As they can compare your inputs with the correct inputs.

This error because of invalid inputs it has nothing to do with the sdk.

On Wed, Oct 20, 2021, 12:44 PM Aziz-cs @.***> wrote:

var configuration = PaymentSdkConfigurationDetails(
  profileId: "*MY PROFILE ID*",
  serverKey: "*MY SERVER KEY*",
  clientKey: "*MY CLIENT KEY*",
  cartId: "12433",
  cartDescription: "Premium membership",
  merchantName: "Biative FZCO",
  screentTitle: "Wein\nPay with credit card",
  billingDetails: billingDetails,
  shippingDetails: shippingDetails,
  amount: amount,
  currencyCode: "AED",
  locale: PaymentSdkLocale.EN,
  merchantCountryCode: "AE",
);
return configuration;

}

Then I call this method: FlutterPaytabsBridge.startCardPayment(configuration, (event) { setState(() { if (event["status"] == "success") { // Handle transaction details here. var transactionDetails = event["data"]; print(transactionDetails); } else if (event["status"] == "error") { // Handle error here. } else if (event["status"] == "event") { // Handle events here. } }); }); When I click (PAY NOW) button after filling details, this message appears "Request must be in JSON format with content type application/json".

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/paytabscom/flutter-sdk-bridge/issues/17#issuecomment-947546159, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEIGPXXBCCJWQ6R4CQ7RPQDUH2MSHANCNFSM5GK6WOZQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

MuhamedAdly commented 2 years ago

Dear @Aziz-cs, please contact the customer support team they will add the Mobile SDK keys to your profile.

Aziz-cs commented 2 years ago

Ok thanks for your fast response, I've contacted customer support and waiting for them to add the Mobile SDK. Thanks Mohamed Adly and Mohamed Khairy,

Aziz-cs commented 2 years ago

Yes it worked after getting Mobile SDK keys from customer service, Thank you very much!