This is the deep-link:
ethereum:0xBaa11D872cfD22c4D9525E1011af790bB56d656E#1337?value=1e18&data=somedata
And this is the QR that is generated from the url above
i am not able to receive the metadata from payment receive event in solidity contract
this is the event log:
{
logIndex: 0,
transactionIndex: 0,
transactionHash: '0x8d504a1253f30bbc43c5212434dc7dc52a122afc2d08cf6e2c496e34fb316ecd',
blockHash: '0xcf91cdab48a97255c52532732fff9091a7ff5f371a6552f94aaac55a95fb42b1',
blockNumber: 33,
address: '0xBaa11D872cfD22c4D9525E1011af790bB56d656E',
type: 'mined',
id: 'log_8ce94ba5',
returnValues: Result {
'0': '0x49372600c1BD394922c0B6463611DeD4CbeDAf45',
'1': '1000000000000000000',
'2': null,
_from: '0x49372600c1BD394922c0B6463611DeD4CbeDAf45',
_amount: '1000000000000000000',
data: null
},
event: 'MoneyReceivedWithData',
signature: '0xf7d31a904a564a801af9dfae1796bd5fd339d215fedc9314fbfbcffb5c14f205',
raw: {
data: '0x0000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000',
topics: [
'0xf7d31a904a564a801af9dfae1796bd5fd339d215fedc9314fbfbcffb5c14f205',
'0x00000000000000000000000049372600c1bd394922c0b6463611ded4cbedaf45'
]
}
this is the solidity functions:
Event:
event MoneyReceived(address indexed _from, uint256 _amount);
Fallback function:
fallback() external payable {
emit MoneyReceived(msg.sender, msg.value);
}
and as you can see the "data" field in the "returnValues" field is null.
Please help. I found no way to pass a metadata to transaction via mobile metamask QR scan transfer (same as deep-link). I need to understand how to build a proper deep-link url to pass the necessary data to my solidity event-emiter or is it a way to pass a metadata as a parameter through deep-link.
Related
For each product we do the following:
When a new product is added, create a new Product with POST /v1/catalogs/products
Using the product_id from step 1, create a new plan POST /v1/billing/plans
Whenever a customer clicks "Subscribe" button, we create a new subscription using plan_id from step 2 with POST /v1/billing/subscriptions
Problem: When creating the subscription we are able to change the price the customer will be billed by passing the plan object to POST /v1/billing/subscriptions endpoint to override the amount of the plan. However passing in a different currency throws an error:
"The currency code is different from the plan's currency code."
With that being said, is thereĀ a way to setup paypal subscriptions where we can pass in a different currency? Is it required to create a new plan for each currency because this does not seem like a good solution
We create a billing plan with the following body:
{
product_id: productId,
name: planName,
status: 'ACTIVE',
billing_cycles: [
{
frequency: {
interval_unit: 'MONTH',
interval_count: 1
},
tenure_type: 'REGULAR',
sequence: 1,
// Create a temporary pricing_scheme. This will be replaced
// with a variable amount when a subscription is created.
pricing_scheme: {
fixed_price: {
value: '1',
currency_code: 'CAD'
}
},
total_cycles: 0
}
],
payment_preferences: {
auto_bill_outstanding: true,
payment_failure_threshold: 2
}
}
We create subscription with the following body (however passing in a different currency than the plan (CAD) throws an error):
{
plan_id: planId,
subscriber: {
email_address: email
},
plan: {
billing_cycles: [
{
sequence: 1,
pricing_scheme: {
fixed_price: {
value: amount,
currency_code: currency
}
}
}
]
},
custom_id: productId
};
Is it required to create a new plan for each currency
Yes
I added a custom field to the default Users record type in CloudKit, and I'm trying to push a value to that new field.
Here's how my request is structured in Node JS:
var query = {
operations :[{
operationType: 'forceUpdate',
record:{
recordType: 'Users',
fields:{
myCustomField: { value: 'stuff' }
},
recordName: '_abc123'
}
}]
}
I'm getting this response from CloudKit:
records: [{
recordName: '_abc123',
reason: 'invalid id string, id=_abc123',
serverErrorCode: 'BAD_REQUEST'
}]
If I put that same custom field on another, custom Record Type (like if I make my own User (without the "s") type) that also has myCustomField on it, the update works fine. So there must be something special I have to do to update the system Users type.
Does anyone know how to update a field on a Users record with the web services API?
I'm using the Paypal Javascript SDK to render smart buttons and capture and authorize all client side. Everything is working great except for the occasional customer not waiting around for processing to complete on our side.
I have set up webhooks and subscribed to all events but am not able to/or not sure how to define and receive any of my custom data IDs etc.
I've attempted several different configurations to pass my data to the order from create order - mainly following this guide https://developer.paypal.com/docs/commerce-platform/v1/reference/orders-integration-guide/#create-order
Which adds custom data to purchase_units as custom and also a metadata json object with supplementary_data and postback_data
paypal.Buttons({
createOrder: function(data, actions) {
return actions.order.create({
intent: 'CAPTURE',
purchase_units : [{
items : ....,
description : ...,
amount : ...,
custom : 'purchase_units_data'
}],
metadata : {
supplementary_data : [{
data : 'supplementary_data'
}],
postback_data : [{
data : 'postback_data'
}]
}
});
},
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
....
});
}
}).render('#paypal-button-container');
Would hope to find a way to pass a bit of custom data to a webhook payload.
The answer appears to be that I was looking at the wrong version of the API.
https://developer.paypal.com/docs/api/orders/v2/#definition-purchase_unit_request
While I can't create a nicely formed metadata object I can however add data to the purchase_units object with reference_id and custom_id.
I'll just have to get a bit creative.
I have a form component in React that can be used to either save a new address, or edit an existing address object in MongoDB. I am using SimpleSchema for client-side schema validation (as well as server-side schema validation).
The document is being passed as a prop to the form with shippingAddress:
<ShippingAddressForm
onChange={this.handleAddressChange.bind(this)}
shippingAddress={shippingAddress}
editModeType={editModeType}
/>
In case of New Address mode type, shippingAddress is passed as a skeleton object:
shippingAddress = {
firstName: "",
address: "",
city: "",
zipCode: "",
company: "",
lastName: "",
address2: "",
state: "",
addressTypeSelected: "",
country: "US",
phoneNumber: ""
}
In case of Edit Address, shippingAddress is used to pass corresponding values from existing MongoDB document:
shippingAddress = {
address: "Arcadia Bay Ct"
city: "Delray Beach"
company: "AT&T"
country: "US"
createdAt: Tue Aug 23 2016 11:59:13 GMT+0530 (IST)
favorite: false
firstName: "Max"
label: "Arcadia Bay Ct"
lastName: "Pricefield"
phoneNumber: "987654321"
state: "FL"
userId: "WEwmG3iYgShasmzGT"
zipCode: "33446"
}
Then the ShippingAddressForm inputs are populated using these values.
Before submitting the form, I validate the formData using a React handler. (This is being done via a submit button in a higher-level component, to which any state changes are regularly propagated.)
onSubmitHandler() {
// get address from form
// check it's complete and send error messages
// if successful save and return to address book
const { userId, saveShippingAddress } = this.props;
let formData = this.state.shippingAddress
let invalidKeys,
validityContext = AddressSchema.namedContext("shippingAddress");
formData.userId = userId;
formData.label = formData.address;
AddressSchema.clean(formData);
if(!validityContext.validate(formData)) {
invalidKeys = validityContext.invalidKeys();
invalidKeys = _.map(invalidKeys, function (o) {
return _.extend({message: validityContext.keyErrorMessage(o.name)}, o);
});
return toastr.error(invalidKeys[0].message, 'Error');
}
return saveShippingAddress(formData);
}
The validation in the above function works perfectly in case of a New Address. If any required key is missing, validityContext.validate(formData) returns false as it should.
However, in case of Edit Address, validityContext.validate(formData) always returns true, even if the data is invalid and required keys are missing etc.
I have checked the formData object being passed into the .validate() function, it is fine. It is not passing the old database object. If my form is missing a 'Last Name' field entry, then formData object is also missing a lastName key. But the SimpleSchema validator still returns true in edit mode.
I have also tried checking just one key using .validateOne(). Same issue occurs there.
The same invalid data is then being caught in server-side validation check and error is returned. However, I need the client-side validation to work in all cases as well.
I am not using MongoDB modifiers.
Has anyone else faced this issue?
ExtJS 5.1.x, with several stores using rest proxy.
Here is an example:
Ext.define('cardioCatalogQT.store.TestResults', {
extend: 'Ext.data.Store',
alias: 'store.TestResults',
config:{
fields: [
{name: 'attribute', type: 'string'},
{name: 'sid', type: 'string'},
{name: 'value_s', type: 'string'},
{name: 'value_d', type: 'string'}
],
model: 'cardioCatalogQT.model.TestResult',
storeId: 'TestResults',
autoLoad: true,
pageSize: undefined,
proxy: {
url: 'http://127.0.0.1:5000/remote_results_get',
type: 'rest',
reader: {
type: 'json',
rootProperty: 'results'
}
}
}
});
This store gets populated when certain things happen in the API. After the store is populated, I need to do some basic things, like count the number of distinct instances of an attribute, say sid, which I do as follows:
test_store = Ext.getStore('TestResults');
n = test_store.collect('sid').length);
The problem is that I have to refresh the browser to get the correct value of 'n,' otherwise, the count is not right. I am doing a test_store.load() and indeed, the request is being sent to the server after the .load() is issued.
I am directly querying the backend database to see what data are there in the table and to get a count to compare to the value given by test_store.collect('sid').length);. The strange thing is that I am also printing out the store object in the debugger, and the expected records (when compared to the content in the database table) are displayed under data.items array, but the value given by test_store.collect('sid').length is not right.
This is all done sequentially in a success callback. I am wondering if there is some sort of asynchronous behavior giving me the inconsistent results between what is is the store and the count on the content of the store?
I tested this with another store that uses the rest proxy and it has the same behavior. On the other hand, using the localStorage proxy gives the correct count consistent with the store records/model instances.
Here is the relevant code in question, an Ajax request fires off and does its thing correctly, and hit this success callback. There really isn't very much interesting going on... the problem section is after the console.log('TEST STORE HERE'); where I get the store, print the contents of the store, load/sync then print the store (which works just fine) and then finally print the length of uniquely grouped items by the sid attribute (which is what is not working):
success: function(response) {
json = Ext.decode(response.responseText);
if(json !== null && typeof (json) !== 'undefined'){
for (i = 0, max = json.items.length; i < max; i += 1) {
if (print_all) {
records.push({
sid: json.items[i].sid,
attribute: json.items[i].attribute,
string: json.items[i].value_s,
number: json.items[i].value_d
});
}
else {
records.push({
sid: json.items[i].sid
})
}
}
//update store with data
store.add(records);
store.sync();
// only add to store if adding to search grid
if (!print_all) {
source.add({
key: payload.key,
type: payload.type,
description: payload.description,
criteria: payload.criteria,
atom: payload.atom,
n: store.collect('sid').length // get length of array for unique sids
});
source.sync();
}
console.log('TEST STORE HERE');
test_store = Ext.getStore('TestResults');
test_store.load();
test_store.sync();
console.log(test_store);
console.log(test_store.collect('sid').length)
}
// update grid store content
Ext.StoreMgr.get('Payload').load();
Ext.ComponentQuery.query('#searchGrid')[0].getStore().load();
}
For completeness, here is the data.items array output items:Array[2886]
which is equivalent count of unique items grouped by the attribute sid and finally the output of console.log(test_store.collect('sid').length), which gives the value from the PREVIOUS run of this: 3114...