Indipay parameter missing exception - laravel

I am sending all the parameters required by indipay but still i am getting a parameter missing exception. If i send the static values then it is working fine.
$parameters = [
'purpose' => 'Application Fee for '.$regnId,
'buyer_name' => $request->s_fname.' '.$request->s_lname,
'amount' => env('APPLICATION_FEE'),
];
$order = Indipay::prepare($parameters);
return Indipay::process($order);
IndipayParametersMissingException in InstaMojoGateway.php line 119 at
InstaMojoGateway->checkParameters(array('redirect_url' =>
'http://127.0.0.1:8000/parent/response/indipay', 'purpose' =>
'Application Fee for GKB_19LKG_000019', 'buyer_name' => 'asdasd
asdasd', 'amount' => '200')) in InstaMojoGateway.php line 41

I finally found the answer.
The indipay package didn't gave the correct error. There was no parameter missing in the request. There was a max size issue in the validator function for the instamojo payment gateway.

Related

Missing required parameter for Route in Laravel tests

I want to test one of the methods that changes the product. The method works on this route
Route::patch('/{id}/edit-product/{product}/edit', [ProductController::class, 'editProduct'])->name('editProduct');
In my test, I call patch and pass this route there and get an error
$response = $this->actingAs($user)->patch(route('editProduct', ['id' => $user->id, 'product' => 1]), [
'title' => 'Updated product',
'description' => 'Updated Product description',
'price' => 100,
'main_photo' => UploadedFile::fake()->image('avatar.jpg', 500, 500)->size(100),
'visible' => true,
'additional_photos' => $new_img,
]);
And every time I get the following error
Missing required parameter for [Route: showProduct] [URI: {id}/edit-product/{product}/show] [Missing parameter: product].
I do not quite understand what is the reason for this error, since the method itself works properly, but the test does not want to work. It seems that I am passing an additional parameter, but the test still swears that it does not exist. What could be the problem?

Laravel Shopify API returns Required parameter missing or invalid on POST Request

I am using Osiset's github for laravel + shopify: https://github.com/osiset/laravel-shopify
But I don't seem the get the POST request going, tried all kinds of variantions already hope one of you'll see my mistake!
Code:
$order_array = [
'order' => [
'email' => "foo#example.com",
'line_items' => [
'variant_id' => 6103067132088,
'quantity' => 1
]
]
];
$order_array = json_encode($order_array);
$shop = User::first();
$request = $shop->api()->rest('POST', '/admin/orders.json', ['body' => $order_array]);
dd($request['body']);
if I do a dd() on order_array after the encode it shows:
{"order":{"email":"foo#example.com","line_items":{"variant_id":6103067132088,"quantity":1}}}
And then it returns
array:1 [
"order" => "Required parameter missing or invalid"
]
I've also tried to make 'body' to 'query'...
I finally found the solution!
// Replace rest
$request = $shop->api()->rest('POST', '/admin/orders.json', ['body' => $order_array]);
// With request
$request = $shop->api()->request('POST', '/admin/orders.json', $order_array);

Guzzle Post Null/Empty Values in Laravel

I've been trying to work with Guzzle and learn my way around it, but I'm a bit confused about using a request in conjunction with empty or null values.
For example:
$response = $client->request('POST',
'https://www.testsite.com/coep/public/api/donations', [
'form_params' => [
'client' => [
'web_id' => NULL,
'name' => 'Test Name',
'address1' => '123 E 45th Avenue',
'address2' => 'Ste. 1',
'city' => 'Nowhere',
'state' => 'CO',
'zip' => '80002'
],
'contact' => [],
'donation' => [
'status_id' => 1,
'amount' => $donation->amount,
'balance' => $donation->balance,
'date' => $donation->date,
'group_id' => $group->id,
],
]
]);
After running a test, I found out that 'web_id' completely disappears from my request if set to NULL. My question is how do I ensure that it is kept around on the request to work with my conditionals?
At this point, if I dd the $request->client, all I get back is everything but the web_id. Thanks!
I ran into this issue yesterday and your question is very well ranked on Google. Shame that it has no answer.
The problem here is that form_params uses http_build_query() under the hood and as stated in this user contributed note, null params are not present in the function's output.
I suggest that you pass this information via a JSON body (by using json as key instead of form_params) or via multipart (by using multipart instead of form_params).
Note: those 2 keys are available as constants, respectively GuzzleHttp\RequestOptions::JSON and GuzzleHttp\RequestOptions::MULTIPART
Try to define anything like form_params, headers or base_uri before creating a client, so:
// set options, data, params BEFORE...
$settings = [
'base_uri' => 'api.test',
'headers' => [
'Accept' => 'application/json',
'Authorization' => 'ajustneedatokenheredontworry'
],
'form_params' => [
'cash' => $request->cash,
'reason' => 'I have a good soul'
]
];
// ...THEN create your client,
$client = new GuzzleClient($settings);
// ...and finally check your response.
$response = $client->request('POST', 'donations');
If you check $request->all() at the controller function that you are calling, you should see that were sent successfully.
For those using laravel, use this:
Http::asJson()

paypal order total with laravel

Anybody using the PayPal API from srmklive with there laravel project?
https://github.com/srmklive/laravel-paypal
Have installed it and I have made it work, till I got the following error.
I have been searching for hours, but can't find the solution.
What would be the problem here?
It keeps saying the following; Order total is invalid.
Array ( [TIMESTAMP] => 2018-06-27T08:06:32Z [CORRELATIONID] => c8e16efc9b6e4 [ACK] => Failure [VERSION] => 123 [BUILD] => 47483429 [L_ERRORCODE0] => 10401 [L_ERRORCODE1] => 10426 [L_ERRORCODE2] => 10431 [L_SHORTMESSAGE0] => Transaction refused because of an invalid argument. See additional error messages for details. [L_SHORTMESSAGE1] => Transaction refused because of an invalid argument. See additional error messages for details. [L_SHORTMESSAGE2] => Transaction refused because of an invalid argument. See additional error messages for details. [L_LONGMESSAGE0] => Order total is invalid. [L_LONGMESSAGE1] => Item total is invalid. [L_LONGMESSAGE2] => Item amount is invalid. [L_SEVERITYCODE0] => Error [L_SEVERITYCODE1] => Error [L_SEVERITYCODE2] => Error [paypal_link] => )
I don't see anything about the order total in the documentation?
Or am I missing something?
The code I am using right now;
`$provider = new ExpressCheckout;
$data = [];
$order_id = 1;
$data['items'] = [
[
'name' => 'Product 1',
'price' => 9.99,
'qty' => 1,
],
];
$data['return_url'] = url('/paypal/ec-checkout-success');
$data['invoice_id'] = config('paypal.invoice_prefix').'_'.$order_id;
$data['invoice_description'] = "Order #$order_id Invoice";
$data['cancel_url'] = url('/');
$total = 0;
foreach ($data['items'] as $item) {
$total += $item['price'] * $item['qty'];
}
$data['total'] = $total;
//return print_r($data);
$response = $provider->setExpressCheckout($data);
//return dd($respons);
// This will redirect user to PayPal
return print_r($response); `
Thank you in advance.
I found the solution to the above problem.
Somehow PayPal doesn't accept the 9.99 USD
When I make a round number like 10 USD it works.

Laravel Payum Omnipay Bridge Logic Exception

I've been getting this error from omnipay bridge whenever I try to capture credit card payment:
Credit card details has to be set explicitly or there has to be an action that supports ObtainCreditCard request.
Here's my code:
//...
$payum = (new PayumBuilder())
->addDefaultStorages()
->addGateway('paymentexpress_pxpost', ['factory' => 'omnipay_paymentexpress_pxpost', 'username' => 'some_username', 'password'=>'some_password'])
->getPayum();
$card = [
'number' => $request->input('cc_number'),
'expiryMonth' => $request->input('expiry_month'),
'expiryYear' => $request->input('expiry_year'),
'cvv' => $request->input('cvv'),
'name' => $request->input('card_name')
];
$payment = new ArrayObject(['amount' => '1.00', 'currency' => 'AUD', 'card' => $card]);
if ($reply = $payum->getGateway('paymentexpress_pxpost')->execute(new Capture($payment), true)) {
// convert reply to http response
}
//...
The ->execute() function is the one that throws an error. I also referred to the same issue from Error: Credit card details has to be set explicitly or there has to be an action that supports ObtainCreditCard request.
Why do you create a new payum builder instead of using the one from laravel package. The one from package have some additional stuff set (like obtain credit card action).
Accoding to the docs you should do something like this
App::resolving('payum.builder', function(\Payum\Core\PayumBuilder $payumBuilder) {
$payumBuilder
->addGateway('paymentexpress_pxpost', [
'factory' => 'omnipay_paymentexpress_pxpost',
'username' => 'some_username',
'password'=>'some_password'
])
;
});

Resources