Paypal billing agreement does not pay quickly? - paypal

I've made a Paypal plan like the following, at 49$ :
{
'id': 'P-PAYPAL-ID',
'name': "My Plan",
'description': 'My description of the plan',
'type': 'INFINITE',
'merchant_preferences': {
'auto_bill_amount': 'YES',
"initial_fail_amount_action": "CONTINUE",
"max_fail_attempts": "3",
"return_url": "https://example.com/paypal/response",
"cancel_url": "https://example.com/paypal/response"
},
'payment_definitions': [{
'name': 'Monthly payment',
'type': 'REGULAR',
'frequency': 'MONTH',
'frequency_interval': 1,
'cycles': 0,
'amount': {
'value': '49',
'currency': 'USD'
}
}]
}
I've created the plan and enabled it following the documentation here.
Then I created a Billing Agreement by following the steps :
Create the billing agreement
Redirect the user to the Paypal page to accept the agreement
Execute the agreement from the URL I got in 1.
Everything works fine, in my sandbox user account, I can see the "Recurring payment details" marked as Active.
I subscribed my server to the webhooks.
My problem is the following : The payment is not done immediately? I've waited an hour, and nothing is paid!
Is there a request I forgot to make to "execute the executed agreement"...?

The short and sweet answer is that it's not possible. Within the agreement you have the option to set a startDate value. Based on my experience the below statement is what I've concluded.
It looks like the payments just process based on the date being before or after 07:00 UTC of the current date.
For example. The current date time is 2017-05-04T04:50:00.00Z I set my start date to be the current UTC date time plus 30 seconds. Because the agreement date is set to a value greater then the current date time the API doesn't throw an error, but it DOESN'T set your time to be what you specified. Instead it sets it to 2017-05-04T07:00:00Z.
Now, if you have the same date time of 2017-05-04T04:50:00.00Z and instead of adding 30 seconds you add 24hrs you'd think that your time would then be set to be 2017-05-05T04:50:00.00Z. But no, the time will be set to 2017-05-05T07:00:00Z.
So it seems like these just process everyday at 07:00 UTC and you can't specify anything but the date.

Related

PayPal Smart Button transaction not charging after 'approval'

After spending a full day on this dangerous thing, I can't understand how a transaction show APPROVED, I get an order ID, but there is no charge (not for buyer or receiver).
I am on live environment after tested on sandbox successfully.
So the code is long but basically on the server side we first create the transaction:
const request = new paypal.orders.OrdersCreateRequest();
request.prefer("return=representation");
request.requestBody({
intent: 'CAPTURE', //CAPTURE
purchase_units: [{
amount: {
currency_code: currency,
value: finalPrice
},
payee: {
email_address: payee
},
shipping: shipObj
}]
});
and later we approve the order with PayPal :
let request = new paypal.orders.OrdersGetRequest(orderID);
let order;
try {
order = await client.execute(request);
}
catch (err) {
console.error("error",err);
return res.sendStatus(500);
}
At this point i get order.result.status = APPROVED .
This is a live environment (the client and secret keys).
How can you send APPROVED to developer, and give an orderID but not charge ?
This is such a dangerous thing to do and can literally ruin businesses.
So then i found out there is a link to your order ID :
https://api.paypal.com/v2/checkout/orders/4PE63643WC652674S
If you look in this page you get this :
"message":"Authentication failed due to invalid authentication credentials or a missing Authorization header."
Now, only god knows what this means, and this is a failur message on an order ID page, which mean the orderID means nothing ??
So i also check the paypal link with my client-ID (should be identical to my client id in sdk right?) :
https://www.paypal.com/sdk/js?client-id=xxxxxxxxx&merchant-id=xxx#yyyy.com&disable-funding=credit,card&currency=USD
Which seems ok and contains the right email.
Seems like you may have solved the issue and that you were missing the capture step, which is a required step to commit the transaction and must always occur after approval.
Just to review the best ways to integrate, if you are doing so with API calls from a server, you'll want to set make two routes on your server, one for 'Set up Transaction' and one for 'Capture Transaction', documented here: https://developer.paypal.com/docs/checkout/reference/server-integration/
Then, the best JS customer approval flow to pair with those server-side routes is this: https://developer.paypal.com/demo/checkout/#/pattern/server

google tag manager eCommerce

I am getting crazy trying to get this to work.
I am pretty new to the whole Google Tag Manager thing, but after reading documentation, I got the basic google analytics to work.
Having said that, I am trying to set up an eCommerce transactions using dataLayer but I cannot seems to get it to work.
I am using the basic example taken on the main site:
var dataLayer = dataLayer || [];
dataLayer.push({
'ecommerce': {
'purchase': {
'actionField': {
'id': 'T12345',
'affiliation': 'Online Store',
'revenue': '35.43',
'tax':'4.90',
'shipping': '5.99',
'coupon': 'SUMMER_SALE'
},
'products': [{
'name': 'Triblend Android T-Shirt',
'id': '12345',
'price': '15.25',
'brand': 'Google',
'category': 'Apparel',
'variant': 'Gray',
'quantity': 1,
'coupon': ''
},
{
'name': 'Donut Friday Scented T-Shirt',
'id': '67890',
'price': '33.75',
'brand': 'Google',
'category': 'Apparel',
'variant': 'Black',
'quantity': 1
}]
}
}
});
In my GTM configuration, I have the following:
- Tag Type: Universal Analytics
- Track Type: Page View
- Google Analytics Settings: {{gaTrackingID}}
- Enable overriding settings in this tag: ticked
- Enable Enhanced Ecommerce Features: true
- Use Data Layer
and in the Trigger i have:
- Trigger Type: Page view
- Trigger fires on: "Page URL contains /checkout
I forgot to mention that I have two tags enabled, one to log activity on all pages and the second one which should log the purchase.
I can in google Analytics that the visit worked correcty, but the transaction does not.
Also, can someone tell me if the section "CONVERSATIONS -> Ecommerce" displays the standard or Enhanced Ecommerce?
I am a bit confused..
Why the above does not work?
I just found out this morning that the code actually worked, but google analytics takes around 24/48 hours to reflect the changes. this is something I did not read anywhere in most of the documentation I found. This kind of make the whole testing process a bit difficult, as the only thing we can do is to check if the event is fired (as far as I know).
Perhaps there is a better way (and more instant) to test whether an eCommerce data has been pushed to google Analytics?
Try to insert page and transaction information into a single 'ecommerce' object and not separated.
Regarding the data displayed in the ecommerce report in Analytics, it depends on whether you have enabled enhanced ecommerce settings or only those standard.

Paypal shopping cart AMOUNT_ERROR

I am having a issue with a paypal cart since the update around march (bit late but the site is not used yet and we just discovered it now).
I already checked this question but it did not solve the issue for a shopping cart (Paypal : hosted button payments fail with code=AMOUNT_ERROR)
We send a object that contains the request data through a plugin called neo.js, this works fine as far as we know.
This is our data we send to paypal as a js object.
{
amount_1: 10.01,
business: "noreply#domain.com",
cancel_return: "https://dev.domain.com",
charset: "utf-8",
cmd: "_cart",
currency_code: "US",
custom: "username",
item_name_1: "$10 item",
item_number_1: "1",
no_shipping: 1,
notify_url: "https://dev.domain.com/callback/paypal.php",
quantity_1: 1,
return: "https://dev.domain.com",
upload: 1
}
It has to do something with the amount, but using a , instead of . but that only gives a normal error message on screen that the format is incorrect.
We have tried multiple things including the dollar sign and making it a string but nothing seem to be working.
I reproduced the error and it is due to the wrong currency code passed.
You are passing "US" but the currency code (that is a parameter that refers to the AMOUNT as in the error returned) must be of 3 characters as you can see on PayPal guide: https://developer.paypal.com/webapps/developer/docs/classic/api/currency_codes/
Change it to "USD" instead and you will have a working checkout.

PayPal IPN: differentiating successful payment response from unsuccessful

I'm painfully trying to get going with PayPal's IPN system. Via the Sandbox, I've got it processind payments and sending notifications to my IPN listener.
Question: what in the response denotes that the payment was succesful? verify_sign looks promising, but then payer_status says unverified, which is less so. What would this look like if paymeny had failed?
Example response on success (truncated for brevity):
{
"txn_type": "subscr_signup",
"subscr_id": "I-X5CCUV52M245",
"option_selection1": "Some Product",
"residence_country": "GB",
"mc_currency": "GBP",
"item_name": "My Project",
"recurring": "1",
"verify_sign": "AxQ2151HawsltpX50Ic0ERjMvTm2AKxR9ZhaRWhY2vsawH.ST73m1oWR",
"payer_status": "unverified",
"test_ipn": "1",
"payer_email": "xxx#xxx.xxx",
"payer_id": "88F6NGLATYQ3S",
"option_name1": "Subscription options",
"reattempt": "1",
"item_number": "1",
"subscr_date": "11:23:05 May 24, 2016 PDT",
"period1": "2 D",
"mc_amount1": "0.00",
"period3": "1 Y",
"mc_amount3": "10.00",
"ipn_track_id": "1d86661393869"
}
I'm unsure how to mimick a failed payment (e.g. legitimate card details but not enough funds in the account) via the Sandbox (since it's all pretend day) so I don't have anything to compare to.
This is not a payment. It is a signup. All you should do when receiving this message is register the user. You will get another transaction for the payment. Until you do, don't give the new user the permissions concerned, or the product, or whatever it is you're selling.
Note that you can get the payment before or after the signup.

PayPal IPN response not getting a payKey or trackingId?

I'm trying to get the whole PayPal AdaptivePayments#Pay working, that part works. I pass a bunch of stuff in, get a paykey, which I pass to the approval url:
{returnUrl: urls[:return],
cancelUrl: urls[:cancel],
requestEnvelope: {errorLanguage: "en_GB"},
currencyCode: "GBP",
trackingId: self.id,
receiverList: {
receiver: [{email: Rails.configuration.site_paypal, amount: self.amount, primary: true},
{email: self.provider.paypal_email, amount: self.amount, primary: false}]
},
actionType: "PAY",
ipnNotificationUrl: urls[:ipn]}
The server comes back with everything correctly, I redirect to the url, it works, I get the payment in my PayPal sandbox account for Rails.configuration.site_paypal and in the IPN history I see the message but I have no way to identify it as it doesn't contain a paykey or trackingId :(
transaction_subject=
txn_type=web_accept
payment_date=10:06:09 Aug 17, 2012 PDT
last_name=Baldry
residence_country=GB
item_name=
payment_gross=
mc_currency=GBP
business=<Rails.configuration.site_paypal>
payment_type=instant
protection_eligibility=Ineligible
verify_sign=Asu0z613h-fyw8CNuZEjSsMXS58PAi46SzR3IvXXTX5JUizhF8vV4z25
payer_status=verified
test_ipn=1
tax=0.00
payer_email=<customer#email.com>
txn_id=9M582867K79935008
quantity=0
receiver_email=<Rails.configuration.site_paypal>
first_name=Michael
payer_id=M7U3UVA3E65VY
receiver_id=375R229JBE3TY
item_number=
payment_status=Completed
mc_gross=157.00
custom=
charset=windows-1252
notify_version=3.6
ipn_track_id=c9fcf587d770f
What am I doing wrong? Ripping my hair out...
Thanks
There are two types of IPN's
One is generated for the account that receives the money, based on their profile settings (It looks like that is the one you are getting)
The other is generated for the API caller (who may or may not be financially involved in the transaction). The API caller's IPN will include the PayKey.
If the API caller, and one of the receivers are the same, Make sure that you can either differentiate between the two IPN's you will receive, or that you have separate URL's for each. (The API callers is specified when making the API call, the receiver's is specified on the PayPal profile)