I'm trying to make the below work:
$company->subscription('default')->swapAndInvoice($price_id,['quantity'=>$quantity]);
But I'm getting the following message:
Received both items and quantity parameters. Please pass in only one.
I've also tried this:
$company->subscription('default')->swapAndInvoice($price_id,['items' => ['quantity'=>$quantity]]);
But then I get an invalid array error:
[2020-11-20 10:48:53] local.ERROR: Invalid array {"userId":1,"exception":"[object] (Stripe\\Exception\\InvalidRequestException(code: 0): Invalid array at C:\\xampp\\htdocs\\myproject\\vendor\\stripe\\stripe-php\\lib\\Exception\\ApiErrorException.php:38)
[stacktrace]
#0 C:\\xampp\\htdocs\\myproject\\vendor\\stripe\\stripe-php\\lib\\Exception\\InvalidRequestException.php(35): Stripe\\Exception\\ApiErrorException::factory('Invalid array', 400, '{\
\"error\": {\
...', Array, Object(Stripe\\Util\\CaseInsensitiveArray), NULL)
#1 C:\\xampp\\htdocs\\myproject\\vendor\\stripe\\stripe-php\\lib\\ApiRequestor.php(187): Stripe\\Exception\\InvalidRequestException::factory('Invalid array', 400, '{\
\"error\": {\
...', Array, Object(Stripe\\Util\\CaseInsensitiveArray), NULL, 'items')
#2 C:\\xampp\\htdocs\\myproject\\vendor\\stripe\\stripe-php\\lib\\ApiRequestor.php(149): Stripe\\ApiRequestor::_specificAPIError('{\
\"error\": {\
...', 400, Object(Stripe\\Util\\CaseInsensitiveArray), Array, Array)
#3 C:\\xampp\\htdocs\\myproject\\vendor\\stripe\\stripe-php\\lib\\ApiRequestor.php(461): Stripe\\ApiRequestor->handleErrorResponse('{\
\"error\": {\
...', 400, Object(Stripe\\Util\\CaseInsensitiveArray), Array)
#4 C:\\xampp\\htdocs\\myproject\\vendor\\stripe\\stripe-php\\lib\\ApiRequestor.php(118): Stripe\\ApiRequestor->_interpretResponse('{\
\"error\": {\
...', 400, Object(Stripe\\Util\\CaseInsensitiveArray))
#5 C:\\xampp\\htdocs\\myproject\\vendor\\stripe\\stripe-php\\lib\\ApiOperations\\Request.php(63): Stripe\\ApiRequestor->request('post', '/v1/subscriptio...', Array, Array)
What's the right way of passing a new quantity when swaping to a new plan?
So I kept digging, and I found out the way to call it is:
$company->subscription('default')->swapAndInvoice([$price_id => ['quantity' => $quantity]]);
I eventually found this out when I went from this issue, to this commit. There is a function called test_swapping_subscription_and_adopting_new_quantity where you can see how it's done.
Related
I'm trying to use the set to set multiple properties at the same time for a shape, but I can'get it to work. I keep getting:
https://learn.microsoft.com/en-us/javascript/api/excel/excel.shape?view=excel-js-preview#excel-excel-shape-set-member(2)
InvalidArgument: The argument 'properties' doesn't work for this situation, is missing, or isn't in the right format.
{
[functions]: ,
__proto__: { },
code: "InvalidArgument",
data: undefined,
debugInfo: { },
description: "The argument 'properties' doesn't work for this situation, is missing, or isn't in the right format.",
httpStatusCode: 400,
innerError: { },
message: "The argument 'properties' doesn't work for this situation, is missing, or isn't in the right format.",
name: "RichApi.Error",
stack: "InvalidArgument: The argument 'properties' doesn't work for this situation, is missing, or isn't in the right format.
at n.prototype._recursivelySet (https://appsforoffice.microsoft.com/lib/beta/hosted/excel-win32-16.01.js:26:297901)
at e.prototype.set (https://appsforoffice.microsoft.com/lib/beta/hosted/excel-win32-16.01.js:26:364470)
at Anonymous function (http://localhost:3000/yo/dist/commands.js:1:5299)
at h (http://localhost:3000/yo/dist/globals.js:1:1139)
at Anonymous function (http://localhost:3000/yo/dist/globals.js:1:948)
at Anonymous function (http://localhost:3000/yo/dist/globals.js:1:1583)
at t (http://localhost:3000/yo/dist/commands.js:1:52)
at s (http://localhost:3000/yo/dist/commands.js:1:265)
at Anonymous function (http://localhost:3000/yo/dist/polyfill.js:1:76119)
at e (http://localhost:3000/yo/dist/polyfill.js:1:31843)",
Symbol()_7.6toumoqr294: undefined,
Symbol(nodejs.util.inspect.custom)_j.6toumoqr2cd: undefined,
traceMessages: [ ]
}
I've tried all sorts of variations to no avail.
How can I do this?
Here is example code:
var Shape_Settings_Obj_Template = {
incrementLeft: 100
}
var shape = await IMAGES.Insert_Image_As_Shape(context, ws, Image_Base64_Str) //, Shape_Settings_Obj_Template)
/*
shape.lockAspectRatio = true;
shape.scaleHeight(0.25, Excel.ShapeScaleType.currentSize);
shape.scaleWidth(0.25, Excel.ShapeScaleType.currentSize);
shape.incrementTop(100) //0 = A1
shape.incrementLeft(100) //0 = A1
*/
shape.set(Shape_Settings_Obj_Template)
I am writing a Solana smart contract that integrates with Mango Markets, and am having an error that I am struggling to nail down. Here is the offending code:
let mango_acc_info_clone = &ctx.accounts.mango_account.clone();
let res = MangoAccount::load_mut_checked(
mango_acc_info_clone,
&ctx.accounts.mango_program_id.key().clone(),
&ctx.accounts.mango_group.key().clone(),
);
let mango_account = match res {
Ok(acc) => acc,
Err(error) => panic!("failed to place perp order: {:?}", error),
};
let accounts = [
ctx.accounts.mango_program_id.clone(),
ctx.accounts.mango_group.clone(),
ctx.accounts.mango_account.clone(),
ctx.accounts.mango_account_owner.clone(),
ctx.accounts.mango_cache.clone(),
ctx.accounts.mango_perp_market.clone(),
ctx.accounts.mango_bids.clone(),
ctx.accounts.mango_asks.clone(),
ctx.accounts.mango_event_queue.clone(),
];
let result = mango::instruction::place_perp_order(
&ctx.accounts.mango_program_id.key().clone(),
&ctx.accounts.mango_group.key().clone(),
&ctx.accounts.mango_account.key().clone(),
&ctx.accounts.mango_account_owner.key().clone(),
&ctx.accounts.mango_cache.key().clone(),
&ctx.accounts.mango_perp_market.key().clone(),
&ctx.accounts.mango_bids.key().clone(),
&ctx.accounts.mango_asks.key().clone(),
&ctx.accounts.mango_event_queue.key().clone(),
None,
&mango_account.spot_open_orders,
converted_side,
price,
quantity,
client_order_id,
converted_order_type,
reduce_only,
);
let is = match result {
Ok(is) => is,
Err(error) => panic!("failed to place order: {:?}", error),
};
invoke_signed(
&is,
&accounts,
&[&[
MANGO_OWNER_PDA_SEED,
ctx.accounts.vault.name.as_ref(),
&[_mango_owner_bump],
]],
)
I believe the error to be with the load_mut_checked function, which is returning a RefMut<MangoAccount> type. Here is the error:
solana.rpc.core.RPCException: {'code': -32002, 'message': 'Transaction simulation failed: Error processing Instruction 0: instruction tries to borrow reference for an account which is already borrowed', 'data': {'accounts': None, 'err': {'InstructionError': [0, 'AccountBorrowFailed']}, 'logs': ['Program AQPDVpAsDtd8cfXVjrUEKrhchF4cYwST2wyq3tJa82ci invoke [1]', 'Program log: Debugging', 'Program log: 3', 'Program log: Failed to borrow a reference to account data, already borrowed', 'Program AQPDVpAsDtd8cfXVjrUEKrhchF4cYwST2wyq3tJa82ci consumed 13081 of 200000 compute units', 'Program AQPDVpAsDtd8cfXVjrUEKrhchF4cYwST2wyq3tJa82ci failed: instruction tries to borrow reference for an account which is already borrowed'], 'unitsConsumed': 0}}
I have tried calling .to_owned() on the account, but that just gives me a different error:
solana.rpc.core.RPCException: {'code': -32002, 'message': 'Transaction simulation failed: Error processing Instruction 0: Program failed to complete', 'data': {'accounts': None, 'err': {'InstructionError': [0, 'ProgramFailedToComplete']}, 'logs': ['Program AQPDVpAsDtd8cfXVjrUEKrhchF4cYwST2wyq3tJa82ci invoke [1]', 'Program AQPDVpAsDtd8cfXVjrUEKrhchF4cYwST2wyq3tJa82ci consumed 5013 of 200000 compute units', 'Program failed to complete: Access violation in stack frame 7 at address 0x200007ae0 of size 8 by instruction #52535', 'Program AQPDVpAsDtd8cfXVjrUEKrhchF4cYwST2wyq3tJa82ci failed: Program failed to complete'], 'unitsConsumed': 0}}
Any help would be great. I am very new to Rust and Solana programming so let me know if any additional information can help. I am running this on a local validator.
I believe the error comes from trying to mutably borrow and immutably borrow at the same time, which is not allowed for RefCell: https://doc.rust-lang.org/std/cell/struct.RefCell.html#method.try_borrow
Since the cross-program invocation at invoke_signed may need to mutably borrow data, the easiest way to fix this is to:
avoid mutably borrowing data, perhaps by using something like MangoAccount::load_checked if it exists
drop all references before calling invoke_signed, using drop(mango_account) once you're done with it
i'm using gauge automated ui tests with taiko integration written in javascript.
I cant find a way to solve my problem. Here is the error i got.
message: 'Invalid parameters',
data: 'Failed to deserialize params.x - BINDINGS: mandatory field missing at position 47'
}
}
Error Message: transport is closing
Stacktrace:
Here is my step_implementation.js file
//this step works fine
step("Go to <item>", async(item) => {
await goto(item);
await click($(".fancybox-close-small"))
})
//this step works fine
step("Search for <item>", async(item) => {
await click(textBox(""));
await focus($(".pw-search-input"));
await write(item);
})
//this step does not working, my tests fail while last step accomplished.
step("Go to Product Detail <item> By Index", async(item)=>
{
click(($(".pw-autocomplete-product-suggestion").elements())[item]);
})
step("Select the size <item> by index", async(item)=>
{
click(dropDown({'name':'options'}).elements()[item]);
click(await $(".detail__add2cart"));
})
This my example.spec file
## Go to site
//lets say example.com
* Go to "example.com"
* Search for "ERKEK SPOR AYAKKABI KİNETİX"
* Go to Product Detail "1" By Index
click is an async function and hence has to be awaited, try updating the steps as below
step("Go to Product Detail <item> By Index", async(item)=>
{
await click(($(".pw-autocomplete-product-suggestion").elements())[item]);
})
step("Select the size <item> by index", async(item)=>
{
await click(dropDown({'name':'options'}).elements()[item]);
await click(await $(".detail__add2cart"));
})
when I try to add an listview.builder inside a row an exception appears
my code:
return new Scaffold(
appBar: new AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: new Text(widget.title),
),
body: Row(children: <Widget>[
ListView.builder(
shrinkWrap: true,
scrollDirection: Axis.vertical,
itemCount: 3,
itemBuilder: (BuildContext context, int index) {
return Text('data');
},
)
// This trailing comma makes auto-formatting nicer for build methods.
],)
);
the exception:
══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter ( 5949): The following assertion was thrown during performLayout():
I/flutter ( 5949): 'package:flutter/src/rendering/viewport.dart': Failed assertion: line 1597 pos 16:
I/flutter ( 5949): 'constraints.hasBoundedWidth': is not true.
I/flutter ( 5949): Either the assertion indicates an error in the framework itself, or we should provide substantially
I/flutter ( 5949): more information in this error message to help you determine and fix the underlying cause.
Wrap Expanded and then add to list.builder > physics:
const NeverScrollableScrollPhysics(),
I want to onverting mongodb Binary _id to UUID using node so in order a googling and find my response at this post :
I want to insert this UUId into postgres database.This is my pg function on node.js:
function insert(arg) {
console.log('insert location');
arg.forEach(element => {
(async () => {
await pool.query(
`insert into public."Location" ("Id", "Lat", "Lng", "CreationDateTime", "DeviceId", "Topic", "UserId")
VALUES ('${uuidv1()}', ${element.Lat}, ${element.Lng}, $1, ${element.DeviceId}, $2, $3)`,[element.CreationDateTime, element.Topic,Bin2HexUUID(element.UserId)]);
})();
});
}
This is element.UserId :
Binary {_bsontype: "Binary", sub_type: 4, position: 16, …}
_bsontype:"Binary"
and this is Bin2HexUUID method:
function Bin2HexUUID(bin){
var hex = new Buffer.alloc(bin, 'base64').toString('hex');
return hex.replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/, function (){
return arguments[1]+"-"+arguments[2]+"-"+arguments[3]+"-"+arguments[4]+"-"+arguments[5];
});
}
When i run script i got this error:
new Buffer.alloc(bin, 'base64').toString('hex')
NodeError: The "size" argument must be of type number. Received type object
----------------------
(node:2292) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_TYPE]: The "size" argument must be of type number. Received type object
For first time i used new Buffer(bin, 'base64').toString('hex') but seems new Buffer is deprecated..
This is my Node and Npm version:
node -v
v10.8.0
npm -v
6.2.0
The size argument inBuffer.alloc(size), not unreasonably, requires a number, because it's an argument that tells the method how many bytes to allocate.
Your Bin2HexUUID(element.UserId) is passing the element.UserId object itself to this method (your error message is telling you that when it says "Received type object"). That's not what the method wants. What it wants is the size (length) of Element.UserId.
So, get the length of Element.UserId and pass that instead.
I changed this part
Bin2HexUUID(element.UserId)
to this:
Bin2HexUUID(element.UserId.buffer)]);
and method :
function Bin2HexUUID(bin){
var hex = new Buffer.from(bin, 'base64').toString('hex');
return hex.replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/, function (){
return arguments[1]+"-"+arguments[2]+"-"+arguments[3]+"-"+arguments[4]+"-"+arguments[5];
});
}
I hope this changes help to guys.