Magento - Capture online from code - magento

often when customers complete and pay their order in our store, the order is set to processing but with the amount due still equal to the grand total and amount paid equal to zero. From the magento backend I can then create an invoice and capture the payment online, which solves this issue. Now I would like to do this automatically. Can anybody help me out with the coding?
I do succeed in creating the invoice, but I cannot find the right function to capture the payment.

I'm not sure which payment method you have enabled, but it seems that you have to update your settings, and as example I will use Authorize.net.
If you go to Admin -> System -> Configuration -> Payment Methods -> Authorize.net, you will see it's settings, and one of this settings is "Payment Action" with two options:
Authorize Only
Authorize and Capture
If the first option is selected, than Magento will not capture the order amount, but will check if there's enough funds on customer's Credit Card.
If the first option is selected, than Magento will check for available funds, and will capture order amount from customer's Credit Card.
PayPal has a similar options, and Here is the related forum topic.

Related

Spring: Paypal Payment on new currencies results to PENDING capture status

I think this is not a code problem since my application can successfully pay and process payments using my account currencies (usd/php/hkd).
Since there was a new requirement to support some currencies (sgd, eur, jpy, etc), I added these currencies Account Settings > Money, banks, and cards.
Btw, I am using paypal order and payment version 2 on spring.
The application was able to pass the currency and value of the transaction (like what I do normally with USD/EUR/PHP).. It was able to create order object, authorized approved payment... but it the capture authorized payment is always stucked at PENDING.
I still need to check on my test paypal account and either Accept/Reject received payment.
However, my application is only checking for COMPLETED capture status for it to considered or mark it as successful payment.
I also tried the configuration on my test paypal account (Account Settings > Payment Preferences > Block Payments).
Tried selecting Yes, accept and convert them to... and Ask me whether to accept or deny each individual payment but the capture status is still PENDING.
Is there a way to proceed with the capture payment and have the status to COMPLETED? Even with payments of different currencies? It would be OK if the payment received will be stored on that currency or have it converted to my default currency (like USD, etc).
What I want is the capture status to proceed to COMPLETED without manually accepting/rejecting payments with other currency (newly added currencies).
Again, I think this is not a coding issue... more of a configuration issue.. but I am not sure which configuration and where to set. I am pretty new with paypal development.
By the way, I based my changes on my paypal account with this link:
Payment Receiving Preferences
TIA
This is standard PayPal behavior. If you accept the first payment in a new currency in a way that opens a balance in such a currency, future payments won't need to be manually accepted. You can also manually open $0 balances in the Money management section, https://www.paypal.com/businessmanage/account/money
The setting in Account Settings > Payment Preferences > Block Payments that you mention to convert non-balance currency transactions to your primary balance will only apply automatically to future payments. Their status should then not be 'PENDING' due to any currency issue.
(If you find that all payments are PENDING, even your primary balance ones, then the pending reason (as stated in the API response) is likely "authorization" -- meaning you created an authorization with intent:AUTHORIZE but haven't captured it yet. Change to intent:CAPTURE to capture immediately.)

Paypal recurring payment for custom billing cycle

I am working on a website in PHP that needs custom cycle for paypal recurring payment. Ex: a customer wants to receive a product in every 15 days. So paypal should process billing in every 15 days for the customer. Others can ask for the same in 30 days, and so on.
I also need the payment status to be updated. I guess paypal will send some data when a recurring payment is done. Not getting clear instructions on implementing the recurring. What I am getting is to create the recurring payment button from paypal account.
Can anyone help me on this?
Assuming the number of days is chosen at checkout time and never changes for that particular customer's custom billing cycle...
Quick solution:
You can generate a "Subscribe" button via http://www.paypal.com/buttons for a certain number of days, say 15 days. In "Step 2", uncheck the option to save the button at PayPal. Once you have generated the code, click the option to remove the code protection.
This will give you plain HTML, and "15" will be one of the variables there. Possible variables are documented at https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables/
So, you can change that hidden input to be of type "text" -- or alternatively to still be hidden but set by your javascript or server-side code, and have a dynamic button for X number of days. The image can also be changed to one of your own, of course.
More involved solution: integrate one of PayPal's recurring subscription APIs, which will accomplish much the same thing as that HTML button. This seems to be the newest API: https://developer.paypal.com/docs/subscriptions/
(The API and the HTML button are separate products , and not interchangeable in terms of how you manage existing recurring profiles later on, so if you need a full-fledged API, best integrate it from day 1 rather than using the HTML button)
If the first assumption does not hold, and you need customers to be able to adjust the billing cycle at a later date after checkout, then things get more complicated.
As far as getting payment status updates, you can integrate PayPal's webhook service: https://developer.paypal.com/docs/integration/direct/webhooks/
There is also an older IPN service that is similar in function

Magento 1.9 - Customize the "Check / Money Order" Order Status from Pending to Complete

I've a Magento website that I'm using for some tests and I need to setup an easy payment method that can make me able to buy something without any risk to get real payment from random users but I also need to register this order with a "complete" status immediately (I've also another add-on that will export complete orders to an external platform but only if they're completed).
I was thinking to use the "Check / Money Order" but there is only one option configurable from "System/Configuration/Payment Methods" and it's the "Pending" status.
I'm quite new with Magento so, is there any easy method to change that status and register automatically the Order as Complete also if using the Payment method? If not, there is the possibility to enable another payment method without any Credit Cards, CC, Bank transfert,... option??
Thanks a lot!
Cheers
Francesco

Magento + Paypal - order status stuck at "Payment review"

I am currently testing the PayPal functionality. I added all the appropriate config information, and the purchase is working perfectly.
Going into the admin panel, all the orders have "Payment review" status (they were made either today or yesterday).
My question is - is it normal to last this long ? If it is, how am I supposed to properly test. If it's not, can anyone give me any tips on how to debug this issue ?
Any information on how the process goes from this point on would be highly appreciated. Anticipated thanks.
Check the PayPal account that you made the purchases on. Do they show completed in there, or do they say pending? If they show completed, it may be possible you did not receive the IPN to update your cart. If they show under review in your test sandbox account, you may have payment review turned on. You could need to go into the details of the transaction within your test sandbox account and manually accept the payment. You can also turn payment review off if it is on. You just need to log into your developer account at developer.paypal.com, click on test accounts. You then should see a column for payment review. If it is enabled, you will just need to toggle it from here.
Since this is quite popular with Google I will add my solution here as well:
I had noticed that many payments would still have the "Payment review" status even after I disabled payment review in my sandbox account.
Turns out that if a payment is made in another than the sandbox account's default currency, it is automatically put into the "Review" status.
To turn this feature off, log into your sandbox account under https://www.sandbox.paypal.com and go to Profile -> More Options -> Payment Receiving Preferences. There you can change the setting for "Allow payments sent to me in a currency I do not hold" to auto-accept such payments.
My problem was transaction status said "Paid" in merchant test (Sandbox) account but IPN response I received had payment status "Pending".
For a new user like me, it was hard to find out how to accept a payment manually when "payment review" is turned on. It took hours for me.
To make it easier for others,
Go to transaction detail -> Click on "More Information" link. Go to bottom of the page. Here you will find "Accept" link just above "Return to My Account" button. Click on "Accept" link and transaction status will change to "Complete".
After that I received IPN response with payment status "Completed"
I hope this helps someone.
This query solved it for me in case of Amazon Sandbox orders which left opened transactions. These popped up in the error log with
The OrderReferenceId XYZ is invalid
each time with Magento's cron scheduler. Basically the same as for Paypal and all other external payment methods which have a sandbox mode:
UPDATE `sales_payment_transaction`
SET `is_closed`=1
WHERE 'S02-XXXXXXX-XXXXXXX' IN (txn_id, parent_txn_id);

Is there anyway of passing a shipping address to Google Checkout?

I'm looking into integrating Google Checkout into our website. At the checkout stage of our website we calculate the delivery cost based on where they are shipping to, however it appears to me that the user could change the shipping address once they reach Google Checkout i.e the user could indicate on our website that they want it shipped down the road, and then at Google Checkout indicate they want it shipped to Australia!
Is there anyway of passing a shipping address across to Google Checkout, and then prevent the user from changing that address? Failing that, is it at minimum possible to pass the shipping address to GC?
Consider using "merchant-calculated shipping".
Merchant-calculated shipping allows you to wait until the buyer selects the shipping address for an order before you determine the availability and cost of different shipping options for that order.
You must provide a callback URL and Google Checkout will call you back with the final shipping address and request from you the available shipping methods and costs.
More info in this doc:
http://code.google.com/apis/checkout/developer/Google_Checkout_XML_API_Merchant_Calculated_Shipping.html
If the order has been placed by this time, you should be OK - from http://checkout.google.com/support/bin/answer.py?hl=en&answer=99746
You may add shipping addresses to your
account or revise them at any time.
Changes cannot be applied to existing
orders; you will need to contact the
seller to request shipping address
updates
And
Any changes you make to your shipping
address are not retroactive -- Once
the order is placed, any changes to
the order must be applied by the
seller. Contact the seller directly
with your request

Resources