payumoney post integration in android.error - payment

Hello I am integrating payumoney in app and when i'm trying to post all fields to URL it says that Sorry, some problem occurred.
Below i am pasting my code.
gen Hash();
String post Data = "hash=hash&key=key&txnid=txnid&amount=amount&product info=product info&first name=first name&email=email&contact=contact&SALT=SALT&SURL=SURL&FURL= FURL";
web View = (Web View) findViewById(R.id.webView1);
webView.getSettings().setJavaScriptEnabled(true);
webView.postUrl(url, EncodingUtils.getBytes(postData, "base64"));
public void genHash() {
try {
hash = sha512.sha512(key + "|" + txnid + "|" + amount + "|"
+ productinfo + "|" + firstname + "|" + email
+ "|||||||||||" + SALT);
}
catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
System.out.println(hash);
}

While posting the data to PayUMoney you are not posting a mandatory parameter named service_provider
whose value is always payu_paisa.
So for this reason you are getting this error.
Regards,
PayUMoney Integration Team

Related

Azure blob storage java generate SAS token always throw sr is mandatory. Cannot be empty error

I want to use Java to generate a SAS token, this is what I do:
public static String GetSASToken(String resourceUri, String keyName, String key) {
long epoch = System.currentTimeMillis() / 1000L;
int week = 60 * 30 * 1000;
String expiry = Long.toString(epoch + week);
String sasToken = null;
try {
String stringToSign = URLEncoder.encode(resourceUri, "UTF-8") + "\n" + expiry;
String signature = getHMAC256(key, stringToSign);
sasToken =
"SharedAccessSignature sr=" + URLEncoder.encode(resourceUri, "UTF-8") + "&sig="
+
URLEncoder.encode(signature, "UTF-8") + "&se=" + expiry + "&skn="
+ keyName;
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return sasToken;
}
public static String getHMAC256(String key, String input) {
Mac sha256_HMAC = null;
String hash = null;
try {
sha256_HMAC = Mac.getInstance("HmacSHA256");
SecretKeySpec secret_key = new SecretKeySpec(key.getBytes(), "HmacSHA256");
sha256_HMAC.init(secret_key);
Encoder encoder = Base64.getEncoder();
hash = new String(encoder.encode(sha256_HMAC.doFinal(input.getBytes("UTF-8"))));
} catch (InvalidKeyException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return hash;
}
This code is nothing but copied from microsoft website,
Then in main class:
String key = "xxxxxHh9jP1ZOTYZI/z1OCVeThsjK00sSc3TYUuiHJQ==";
String kn = "frankbucket";
String url = "https://frankbucket.blob.core.windows.net/mycontainer";
System.out.print(AzureSASTokenGenerator.GetSASToken(url, kn, key));
when I run this, I got below SAS:
SharedAccessSignature sr=https%3A%2F%2Ffrankbucket.blob.core.windows.net%2Fmycontainer&sig=xxxj7Fgbkz5OSag%2BzFQAzBkIdd3I1J9AmFwxjcQg%3D&se=1588299503&skn=frankbucket
In Javascript:
var blobUri = 'https://frankbucket.blob.core.windows.net';
var token =
"SharedAccessSignature sr=https%3A%2F%2Ffrankbucket.blob.core.windows.net%2Fmycontainer&sig=ZA5fgKKny5%2BzdffvdEmy6WdsqqpoMsssssYYM9ruXgAdo0%3D&se=1588299257&skn=frankbucket";
var blobService = AzureStorage.Blob.createBlobServiceWithSas(blobUri, token);
blobService.listBlobsSegmented('mycontainer', null, function(error, results) {
When I run it, I got below error:
<?xml version="1.0" encoding="utf-8"?><Error><Code>AuthenticationFailed</Code><Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:ea315aac-001e-00a0-0700-0f2e4d000000
Time:2020-04-10T06:22:18.2383162Zsr is mandatory. Cannot be empty
I have no clue where is the issue, I got code form microsoft website, but it does not work.
Can anyone show me working example for this?
Hope to hear your advice.
Thanks
If you want to know how to create account sas token with java, please refer to the following code
public void callblobRestAPIWithSas() throws NoSuchAlgorithmException, InvalidKeyException, IOException {
// 1. create account sas token
SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
fmt.setTimeZone(TimeZone.getTimeZone("UTC"));
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(Calendar.DATE, -2);
String start = fmt.format(cal.getTime());
cal.add(Calendar.DATE, 4);
String expiry = fmt.format(cal.getTime());
String StorageAccountName = "blobstorage0516";
String StorageAccountKey = "";
String apiVersion="2019-07-07";
String resource ="sco";
String permissions ="rwdlac";
String service = "b";
String stringToSign = StorageAccountName + "\n" +
permissions +"\n" + // signed permissions
service+"\n" + // signed service
resource+"\n" + // signed resource type
start + "\n" + // signed start
expiry + "\n" + // signed expiry
"\n" + // signed IP
"https\n" + // signed Protocol
apiVersion+"\n"; // signed version
SecretKeySpec secretKey = new SecretKeySpec(Base64.getDecoder().decode(StorageAccountKey), "HmacSHA256");
Mac sha256HMAC = Mac.getInstance("HmacSHA256");
sha256HMAC.init(secretKey);
String signature=Base64.getEncoder().encodeToString(sha256HMAC.doFinal(stringToSign.getBytes("UTF-8")));
String sasToken = "sv=" + apiVersion +
"&ss=" + service+
"&srt=" + resource+
"&sp=" +permissions+
"&se=" + URLEncoder.encode(expiry, "UTF-8") +
"&st=" + URLEncoder.encode(start, "UTF-8") +
"&spr=https" +
"&sig=" + URLEncoder.encode(signature,"UTF-8");
//2. test the sas token
String resourceUrl="https://blobstorage0516.blob.core.windows.net/test/help.txt"; // your blob url
URL url = new URL(resourceUrl+"?"+sasToken);
OkHttpClient httpClient = new OkHttpClient().newBuilder().build();
Request request = new Request.Builder()
.url(url)
.method("GET", null)
.build();
okhttp3.Response response = httpClient.newCall(request).execute();
if(response.isSuccessful()){
System.out.println("The blob content : "+ response.body().string());
}
}

Devices are not registered in azure push notification hub in xamarin forms

I am trying to register device token with tag in azure push notification hub in development mode but in azure portal it shows 0 active devices registered, when I check with notification hub it will show one registration is occur.
Here is my sample code:
App delegate:
var deviceTokenDes = deviceToken.Description;
if (!string.IsNullOrWhiteSpace(deviceTokenDes))
{
deviceTokenDes = deviceTokenDes.Trim('<');
deviceTokenDes = deviceTokenDes.Trim('>');
deviceTokenDes = deviceTokenDes.Replace(" ", "");
DeviceToken = deviceTokenDes.Trim('<');
DeviceToken = deviceTokenDes.Trim('>');
DeviceToken = deviceTokenDes.Replace(" ", "");
}
Hub = new SBNotificationHub(myapp.ListenConnectionString, myapp.NotificationHubName);
Login view model:
var tags = new List<string> { userId };
AppDelegate.Hub?.UnregisterAllAsync(AppDelegate.DeviceToken, error =>
{
if (error != null)
{
Console.WriteLine("Error calling Unregister: {0}", error);
}
AppDelegate.Hub.RegisterNativeAsync(AppDelegate.DeviceToken, new NSSet(tags.ToArray()), errorCallback =>
{
if (errorCallback != null)
{
Console.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString());
}
});
I have registered device token with tag after user successfully login in to the application. Can you please suggest idea on.
This is all we do in our AppDelegate class.
public override async void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
{
bool ShouldComplete = true;
// Validate if we have already got a registration
try
{
string validation = NSUserDefaults.StandardUserDefaults.StringForKey("InitialTagRegistration");
if (validation.Contains("Completed"))
{
ShouldComplete = false;
}
}
catch (Exception genEx)
{
ApplicationLog.AppendFile(DateTime.Now.ToString() + " : " + "[EXCEPTION] - Exception has been hit! - Message: " + genEx.Message + " | Source: " + genEx);
}
Hub = new SBNotificationHub(ConfigurableSettings.NotificationHubConnectionString, ConfigurableSettings.NotificationHubPathName);
ApplicationState.SetValue("NotificationHub", Hub);
// Get previous device token
NSData oldDeviceToken = await ApplicationSettings.RetrieveDeviceToken();
// If the token has changed unregister the old token and save the new token to UserDefaults.
if (oldDeviceToken != null)
{
if (oldDeviceToken.ToString() != deviceToken.ToString())
{
try
{
Hub.UnregisterAllAsync(oldDeviceToken, (error) =>
{
//check for errors in unregistration process.
if (error != null)
{
ApplicationLog.AppendFile(DateTime.Now.ToString() + " : " + "[PNS EXCEPTION] - Exception has been hit! - Message: " + error + " | Source: " + "Unregistering old device token against the notification hub.");
//exit out of the code here because we can't keep our hub clean without being able to remove the device from our registration list.
return;
}
else
{
ShouldComplete = true;
}
});
}
catch (Exception genEx)
{
ApplicationLog.AppendFile(DateTime.Now.ToString() + " : " + "[PNS EXCEPTION] - Exception has been hit! - Message: " + genEx.Message + " | Source: " + genEx + Environment.NewLine + Environment.NewLine);
}
}
}
else
{
// Store current device token
bool res = await ApplicationSettings.CacheDeviceToken(deviceToken);
}
// Check if we need to perform our initial registrations
if (ShouldComplete)
{
NSSet RegisteredTags = await ApplicationSettings.RetrieveUserTags();
if (RegisteredTags == null)
{
RegisteredTags = new NSSet("AppleDevice");
}
//Register the device against the notification hub keeping the details accurate at all times.
Hub.RegisterNativeAsync(deviceToken, RegisteredTags, (errorCallback) =>
{
if (errorCallback != null)
{
ApplicationLog.AppendFile(DateTime.Now.ToString() + " : " + "[PNS EXCEPTION] - Exception has been hit! - Message: " + errorCallback + " | Source: " + "Registering device token against the notification hub.");
}
else
{
if (deviceToken != null)
{
NSUserDefaults.StandardUserDefaults.SetString("Completed", "InitialTagRegistration");
NSUserDefaults.StandardUserDefaults.Synchronize();
}
}
});
}
}
The long and short of it is that you don't need to do anything to the device token before passing it up to the azure notification hub. That's what solved the problem for us, ours has been running in an active application for months now without any issues. Hope this helps.
EDIT: in order to update the tags when a user logs in, we store the device token for use later on, and when the user logs in we use the following method in a seperate class to facilitate updating the tags:
public static async Task<bool> UpdateTags(StaffProfile user)
{
//Get the instance of the Notification hub
SBNotificationHub UpdateHub = new SBNotificationHub(ConfigurableSettings.NotificationHubConnectionString, ConfigurableSettings.NotificationHubPathName);
//Grab the current device token that was stored during the start up process.
NSData CurrentDeviceToken = await ApplicationSettings.RetrieveDeviceToken();
//Get and create the tags we want to use.
string EmailTag = string.Empty;
string StoreTag = string.Empty;
string OrganisationTag = "AppleDevice:OrgTag";
string GenericTag = "AppleDevice:StaffTag";
if (!string.IsNullOrWhiteSpace(user.Email))
{
EmailTag = user.Email;
//Remove unwanted spaces and symbols.
EmailTag = EmailTag.Replace(" ", "");
EmailTag = string.Format("AppleDevice:{0}", EmailTag);
}
if (!string.IsNullOrWhiteSpace(user.Store?.Name))
{
StoreTag = user.Store.Name;
//Remove unwanted space.
StoreTag = StoreTag.Replace(" ", "");
StoreTag = string.Format("AppleDevice:{0}", StoreTag);
}
//Create array of strings to the currently fixed size of 3 items.
NSString[] TagArray = new NSString[4];
//Only add in the tags that contain data.
if (!string.IsNullOrEmpty(EmailTag)) { TagArray[0] = (NSString)EmailTag; }
if (!string.IsNullOrEmpty(StoreTag)) { TagArray[1] = (NSString)StoreTag; }
if (!string.IsNullOrEmpty(OrganisationTag)) { TagArray[2] = (NSString)OrganisationTag; }
if (!string.IsNullOrEmpty(GenericTag)) { TagArray[3] = (NSString)GenericTag; }
NSSet tags = new NSSet(TagArray);
// Store our tags into settings
ApplicationSettings.CacheUserTags(tags);
try
{
if (CurrentDeviceToken == null)
{
ApplicationLog.AppendFile(DateTime.Now.ToString() + " : " + "[PNS EXCEPTION] - Exception has been hit! - Message: Device token is empty." + Environment.NewLine + Environment.NewLine);
}
else
{
UpdateHub.RegisterNativeAsync(CurrentDeviceToken, tags, (error) =>
{
//check for errors in unregistration process.
if (error != null)
{
ApplicationLog.AppendFile(DateTime.Now.ToString() + " : " + "[PNS EXCEPTION] - Exception has been hit! - Message: " + error + " | Source: " + "Registering against hub with new tags." + Environment.NewLine + Environment.NewLine);
// Lets do this so that we can force the initial registration to take place again.
NSUserDefaults.StandardUserDefaults.SetString("Failed", "InitialTagRegistration");
NSUserDefaults.StandardUserDefaults.Synchronize();
}
else
{
ApplicationLog.AppendFile(DateTime.Now.ToString() + " : " + "[INFORMATION] - Message: Successful Registration - Source: Registering against hub with new tags." + Environment.NewLine + Environment.NewLine);
}
});
}
}
catch (Exception genEx)
{
ApplicationLog.AppendFile(DateTime.Now.ToString() + " : " + "[PNS EXCEPTION] - Exception has been hit! - Message: " + genEx.Message + " | Source: " + genEx + Environment.NewLine + Environment.NewLine);
}
return await Task.FromResult(true);
}
I have tried with fallowing code but i didn't receive any notification. At first time when i send test notification in azure notification hub it will shows one success but didn't receive notification, after second time onward it shows 0 passed and 0 failed.
According to your description, I would recommend you could communicate with APNs directly to check whether you could get the error response to narrow this issue. Here are some useful tutorials, you could refer to them and troubleshoot your issue as follows:
Official documentation:Communicating with APNs
Knuff, a debug application for Apple Push Notification Service (APNs)
PushSharp, a server-side library for sending notification to iOS/OSX (APNS), Android/Chrome (GCM), Windows/Windows Phone, Amazon (ADM) and Blackberry devices. For how to configure and send Apple Push Notifications, you could refer to here.

How to get an existing MediaContainerModel in hybris?

I tried to get MediaFormatModel, MediaModel, MediaFolderModel etc with the help of MediaService but only the MediaContainer is not possible to get from MediaService and I tried with ModelService. Only one possibility I found that by getting MediaModel we can get the MediaContainerModel but I need to get specific MediaContainerModel by passing qualifier. Like for example:
final MediaModel mm1 = mediaService.getMedia(catalogVersion, "picture515x515");
final MediaFormatModel mf1200 = mediaService.getFormat("1200x1200");
final MediaFolderModel mfm = mediaService.getFolder("convertedimages");
any help?
You can always retrieve models using the flexiblesearh getModelByExample
CatalogVersionModel catalogVersion = catalogVersionService.getCatalogVersion("yourCatalogName", "version");
MediaContainerModel container = new MediaContainerModel();
container.setCatalogVersion(catalogVersion);
container.setQualifier("yourQualifier");
try
{
container = flexibleSearchService.getModelByExample(container);
}//no container found
catch (final ModelNotFoundException ex)
{
...
}
private MediaContainerModel getExistingMediaContainer(CatalogVersionModel catalogVersion, String qualifier) {
final String query = "SELECT {" + MediaContainerModel.PK + "} FROM {" + MediaContainerModel._TYPECODE + "} "
+ "WHERE {" + MediaContainerModel.QUALIFIER + "} = ?qualifier AND " + "{" + MediaContainerModel.CATALOGVERSION + "} = ?catalogVersion";
final FlexibleSearchQuery fQuery = new FlexibleSearchQuery(query);
fQuery.addQueryParameter("qualifier", qualifier);
fQuery.addQueryParameter("catalogVersion", catalogVersion);
final SearchResult<MediaContainerModel> searchResult = flexibleSearchService.search(fQuery);
if (searchResult.getTotalCount() > 0) {
return searchResult.getResult().get(0);
} else {
return null;
}
}
I got the solution we can get as follows
#Autowired
MediaContainerService mediaContainerService;......
MediaContainerModel mediaContainer = null;
try
{
mediaContainer = mediaContainerService.getMediaContainerForQualifier("testContainer");
}
catch (final Exception e)
{
mediaContainer = createMediaContainer("testContainer");
}
mediaContainer.setCatalogVersion(catalogVersion);

not able to read J2ME PIM contact details

I want to read contact details like firstname , lastname, mobile no, telephone , fax, address, synchronization and UID details using PIM apis in Nokia S60 sdk.
But , I am getting only Contact.TEL and Contact.EMAIL value, none of the other values I am getting , although, I am able to see other fields like first name, last name in the emulator contact details.
I have configures all the required permission .
ContactList addressbook = (ContactList) (PIM.getInstance().openPIMList(
PIM.CONTACT_LIST, PIM.READ_ONLY));
Contact contact = null;
Enumeration items = addressbook.items();
while (items.hasMoreElements()) {
String name = "";
String telephone = "";
String mobile = "";
String email = "";
String InternetTelephone = "";
String Company = "";
String JobTitle = "";
String Synchronisation = "";
String UID = "";
String LastModified = "";
String contactRow = "";
System.out.println("\n *** NEW ITEM ***");
contact = (Contact) (items.nextElement());
System.out.println(" * contact : " + contact.toString());
try {
name = contact.getString(Contact.FORMATTED_NAME, 0);
System.out.println("Name = " + name);
} catch (Exception ex) {
System.out.println(" Name error "+ ex.getMessage());
}
try {
mobile = contact.getString(Contact.ATTR_MOBILE, 0);
System.out.println("Name = " + name);
} catch (Exception ex) {
System.out.println(" Name error "+ ex.getMessage());
}
try
{ telephone = contact.getString(Contact.TEL, 0);
System.out.println("Telephone = " + contact.getString(115, 0)); //field 115: Telephone
} catch (Exception ex) {
System.out.println(" Telephone error "+ ex.getMessage());
}
try
{
email = contact.getString(Contact.EMAIL, 0);
System.out.println("E-mail = " + contact.getString(103, 0));
} catch (Exception ex) {
System.out.println(" E-mail error "+ ex.getMessage());
}
try
{
UID = contact.getString(Contact.UID, 0);
System.out.println(" UID " + UID );
} catch (Exception ex) {
System.out.println(" UID error "+ ex.getMessage());
}
try
{
LastModified = contact.getString(114, 0);
System.out.println(" Last modified " + contact.getString(114, 0));
} catch (Exception ex) {
System.out.println(" Last modified error "+ ex.getMessage());
}
looking forward your valuable suggestions.
Thanks in advance.
some sapmles from Nokia .... !
http://www.developer.nokia.com/Community/Wiki/How_to_read_contacts_using_JSR_75

SharePoint 2007 Object Model: How can I make a new site collection, move the original main site to be a subsite of the new site collection?

Here's my current setup:
one site collection on a SharePoint 2007 (MOSS Enterprise) box (32 GB total in size)
one main site with many subsites (mostly created from the team site template, if that matters) that is part of the one site collection on the box
What I'm trying to do*:
**If there is a better order, or method for the following, I'm open to changing it*
Create a new site collection, with a main default site, on same SP instance (this is done, easy to do in SP Object Model)
Move rootweb (a) to be a subsite in the new location, under the main site
Current structure:
rootweb (a)
\
many sub sites (sub a)
What new structure should look like:
newrootweb(b)
\
oldrootweb (a)
\
old many sub sites (sub a)
Here's my code for step #2:
Notes:
* SPImport in the object model under SharePoint.Administration, is what is being used here
* This code currently errors out with "Object reference not an instance of an object", when it fires the error event handler
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Deployment;
public static bool FullImport(string baseFilename, bool CommandLineVerbose, bool bfileCompression, string fileLocation, bool HaltOnNonfatalError,
bool HaltOnWarning, bool IgnoreWebParts, string LogFilePath, string destinationUrl)
{
#region my try at import
string message = string.Empty;
bool bSuccess = false;
try
{
SPImportSettings settings = new SPImportSettings();
settings.BaseFileName = baseFilename;
settings.CommandLineVerbose = CommandLineVerbose;
settings.FileCompression = bfileCompression;
settings.FileLocation = fileLocation;
settings.HaltOnNonfatalError = HaltOnNonfatalError;
settings.HaltOnWarning = HaltOnWarning;
settings.IgnoreWebParts = IgnoreWebParts;
settings.IncludeSecurity = SPIncludeSecurity.All;
settings.LogFilePath = fileLocation;
settings.WebUrl = destinationUrl;
settings.SuppressAfterEvents = true;
settings.UpdateVersions = SPUpdateVersions.Append;
settings.UserInfoDateTime = SPImportUserInfoDateTimeOption.ImportAll;
SPImport import = new SPImport(settings);
import.Started += delegate(System.Object o, SPDeploymentEventArgs e)
{
//started
message = "Current Status: " + e.Status.ToString() + " " + e.ObjectsProcessed.ToString() + " of " + e.ObjectsTotal + " objects processed thus far.";
message = e.Status.ToString();
};
import.Completed += delegate(System.Object o, SPDeploymentEventArgs e)
{
//done
message = "Current Status: " + e.Status.ToString() + " " + e.ObjectsProcessed.ToString() + " of " + e.ObjectsTotal + " objects processed.";
};
import.Error += delegate(System.Object o, SPDeploymentErrorEventArgs e)
{
//broken
message = "Error Message: " + e.ErrorMessage.ToString() + " Error Type: " + e.ErrorType + " Error Recommendation: " + e.Recommendation
+ " Deployment Object: " + e.DeploymentObject.ToString();
System.Console.WriteLine("Error");
};
import.ProgressUpdated += delegate(System.Object o, SPDeploymentEventArgs e)
{
//something happened
message = "Current Status: " + e.Status.ToString() + " " + e.ObjectsProcessed.ToString() + " of " + e.ObjectsTotal + " objects processed thus far.";
};
import.Run();
bSuccess = true;
}
catch (Exception ex)
{
bSuccess = false;
message = string.Format("Error: The site collection '{0}' could not be imported. The message was '{1}'. And the stacktrace was '{2}'", destinationUrl, ex.Message, ex.StackTrace);
}
#endregion
return bSuccess;
}
Here is the code calling the above method:
[TestMethod]
public void MOSS07_ObjectModel_ImportSiteCollection()
{
bool bSuccess = ObjectModelManager.MOSS07.Deployment.SiteCollection.FullImport("SiteCollBAckup.cmp", true, true, #"C:\SPBACKUP\SPExports", false, false, false, #"C:\SPBACKUP\SPExports", "http://spinstancename/TestImport");
Assert.IsTrue(bSuccess);
}
Instead of trying to code this up, have you tried to use the SharePoint Content Deployment Wizard from Codeplex?
Export your current hierarchy, and import it to the new place using this tool.
Regards,
M

Resources