React-native-payments: issue Unhandled Promise Rejection - android

It's about the react-native-payments from Naoufal
I follow the simple tutorial, all is good, installation, setting, and so on.
When I called paymentRequest.show(). I have the warning
Possible Unhandled Promise Rejection(id:0)
I've already write a message to the developer, maybe the issue is in its side, I don't know.
Here is the simple code:
const METHOD_DATA = [{
supportedMethods: ['android-pay'],
data: {
supportedNetworks: ['visa', 'mastercard', 'amex'],
currencyCode: 'USD',
environment: 'TEST', // defaults to production
paymentMethodTokenizationParameters: {
tokenizationType: 'NETWORK_TOKEN',
parameters: {
publicKey: 'your-public-key'
}
}
}
}];
const DETAILS = {
id: 'basic-example',
displayItems: [
{
label: 'Movie Ticket',
amount: { currency: 'USD', value: '15.00' }
}
],
total: {
label: 'Merchant Name',
amount: { currency: 'USD', value: '15.00' }
}
};
const paymentRequest = new PaymentRequest(METHOD_DATA, DETAILS);
paymentRequest.show().then((response) => {
console.log(response)
});
I just want to display the payment view.
Here is the link of tutorial:
https://github.com/naoufal/react-native-payments

Related

How can a regular React application save video to Android Galery?

I figured out it is not possible to share video content onto Instagram directly on Android in behalf of the user. This was my original intention.
Seems I can not use navigator.share call which works on iOS but not on Android, or only for text and url, but not for video / mp4.
I would not use MediaStore and similar React Nativ solutions as my app is a regular React.
What elso approach do you know?
I have now this:
const showShareDialog = async () => {
try {
log(
{
text: 'setIsDownloadFileInProgress(true) ' + getTempUserShortId(),
},
env
)
setIsDownloadFileInProgress(true)
const res = await axios.get(
`https://t44-post-cover.s3.eu-central-1.amazonaws.com/${imgId}.mp4`,
{ withCredentials: false, responseType: 'blob' }
)
setIsDownloadFileInProgress(false)
const shareData = {
files: [
new File([res.data], `${imgId}.mp4`, {
type: 'video/mp4',
}),
],
title: 'Megosztom',
text: 'Mentsd le a képekbe, és oszd meg storyban.',
}
//showShareDialog(shareData, 0)
if (navigator.share && !isDesktop) {
log(
{
text:
`navigator.share && !isDesktop shareData.files[0].size: ${shareData.files[0].size} ` +
getTempUserShortId(),
},
env
)
if (isAndroid()) {
const { status } = await MediaLibrary.requestPermissionsAsync()
if (status === 'granted') {
const asset = await MediaLibrary.createAssetAsync(res.data)
await MediaLibrary.createAlbumAsync(`${imgId}.mp4`, asset, false)
}
} else {
navigator
.share(shareData)
.then(() => {
log(
{
text: `'The share was successful 1 ` + getTempUserShortId(),
},
env
)
})
.catch((error) => {
log(
{
text:
`There was an error sharing 1 ${error} ` +
getTempUserShortId(),
},
env
)
})
}
} else {
log(
{
text: 'else ' + getTempUserShortId(),
},
env
)
setIsDesktopDownloadDialogVisible(true)
}
} catch (error) {
console.error(error)
log(
{
text: `a onclick error 2: ${error} ` + getTempUserShortId(),
},
env
)
}
}

MissingSchemaError: Schema hasn't been registered for model products

MissingSchemaError: Schema hasn't been registered for model products
getCartItems MissingSchemaError: Schema hasn't been registered for model "products".
Use mongoose.model(name, schema)
at NativeConnection.Connection.model (F:\ecommerceApp\ecommerce-backend\node_modules\mongoose\lib\connection.js:1242:11)
This is the controller
Cart
const mongoose = require('mongoose');
const cartSchema = new mongoose.Schema({
user: { type: mongoose.Schema.Types.ObjectId, ref: 'user', required: true },
cartItems: [
{
product : {
type :mongoose.Schema.Types.ObjectId,
ref : "product",
required:true
},
quantity : {
type:Number,
default:1
}
}
]
} ,{timestamps:true});
module.exports = mongoose.model('Cart' , cartSchema , 'cart');
Products
const mongoose = require('mongoose');
const productSchema = new mongoose.Schema({
name: {
type: String,
required: true,
trim: true
},
slug: {
type: String,
required: true,
unique: true
},
quantity: {
type: Number,
required: true
},
price: {
type: Number,
required: true
},
description: {
type: String,
required: true,
trim: true
},
offer: { type: Number },
productPictures: [{
img: { type: String }
}],
reviews: [{
userid: { type: mongoose.Schema.Types.ObjectId, ref: "User", review: String }
}],
category: { type: mongoose.Schema.Types.ObjectId, ref: "Categories" },
createdby: {
type: mongoose.Schema.Types.ObjectId, ref: "User", required: true
},
updatedAT: {
type: Date
}
}, { timestamps: true });
module.exports = mongoose.model('Product', productSchema);
Document
Products
{"_id":{"$oid":"6027d3a8cf712436607e6a6f"},"name":"Samsung Galaxy S21 Plus (Phantom Silver, 256 GB) (8 GB RAM)","slug":"Samsung-Galaxy-S21-Plus-(Phantom-Silver-256-GB)-(8-GB-RAM)","price":5000,"quantity":10,"description":"With the Samsung Galaxy S21 Plus Smartphone, you can click amazing shots and record stunning videos at up to 8K resolution as it comes with a 64 MP camera setup. This smartphone is 5G-ready, enabling you to stream videos and download content from the Web with minimal lag. Moreover, its powerful processor and long-lasting battery make it a delight to use this smartphone.","productPictures":[{"_id":{"$oid":"6027d3a8cf712436607e6a70"},"img":"wGFfBkAhQ-samsung-galaxy-j6-sm-j600gzbgins-original-imaf6zpf6q8tjcva.jpeg"}],"category":{"$oid":"6020d53117616c5228246ac4"},"createdby":{"$oid":"601400873e5a422f9c81ae1c"},"reviews":[],"createdAt":{"$date":"2021-02-13T13:27:04.135Z"},"updatedAt":{"$date":"2021-02-13T13:27:04.135Z"},"__v":0}
Cart
{"_id":{"$oid":"6027d3bacf712436607e6a71"},"user":{"$oid":"60238bea8f89fb538c845f5b"},"cartItems":[{"quantity":2,"_id":{"$oid":"6027d3d4cf712436607e6a73"},"product":{"$oid":"6027d3a8cf712436607e6a6f"}}],"createdAt":{"$date":"2021-02-13T13:27:22.393Z"},"updatedAt":{"$date":"2021-02-13T13:27:48.217Z"},"__v":0}
Router export method , Here is the error which is not populating the population not happening
Throws in when called from PostMan
exports.getCartItems = (req, res) => {
//const { user } = req.body.payload;
//if(user){
console.log('req.user._id' , req.user._id);
Cart.findOne({ user: req.user._id })
.populate("cartItems.product", "_id name price productPictures")
.exec((error, cart) => {
console.log('getCartItems' , error);
if (error) return res.status(400).json({ error });
if (cart) {
let cartItems = {};
cart.cartItems.forEach((item, index) => {
cartItems[item.product._id.toString()] = {
_id: item.product._id.toString(),
name: item.product.name,
img: item.product.productPictures[0].img,
price: item.product.price,
qty: item.quantity,
};
});
res.status(200).json({ cartItems });
}
});
//}
};
You have a typo. You mean products but typed proucts

Razor pay not working in react-native version 0.61.5. Android app crash on razorpayCheckout.open. Any solutions?

All parameters are holding proper values, but app crashes without logs RazorpayCheckout.open line.
let options = {
description: title,
image: 'https://cdn.razorpay.com/logos/DjijAUZBHCGlv4_medium.png',
currency: currency,
key: orderInfo.key,
amount: base_price,
name: 'dfgdfg',
order_id:orderInfo.order_id,
prefill: {
email: user.email,
contact: user.country_code + user.mobile_number,
name: user.first_name + ' ' + user.last_name
},
theme: { color: '#F37254' }
}
RazorpayCheckout.open(options).then((err,data) => {
console.log(err,data)
}).catch((error) => {
console.log(error)
});

Realm crashes on create object (React Native)

This is my RealmService file:
import Realm from 'realm';
const AuthSchema = {
name: 'Auth',
primaryKey: 'id',
properties: {
id: {
type: 'int',
indexed: true
},
time: 'date',
username: 'string',
action: 'string'
}
}
const WiretransferSchema = {
name: 'Wiretransfer',
primaryKey: 'id',
properties: {
id: {
type: 'int',
indexed: true
},
time: 'date',
source: 'string',
target: 'string',
amount: 'float',
comments: {
type: 'string',
optional: true
}
}
}
let RealmService = {
findAllAuth: function() {
return repository.objects('Auth');
},
SaveAuth: function(username, action) {
Realm.open({
path: 'testtt.realm',
schema: [AuthSchema, WiretransferSchema]
}).then(realm => {
// Get max ID
var maxId = realm.objects('Auth').max('id');
realm.write(() => {
realm.create('Auth', {
id: maxId + 1,
time: Date.now(),
username: username,
action: action
}, true);
});
realm.close();
}).catch(err => {
console.log(err);
});
}
}
module.exports = RealmService;
The app crashes without any errors when this code is called:
realm.write(() => {
realm.create('Auth', {
id: maxId + 1,
time: Date.now(),
username: username,
action: action
}, true);
});
Just the write method doesn't crash the app. It's the create method.
If I disable the debugging tools in React Native the app doesn't crash but there is nothing in the realm file added.
I've tried RN 0.57.1 and 0.57.8. Reinstalled realm and still no luck. What could the problem be?
Make sure datatypes and objects you are passing are same. I got same crash when my datatype was int and I gave it string.
In your case passing new Date() will work.
It won't give any errors but app will crash on both android and iOS. Maybe realm team will solve it in future release as this bug already exists in Github forum.

Sencha Touch Chart, visible in browser, but not in my android phone

I trying to build an application using Sencha Touch 2.4.1,
and using cordova packager.
My simple application show chart, when i use
"start sencha web start" application for browsing.
(picture 1).
But when i pack the app to android apk,
on my android phone, it doesn't show the chart,
only starting animation..
(picture 2)
However if i remove line with xtype: 'companystockchart',
my application (on phone) is working (of course without chart)!
What am i doing wrong?
Source code:
app.js:
Ext.require([
]);
Ext.application({
name: 'app',
views: ['CompanyStockChart'],
launch: function() {
Ext.create('Ext.Panel', {
fullscreen: true,
layout: 'fit',
title: 'Chart',
iconCls: 'overview',
items:[{
xtype: 'companystockchart'
}],
listeners: {
activate: function() {
}
}
})
}
});
app.view.CompanyStockChart.js:
Ext.define('app.view.CompanyStockChart', {
extend: 'Ext.chart.Chart',
alias: 'widget.companystockchart',
config: {
store: {
fields: ['name', 'value'],
data: [
{ name: 'Jan', value: 110},
{ name: 'Feb', value: 252},
{ name: 'Mar', value: 952},
{ name: 'Apr', value: 325},
{ name: 'May', value: 123},
{ name: 'Jun', value: 52},
{ name: 'Jul', value: 1122},
{ name: 'Aug', value: 35},
{ name: 'Sep', value: 172},
{ name: 'Oct', value: 752},
{ name: 'Nov', value: 810},
{ name: 'Dec', value: 410}
]
},
animate: false,
interactions: ['panzoom'],
series: [
{
type: 'line',
xField: 'name',
yField: 'value',
style: {
fill: 'rgba(0,40,170,0.3)',
stroke: 'black'
}
}
],
axes: [
{
type: 'numeric',
position: 'left',
title: 'Number of Hits',
minimum: 0,
maximum: 1200,
grid: {
fill: '#efefef',
odd: {
fill: '#cdcdcd'
},
even: {
lineWidth: 3
}
}
},
{
type: 'category',
position: 'bottom',
title: 'Month of the Year',
grid: true,
style: {
estStepSize: 1
}
}
]
}
});
Next i try to debug the app, and i see next issue:
(picture 3)

Categories

Resources