"The Transaction is invalid ...." PayPal when I send user for approval - php

I am really in trouble from couple of hours, tried many ways but still no luck. I have integrated PayPal in my wordpress theme using Paypal Framework Wordpress plugin. The Sandbox settings are working fine. I got Success on SetExpressCheckout with Token, When I send user to PayPal for approval and payment using https://www.sandbox.paypal.com/webscr?TOKEN=EC-2FY692500K5578627&cmd=_express-checkout it gives me error...
This transaction is invalid. Please return to the recipient's website to complete your transaction using their regular checkout flow.
Please help, what can I do to make it work... I am really worried... :(
UPDATED
I am sending following params for SetExpressCheckout
$ppParams = array(
'METHOD' => 'SetExpressCheckout',
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
'RETURNURL' => admin_url('admin-ajax.php?action=paypal_handler&step=commit&user_id=' . $user_id),
'CANCELURL' => home_url(),
'AMT' => $price,
'PAYMENTREQUEST_0_AMT' => $price,
'PAYMENTREQUEST_0_ITEMAMT' => $price,
'L_PAYMENTREQUEST_0_ITEMCATEGORY0' => 'Digital',
'L_PAYMENTREQUEST_0_NAME0' => 'Prod Name',
'L_PAYMENTREQUEST_0_QTY0' => 1,
'L_PAYMENTREQUEST_0_AMT0' => $price,
'DESC' => 'description',
'FIRSTNAME' => $_POST['first_name'],
'LASTNAME' => $_POST['last_name'],
'EMAIL' => $email
);
$response = hashCall($ppParams);
I am using following https://cms.paypal.com/uk/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ECGettingStarted for cross checking and implementation.

Huh! found the solution... it was nothing just use lower-case letters for TOKEN... in https://www.sandbox.paypal.com/webscr?token=EC-2FY692500K5578627&cmd=_express-checkout

Related

Paypal Checkout SDK - immediate payment

I need to use Paypal checkout in order to accept immediate payment on my Laravel website, and I switched from old Paypal PHP SDK to the new Paypal checkout SDK to support API V2.
I followed the samples codes that provided in the new SDK, I have to create all workflow on my server, so I created an order with intent=CAPTURE with other required fields.
$request = new OrdersCreateRequest();
$request->headers["prefer"] = "return=representation";
$request->body = $this->buildMinimumRequestBody(...);
$response = $this->client->execute($request);
// redirect the user to approval link.
Order body:
return array(
'intent' => 'CAPTURE',
'application_context' =>
array(
'return_url' => 'https://example.com/return',
'cancel_url' => 'https://example.com/cancel',
'locale' => 'en-US',
'user_action' => 'PAY_NOW',
'shipping_preference'=> 'NO_SHIPPING'
),
'purchase_units' =>
array(
0 =>
array(
'amount' =>
array(
'currency_code' => 'USD',
'value' => 12,
'breakdown' =>
array(
'item_total' =>
array(
'currency_code' => 'USD',
'value' => 10,
),
'tax_total' =>
array(
'currency_code' => 'USD',
'value' => 2,
),
),
),
),
),
);
After the user redirected to approval URL and approving it, I execute the payment like below:
$response = $this->client->execute(new OrdersCaptureRequest($payment_id));
Below is the response after executing the payment.
Order and Payment response
So after directing the user to the approval page, then after approving the payment, then executing the order, I got the above result in the attached screenshot which shows the Order status is completed but the payment status is still "pending" and the reason is "PENDING_REVIEW", so I would like to ask if there is any error or something missed to make the payment immediately without waiting for review with an example.
Thanks.

WooCommerce REST API v3 remote ordering and payment and sending all data into WP

I started creating a program where we can browse products by category. Add items to our cart (in messenger) and update cart etc.
We have Stripe / PayPal already connected to our App and would like to handle everything on our end, in the app. Then, when the order is completed, send the entire order as the data array into WP.
A few questions since I'm stuck.
I'd use this part from the API docs:
https://woocommerce.github.io/woocommerce-rest-api-docs/?php#create-an-order
<?php
$data = [
'payment_method' => 'bacs',
'payment_method_title' => 'Direct Bank Transfer',
'set_paid' => true,
'billing' => [
'first_name' => 'John',
'last_name' => 'Doe',
'address_1' => '969 Market',
'address_2' => '',
'city' => 'San Francisco',
'state' => 'CA',
'postcode' => '94103',
'country' => 'US',
'email' => 'john.doe#example.com',
'phone' => '(555) 555-5555'
],
'shipping' => [
'first_name' => 'John',
'last_name' => 'Doe',
'address_1' => '969 Market',
'address_2' => '',
'city' => 'San Francisco',
'state' => 'CA',
'postcode' => '94103',
'country' => 'US'
],
'line_items' => [
[
'product_id' => 93,
'quantity' => 2
],
[
'product_id' => 22,
'variation_id' => 23,
'quantity' => 1
]
],
'shipping_lines' => [
[
'method_id' => 'flat_rate',
'method_title' => 'Flat Rate',
'total' => 10
]
]
];
print_r($woocommerce->post('orders', $data));
I have some issues with that though. I haven't tested it yet because we use it on a live store, but I'd like to know some stuff that isn't mentioned anywhere. Except for when using a 3rd party plugin, which we don't want. We want to only use the native, clean WooCommerce plugin.
• Is it possible to use a payment method as the reference, even though it does not exist in WP itself? So, if we use Stripe to create and pay for the order in messenger even though Stripe itself isn't in use in our store, can we still push that as the payment reference in the $data array here:
'payment_method' => 'stripe',
'payment_method_title' => 'Offsite Payment Method',
I read you need to create the order first normally if you want to get the payment token, and then update the status after payment, but since we're doing the entire ordering and payment processing offsite (only utilizing the WooCommerce catalog) and want to shoot in the order after a successful ordering process outside of WP, I'm a bit puzzled.
There's a lot of info to be found about missing cart features unless you use something like cocart, which we don't want since we can't ask customers to all install another to be able to use our tool.
Anybody came across a similar use case?
Is it possible to use a payment method as the reference, even though it does not exist in WP itself?
Yes, they are basically strings you can pass any data which is of string type it doesn't matter whether it exists in wp or not
And as you said "you need to create the order first normally if you want to get the payment token, and then update the status after payment"
This is true first you need to create order ..
Why ?
Because in most of the payment gateways there will be a field called orderId to bind order id with that transaction and to keep things clean it's used ...So you need to create an order first when you create the order you need to set the status to pending. Then you will get orderId now redirect the user to payment gateway. Once user comes back again update the order status to processing if it success or failure if it failed

Magento 2 Authorize.net Direct Post Method error - Sorry, but something went wrong. Please contact the seller

In Magento 2.2.5 I have enabled the authorize.net Direct Post Method in Sandbox mode, while trying to make the payment at checkout page it's showing error message Sorry, but something went wrong. Please contact the seller.
I checked the console to troubleshoot and found that below message showing in Request URL: https://test.authorize.net/gateway/transact.dll
The reporting of this transaction to the Merchant has timed out. An e-mail has been sent to the merchant informing them of the error. The following is the result of the attempt to charge your credit card.
This transaction has been approved.
It is advisable for you to contact the merchant to verify that you will receive the product or service.
I did lots of research and found that it may occur due the many reasons, I applied all the fixes but still have the same problem.
Below are the key points:
Authorize.net Sandbox URLs:
Gateway URL: https://test.authorize.net/gateway/transact.dll
Transaction Details URL: https://apitest.authorize.net/xml/v1/request.api
Test Mode: NO
SSL: enabled
MD5 Hash: Yes, Less than 10 character long.
Debug Log:
main.DEBUG: array (
'request' =>
array (
'x_version' => '3.1',
'x_delim_data' => 'FALSE',
'x_relay_response' => 'TRUE',
'x_test_request' => 'FALSE',
'x_login' => '****',
'x_method' => 'CC',
'x_relay_url' => 'https://mydomain/authorizenet/directpost_payment/response',
'x_type' => 'AUTH_CAPTURE',
'x_fp_sequence' => '43',
'x_invoice_num' => '000000030',
'x_amount' => 50.0,
'x_currency_code' => 'USD',
'x_tax' => '0.00',
'x_freight' => '5.00',
'x_first_name' => 'Demo',
'x_last_name' => 'Buyer1',
'x_company' => 'Demo',
'x_address' => 'New Street 33',
'x_city' => 'California',
'x_state' => 'California',
'x_zip' => '56005',
'x_country' => 'US',
'x_phone' => '0123456789',
'x_fax' => '',
'x_cust_id' => '',
'x_customer_ip' => '103.15.66.130',
'x_customer_tax_id' => '',
'x_email' => 'myemailaddresss',
'x_email_customer' => '0',
'x_merchant_email' => '',
'x_ship_to_first_name' => 'Demo',
'x_ship_to_last_name' => 'Buyer1',
'x_ship_to_company' => 'Demo',
'x_ship_to_address' => 'New Street 33',
'x_ship_to_city' => 'California',
'x_ship_to_state' => 'California',
'x_ship_to_zip' => '56005',
'x_ship_to_country' => 'US',
'x_po_num' => '',
'x_fp_timestamp' => 1538807586,
'x_fp_hash' => '16bf75c140a4ca76a6dcf3dc82a5c4bf',
),
)
Any help on this will be appreciated.
Thank You.
I have been found the problem and fixed the issue, it was a silly mistake. Actually, my dev site had the IP restriction applied, hence why it was not available to the outside world and authorize.net not able to post on x_relay_url.
Hope this help someone to save their time in this kind of situations.
Thank You

Paypal Sandbox: DoExpressCheckoutPayment 10001 Internal Error

I'm currently working on an e-commerce website, I have integrated Paypal (Express Checkout) and it worked well until yesterday.
When I send the DoExpressCheckoutPayment Request, I receive this response :
"ACK" => "Failure"
"VERSION" => "204.0"
"BUILD" => "000000"
"L_ERRORCODE0" => "10001"
"L_SHORTMESSAGE0" => "Internal Error"
"L_LONGMESSAGE0" => "Internal Error"
"L_SEVERITYCODE0" => "Error"
The parameters that I send :
'USER' => $username,
'PWD' => $password,
'SIGNATURE' => $signature,
'VERSION' => "204.0",
'METHOD' => 'DoExpressCheckoutPayment',
'TOKEN' => $token,
'PAYERID' => $payerid,
'PAYMENTREQUEST_0_AMT' => $price,
'PAYMENTREQUEST_0_ITEMAMT' => $price,
'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR'
Do you have Any idea ?
I could solve that by creating a new buyer and merchant account at https://developer.paypal.com/developer/accounts both in the same country (and so using the same currency).
I updated the API credentials (username, password, signature) from the new merchant and payed with the new buyer account.

How to add product image via the woocommerce REST API?

I am working with the Woocommerce REST API and need to add a product to the store.
It worked before. Now I have this error:
stdClass Object ( [errors] => Array (
[0] => stdClass Object ( [code] =>
woocommerce_api_invalid_remote_product_image
[message] => Error getting remote image
https://www.google.lt/images/srpr/logo11w.png ) ) )
Here is the documentation for adding a product via the WooCommerce REST API
http://woothemes.github.io/woocommerce-rest-api-docs/#create-a-product
Here is my code:
$dataArray = array(
'title' => 'xxxxxxxxxx',
'description' => 'description1',
'price' => '69',
'sku' => 'sku2',
'tags' => 'tag1, tag2, tag3',
'color' => array('red', 'blue'),
'size' => array('S', 'M'),
'image' => 'https://www.google.lt/images/srpr/logo11w.png'
);
public function addProduct($data)
{
$wc_api = $this->_getClient();
$newProductData = array(
'product' => array(
'title' => $data['title'],
'type' => 'variable',
'regular_price' => $data['price'],
'description' => $data['description'],
'sku' => $data['sku'],
'tags' => [ $data['tags'] ],
'images' => [ array('src' => $data['image'], 'position' => '0') ],
'virtual' => true
)
);
return $wc_api->create_product($newProductData);
}
I'm using this client to call the REST API
https://github.com/kloon/WooCommerce-REST-API-Client-Library
EDITED:
If I get image from wordpress where woocommerce is hosted then all is fine. But, if I use a link from another site then I get an error.
I had a similar issue and the error that cURL was generating inside WordPress which leads to woocommerce_api_invalid_remote_product_image was {"errors":{"http_request_failed":["SSLRead() return error -9806"]},"error_data":[]} which means, according to Asaph in https://stackoverflow.com/a/26538127/266531,
php is compiled with a version of cURL that uses Apple's Secure
Transport under Yosemite and the target of the URL request doesn't
support SSLv3 (which was probably disabled due to the POODLE
vulnerability).
My guess is that you are experiencing errors with using SSL over cURL.
Have you tried it with an http link rather thank https?
If you can debug the server side, take a look at what's happening inside class-wc-api-products.php around line 1700. That's what's generating the error. You may be experiencing SSL errors.
If it is the same type of SSL issue, then your possible solutions are
Use a non-secure image link (http instead of https), or
Follow Asaph's steps to install PHP using OpenSSL instead of SecureSSL in his answer at https://stackoverflow.com/a/26538127/266531
In Woocommerce REST API liblary You can also set option to dont validate SSL.
$options = array(
'debug' => true,
'return_as_array' => false,
'validate_url' => false,
'timeout' => 60,
'ssl_verify' => false,
);

Categories