how we can use PROFILESTARTDATE in paypal payment form - paypal-sandbox

can we define PROFILESTARTDATE in payPal form like we mention the BILLINGPERIOD and BILLINGFREQUENCY as t3,p3 () in it.

There are two types of recurring payment types:
Subscriptions
Recurring Payments
For difference: PayPal subscription vs recurring?
PROFILESTARTDATE option is only available when you use the recurring payment api.

Related

In Woocommerce API, which hook for a specific order status for a webhook?

I need to subscribe to a webhook that will fire when an order is complete (having been completely paid for). Which webhook will do this?
I've seen there is a woocommerce_payment_complete action, but I imagine this will fire for each payment that is made in the event of there being multiple payments on a single order? e.g. a customer may make a part-payment on credit card 1 and a part payment on credit card 2. Surely each of these will cause the woocommerce_payment_complete event to fire? Or am I missing something in the documentation?
I'm hoping for a webhook like order.complete, which fires when the order is now in the warehouse. Payment is received, and fulfillment can begin. But I'm not seeing such a webhook in the documentation.
Edit:
So I found this link which explains the Woocommerce order lifecycle, which tells me that Processing is the status/event that I am interested in.
However, I'm not seeing this event in the official Webhook reference
What webhook will fire when an order enters this processing status?
Edit 2: (after #LoicTheAztec's answer)
When I try to create the webhook using the WooCommerce API (https://mysite/wp-json/wc/v3/webhooks), with the following payload:
{
"name": "Order Processed",
"topic": "woocommerce_order_status_processing",
"delivery_url": "https://mycallbackapp.herokuapp.com/yo8i78yo"
}
I get back the following 400 Bad Request response:
{
"code": "woocommerce_rest_shop_webhook_invalid_topic",
"message": "Webhook topic is required and must be valid.",
"data": {
"status": 400
}
}
Edit 3:
Finally the topic needs to be topic.woocommerce_order_status_processing
You don't find it because there are some WooCommerce composite hooks and the right one to be used in your case is: woocommerce_order_status_$STATUS_TRANSITION[to\] where $STATUS_TRANSITION is your desired (transition) order status.
So for "processing" order status the hook will be: woocommerce_order_status_processing
or for "completed" order status your hook will be woocommerce_order_status_completed.

WooCommerce Subscriptions - Action on initial payment

I am using the WooCommerce subscriptions plugin, in particular the woocommerce_subscription_payment_complete function.
I am using it like this:
add_action('woocommerce_subscription_payment_complete','subscription_created');
function subscription_created($subscription) {
echo 'Run when subscription payment is complete';
}
This works, but it also fires when a renewal payment completes. Does anybody know of a way to determine if the payment was for an initial subscription payment rather than a renewal?
You could use woocommerce_checkout_subscription_created, however the problem here is that it will fire before payment is processed - and I'm assuming you need to fire your even after payment has been successful.
One way to approach this is to set meta on the subscription post, that denotes whether your custom function has been run, and checking that meta with an if statement like this:
add_action('woocommerce_subscription_payment_complete','subscription_created');
function subscription_created($subscription) {
//check if meta exists/is not true
if (!get_post_meta($subscription->id, 'has_my_function_run', true)) {
//update meta to bool(true)
update_post_meta($subscription->id, 'has_my_function_run', true);
//run your function
echo 'Run when subscription payment is complete';
}
}
I am sure there is a better way to approach this though, so keep an eye out for other answers. It might be a good idea to look into hooking into woocommerce_order_status_processing, checking if it contains a subscription product, and then running your function, but that won't work if WooCommerce generates a new order for every subscription renewal.

Google analytics api Get the userID / ClientID

I want to get the usage data of my customer out of google analytics, to make some usability analysis with it. For this, I need something that I can determine, which event was done by which user. Is there a possibility in a google analytics api to get this two parts linked?
You could add a user ID as a custom dimension, you'd probably want to set the scope to user.
https://support.google.com/analytics/answer/2709828?hl=en
This would allow you to connect up which users performed which actions.
Of course you can! :) I have used it in a lot of projects.
https://developers.google.com/analytics/devguides/collection/analyticsjs/sending-hits
Example:
ga('send', {
hitType: 'event',
eventCategory: 'Video',
eventAction: 'play',
eventLabel: 'cats.mp4'
});
Since clientId has been made available through the API as ga:clientId you can use this value.
I would recommend using a custom User Id though - setting you own generated User Id in the script using the Universal Analytics User ID feature and in your backend db.
Also add the id to any link you send to your clients via email/sms/etc. that lands on your homepage to follow up on marketing performance.
You would need to have some javascript that grab the id and set it on the pageview. (like Linker, but adjusted for user id)
Note to anyone using the Universal Analytics User ID feature The values returned in ga:clientId is actually the userId Even more interessting. (As of time of writing) GA fails if you request clientId from a User ID view. So you should use a non-User ID view to get the User ID. :)

Not able to create source in stripe with type 'sepa_debit'

I am trying to integrate the Sepa payment method with a woocommerce store.
In test mode when I try to create the source with type sepa debit,
it gives me following error. The code I am using is as follows and same as in the documentation.
Stripe.source.create({
type: 'sepa_debit',
sepa_debit: {
iban: 'DE89370400440532013000',
},
currency: 'eur',
owner: {
name: 'Jenny Rosen',
address: {
line1: 'Nollendorfstraße 27',
city: 'Berlin',
postal_code: '10777',
country: 'DE',
},
},
}, function(status,response){
console.log(status);
console.log(response);
});
According to this post here:
SEPA Direct Debit payments are available to Europe-based Stripe users in a closed preview. In order to activate SEPA Direct Debit, you will need to request an invite through your Stripe Dashboard.
However I am not able to find out from where I can request the invite for Sepa Debit in my Stripe Dashboard.
I am based in India so do I need to have a different stripe account? Or am I missing something?
Before you can begin accepting SEPA Direct Debit payments, your Stripe account needs to have a few months history of processing card payments.
( source: https://stripe.com/docs/sources/sepa-debit -> in the green header )
Apparently, they also disable this in test mode..
For try the source type "sepa_debit" on an IBAN Element is indifferent if you are in live or test mode, the only requisite is enable the option "SEPA Direct Debit" under Payment Settings section which is based in "invitation list" mode.
As they write:
SEPA Direct Debit payments are available to Europe-based Stripe users
in a closed preview. In order to activate SEPA Direct Debit, you will
need to request an invite through your Stripe Dashboard.
And as second condition:
Before you can accept SEPA Direct Debit payments, your Stripe account
needs to have regularly processed card payments for 30 days. SEPA
Direct Debit payments are also subject to processing volume limits,
and payments can fail if you exceed your limits. If you are a new
customer or plan to process a high volume of transactions, please get
in touch to request a review.
When you get accepted, you can try in live/test mode with your public and secret keys. Until you get accepted, you can use ONLY the public keys as demo which are showed in stripe docs as merchant demo, like for example this key (could be changed in future):
// Note: this merchant has been set up for demo purposes.
pk_test_6pRNASCoBOKtIshFeQd4XMUh

Removing payment gateways from WooCommerce

I have a WooCommerce shop (running local) but I want to remove the payment gateways. The customer should be able to place an order without paying any cent, I will send them an invoice manually.
I can not really find where to disable this, it seems not to be standard in WooCommerce.
Have tried disabling all the payment gateways in the backend, but you have to leave one payment gateway enabled.
Thanks in advance!
Just add this line in functions.php in your theme:
add_filter('woocommerce_cart_needs_payment', '__return_false');
Leave 'Cash on Delivery' enabled, and it won't take a payment at the checkout. You can easily change the 'Cash on Delivery' titles and labels to something like 'No Payment Required' or similar.
Something that the other answers to this question haven't addressed is the fact that you need a way for the customer to eventually pay the invoice. Using Cash on Delivery (renamed to suit your needs) perfectly accomplishes not having the user actually pay at checkout, but the problem is that if Cash on Delivery was your only payment method, it will still be the only payment method when you send them the invoice.
I think in most cases you're going to want only cash on delivery during the cart checkout, and a different payment method (like Stripe) for the invoice payment method.
Here's the full workflow to create a deferred payment setup.
Like #crdunst mentions, you should use Cash on Delivery and rename
it to "Wait for Invoice" or something.
Enable all of the payment gateways that you ever want to use (in this example, we'll just use Cash on Delivery and Stripe. Cash on Delivery will be our "checkout" payment gateway, and Stripe will be our invoice payment gateway.
Use the following filter to turn on and off gateways based on whether or not you're on the order-pay endpoint (the page used for invoice payments).
/**
* Only show Cash on Delivery for checkout, and only Stripe for order-pay
*
* #param array $available_gateways an array of the enabled gateways
* #return array the processed array of enabled gateways
*/
function so1809762_set_gateways_by_context($available_gateways) {
global $woocommerce;
$endpoint = $woocommerce->query->get_current_endpoint();
if ($endpoint == 'order-pay') {
unset($available_gateways['cod']);
} else {
unset($available_gateways['stripe']);
}
return $available_gateways;
}
add_filter( 'woocommerce_available_payment_gateways', 'so1809762_set_gateways_by_context');
Of course, if you're using a gateway other than stripe for the order-pay page, you'll want to make sure that you update unset($available_gateways['stripe']); to the proper array key.
After that, you should be good to go! Your site will now display different gateways based on whether or not you're on the invoice pay page!
Other option would be using BACS payment method, where you could explain the client that he will be invoiced later.
You can even add some info at the email that is sent when BACS is used.

Resources