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.
Related
I'm building a support system with Codeigniter 3.
When the ticket status is 0, there is no problem, but when I want to set the current status to 1, I get an error.
My database "TNYINT" Length 1 default value 0
if i send it as 0 it's ok but when admin posts this i have to make it 1.
/*** Reply Ticket Post */
public function admin_reply_ticket_post()
{
/// Admin Authority Checkup Getting Started
adminCheck();
// Admin Authority Check End
$data = array(
'ticket_id' => $this->input->post('ticket_id'),
'admin_id' => $this->session->userdata('adminid'),
'first_name' => $this->session->userdata('first_name'),
'last_name' => $this->session->userdata('last_name'),
'message' => $this->input->post('message')
);
$this->db->insert('tickets_sub', $data);
// Make Ticket Status "in the transaction"
$data = array(
'id' => $this->input->post('ticket_id'),
'status' => 1 ,
);
$this->db->update('tickets', $data);
Right now, you're giving all the records in the tickets table a new id and status, that's why you're getting the "Duplicate" error. You need to add a WHERE clause to specify which record to update:
// Make Ticket Status "in the transaction"
$data = array(
'status' => 1 ,
);
$this->db->where('id' => $this->input->post('ticket_id'));
$this->db->update('tickets', $data);
Or even shorter:
// Make Ticket Status "in the transaction"
$data = array(
'status' => 1 ,
);
$this->db->update('tickets', $data, array('id' => $this->input->post('ticket_id')));
See: https://www.codeigniter.com/userguide3/database/query_builder.html#updating-data
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.
I am implementing an API that needs to receive data from my database. The data comes from my 'Products' table. I organized the products that I want to send through Guzzle.
public function post()
{
$product = Product::where('erp_status', '=', 1)->limit(5)->offset(0)->get();
$client = new Client([
// Base URI is used with relative requests
'base_uri' => 'http://httpbin.org',
// You can set any number of default request options.
'timeout' => 2.0,
]);
And right after I created a foreach to send the data through the URL.
foreach($product as $prod){
set_time_limit(0);
$r = $client->request('POST', 'https://api.mercadolibre.com/items?access_token=XXXXXXXXXXXXXXXXXXX', [
'json' => [
'title' => $prod->description->erp_name,
'category_id' => 'MLB46511',
'price' => 10,
'currency_id' => 'BRL',
'available_quantity' => 10,
'buying_mode' => 'buy_it_now',
'listing_type_id' => 'gold_special',
'condition' => 'new',
'description' => 'Teste',
'pictures' => [
['source' => $prod->image->erp_image]
]
]
]);
}
return view('home');
}
But every time I run. It returns the message:
cURL error 28: Operation timed out after 2012 milliseconds with 0 out of 0 bytes received (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
My variable $product have 5 thousand rows.
Does Guzzle support this amount? Is it possible to use the guzzle in this case or what is the pure PHP script?
Any suggestion?
How can I get the author,price and title by knowing the ISBN search using amazon in codeigniter?
and
I been trying to sign up for the AProduct Advertising API registration for about 2 days, every time I get an error: We're sorry! There was an error processing your changes. Please try again. after account info step
how to get keys value of awsAccessKeyID, awsSecretKey, awsAssociateTag?
function getMetadataFromIsbn($isbn) {
// Get your own accesskey at http://aws.amazon.com/
$awsAccessKeyID = 'accesskey';
$awsSecretKey = 'secrete key';
$awsAssociateTag = 'Associate tag';
$host = 'ecs.amazonaws.com';
$path = '/onca/xml';
$args = array(
'AssociateTag' => $awsAssociateTag,
'AWSAccessKeyId' => $awsAccessKeyID,
'IdType' => 'ISBN',
'ItemId' => $isbn,
'Operation' => 'ItemLookup',
'ResponseGroup' => 'Medium',
'SearchIndex' => 'Books',
'Service' => 'AWSECommerceService',
'Timestamp' => gmdate('Y-m-d\TH:i:s\Z'),
'Version'=> '2009-01-06'
);
Has anyone had any luck using SagePay Direct with CI-Merchant? So far the only response I am getting is:
Merchant_response Object
(
[_status:protected] => failed
[_message:protected] =>
[_reference:protected] =>
[_data:protected] =>
[_redirect_url:protected] =>
[_redirect_method:protected] => GET
[_redirect_message:protected] =>
[_redirect_data:protected] =>
)
I haven't used SagePay before and need to get this working urgently. I have added my IP address to the SagePay testing area but am not testing on https as am just on my localhost at the moment.
My code looks like:
public function process_payment()
{
$settings = array (
'vendor' => 'XXX',
'test_mode' => TRUE,
'simulator_mode' => FALSE,
);
$this->merchant->initialize($settings);
//get customer details
$this->load->library('custom_cart');
$customer = $this->custom_cart->get_customer_invoice_info();
$customer_name = '';
if ( ! empty($customer['title'])) $customer_name .= $customer['title'] .' ';
$customer_name .= $customer['forename'];
$customer_name .= $customer['surname'];
$customer_street = $customer['address1'];
$customer_street2 = $customer['address2'];
if ( ! empty($customer['address3'])) $customer_street2 .= $customer['address3'];
//order details
$amt = $this->custom_cart->order_total();
$get_curr = $this->custom_cart->get_currency();
$currencycode = $get_curr['name'];
$shippingamt = $this->custom_cart->shipping_cost();
$itemamt = $this->custom_cart->order_subtotal();
$taxamt = '0';
$invnum = $this->custom_cart->customer_order_no();
$params = array(
'description'=> 'Online order',
'currency'=> $currencycode,
'transaction_id'=> $invnum,
'email'=> $customer['email_address'],
'first_name'=> $customer['forename'],
'last_name'=> $customer['surname'],
'address1'=> $customer_street,
'address2'=> $customer_street2,
'city'=> $customer['town_city'],
'postcode'=> $customer['postcode'],
'country'=> $customer['country'],
'region'=> $customer['county'],
'phone'=> $customer['phone'],
'Amount'=> $amt,
'card_no'=> $this->input->post('creditcard'),
'name'=> $customer_name,
'card_type' => $this->input->post('creditcardtype'),
'exp_month'=> $this->input->post('cardmonth'),
'exp_year' => $this->input->post('cardyear'),
'csc'=> $this->input->post('cardsecurecode')
);
$response = $this->merchant->purchase($params);
echo '<pre>';
print_r($response);
}
(all the values for the params are valid and I have checked the correct values are passed to them. Vendor name is masked here)
Finally tracked down the problem - I was passing through two digits for the year and this is where it was failing (I forgot on my previous merchant I was adding in the 20 prefix)! Thank you for your help. (If anyone has a similar problem I tracked it down by echoing a response from each function in the function trail)