Magento Rest API Issue When Using PayPal Payment Advanced - magento

I'm using Magento's Rest API to sell item from my Wordpress based site. I am having an issue when I try to use PayPal Payment Advanced to complete the transaction. Here is the code below:
$paymentArray = array(
"method" => "payflow_advanced",
'cc_cid' => $_POST['cccvv'],
'cc_owner' => $_POST['firstName'] . " ". $_POST['lastName'],
'cc_number' => $_POST['ccnumber'],
//'cc_type' => "MC",
'cc_exp_year' => $_POST['ccmonth'],
'cc_exp_month' => $_POST['ccyear'],
);
$resultPaymentMethod = $client->call($session, 'cart_payment.method', array($shoppingCartIncrementId, $paymentArray));
When I run the code, it comes back as "true" but the api never hits PayPal and authorizes the transaction.

Once you var_dump($resultPaymentMethod) and see what's it displaying the output..

Related

Error in using same card for subscription and one off payment

Scenario:
I want to create a subscription and also one time payment with the same card. I am using 3D secure card number 4000002500003155 so I got a popup to convert 3D autentication. Once I confirm, I submit payment method to server using Ajax, and I update the default payment method and subscription is creating successfully but one time charge with the same default payment method is throwing this exception:
"The payment attempt failed because additional action is required before it can be completed."
How can I use the same card to create subscription and one off payment with 3D secure card: 4000002500003155
Here is my frontend code:
stripe.confirmCardSetup(clientSecret, {
payment_method: {
card: cardElement,
billing_details:{ name: "{{$data->first_name}} {{$data->last_name}}"}
},}).then(function(result) {
if(result.error){
}else{
}}
Hoping for some help in this.
If you review the description for that test card, you'll see that it requires 3DS for one time payments unless set up and used as off-session.
If you make your one-time payment intent as off-session, after doing the card setup and attaching to a customer as you've done, then it should succeed.
\Stripe\PaymentIntent::create([
'amount' => 2000,
'currency' => 'usd',
'payment_method_types' => ['card'],
'customer' => 'cus_123',
'payment_method' => 'pm_456',
'off_session' => true,
'confirm' => true,
]);

How to post image on facebook timeline using graph api 4.0?

I am creating an API to post on my Facebook timeline using graph API 4.0. For this, i am first creating an album and then post image in that album.
here is the code
$facebook = new Facebook(array(
'appId' => 'APP_ID',
'secret' => 'APP_SECRET',
'cookie' => true,
));
$user = $facebook->getUser();
if ($user) {
//Create an album
$album_details = array(
'message'=> 'Album desc',
'name'=> 'Album name'
);
$create_album = $facebook->apiRequest('/me/albums/{user-access-token}', 'post', $album_details);
dd($create_album);
}
which returns an error
Raw Provider API response: {\"error\":{\"message\":\" This object does not exist or does not support this action\"
But when i gave page token instead of a user access token , it works fine. I am new to this. So, i have no idea how to solve this.
The Facebook API no longer permits publishing to personal profile feeds.
https://developers.facebook.com/docs/graph-api/reference/v4.0/user/feed#publish
As of April 24,2018, the publish_actions permission has been removed. Please see the Breaking Changes Changelog for more details. To provide a way for your app users to share content to Facebook, we encourage you to use our Sharing products instead.

How to override shipping address without checkbox in PayPal

I'm trying to implement PayPal Api in my application, everything works just fine except for one thing; How can I override the shipping address in PayPal Payment without checking the Make this my preferred shipping address checkbox.
I want it to be automatically check or my shipping address MUST be automatically applied as my shipping address. Please see the code and screenshot below:
$patchReplace = new Patch();
$patchReplace->setOp('add')
->setPath('/transactions/0/item_list/shipping_address')
->setValue([
"recipient_name" => "{$request->input('first_name')} {$request->input('last_name')}",
"line1" => $request->input('address'),
"line2" => $request->input('barangay'),
"city" => $request->input('city'),
"state" => $request->input('province'),
"phone" => $request->input('contact_number'),
"postal_code" => $request->input('zip'),
"country_code" => $request->input('country')
]);
$patchRequest = (new PatchRequest())->setPatches([$patchReplace]);

Inventory stock is not updating for a particular product using Soap Api

I am using Magento version 1.12.0.2.
I am not able to update stock quantity using soap API. It is working fine for other products except one. I tried to update manually from admin and it worked fine but when trying to update from soap API, its not updating.
Please find the script below:
$proxy = new SoapClient('https://sueryder.wcltest.com/index.php/api/v2_soap/?wsdl');
$sessionId = $proxy->login('demo', 'demotest');
$result = $proxy->catalogInventoryStockItemUpdate($sessionId, 3711, array(
'qty' => '31',
'is_in_stock' => 1
));
var_dump($result);
Use soap client- https://sueryder.wcltest.com/index.php/api/v2_soap/?wsdl=1 insteed of https://sueryder.wcltest.com/index.php/api/v2_soap/?wsdl.

Magento - Customer Not Logged in After Redirect From External Page

I'm having a lot of trouble getting a customer to stay logged in after I have created a new account. I'm creating them an account and adding products to a cart from an external site, and then sending them to Magento store. What I want to have happen is:
A customer goes to a signup page and enters relevant information.
They go to a new page where they can choose to add free samples to their cart.
After picking samples. their account is created and they are redirected to the Magento store with the samples in their cart.
The problem I'm having is between steps 2 and 3. I create an account using the Magento's SOAP API with the following:
$customerInfo = array('firstname' => $custFirstname, 'lastname' => $custLastname, 'email' => $email, 'password_hash' => md5( $new_password ), 'store_id' => 34, 'website_id' => 25,'group_id' => 9);
// Call API method customer.create
$newCustomerId = $client->call( $session, 'customer.create', array( $customerInfo ) );
I then return their customer ID, which I pass to another function which actually logs them in and adds products to their cart:
public static function _addSamplesToCart($customer_id, $sample_one, $sample_two, $sample_three){
Mage::getSingleton("core/session", array("name" => "frontend"));
$customerSession = Mage::getSingleton('customer/session', array("name" => "frontend"));
$customerSession->init("customer_bn_us");
$customerSession->loginById($customer_id);
$cart = Mage::getSingleton('checkout/cart');
$cart->addProductsByIds($idArray);
$cart->save();
$cart->getCheckoutSession()->setCartWasUpdated(true);
}
These functions are actually called from AJAX post requests, so when I get a successful return value from _addSamplesToCart, I do a simple javascript redirect (window.location ="http://www.myhostname.net/welcome") and it correctly takes me there, but I'm not logged in.
I've been looking around all afternoon and trying a few different things and nothing has worked. I've also tried doing a hidden form submit to /customer/account/loginPost and it still doesn't work. I have verified that it's correctly creating an account in Magento. My only hunch is that I'm doing this with a mix of AJAX and PHP so somehow the cookies or sessions are getting mixed up?
If you are trying to login from an hostname different from the one used by the Magento store, it cannot work. You can verify this by checking if a frontend cookie is created after the AJAX call.
I suggest you to create a new controller in Magento that receives the id of the customer just created and executes the code you wrote in your function:
www.myhostname.net/autologin/myaction/13 (where 13 is the id of the customer just created).
Obviously you should add something else to avoid security issues.

Resources