PayPal\Api\Payment - getState() - paypal

I have a question regarding states:
The API says the following:
getState( )
The state of the payment, authorization, or order transaction.
The value is:
created: The transaction was successfully created.
approved: The buyer approved the transaction.
failed: The transaction request failed.
–––
What does approved actually mean ?
Is the money already on my PayPal account ?
Can it be canceled by the Payer after the status is approved (fraud) ?
The question is now, is it safe to ship the product when the status is approved?
Is that enough or do I need to use a Webhook or IPN ?
Here is an example response for my current sandbox setup:
https://gist.github.com/daslicht/795dceae24740d5ca3330cd2066c38bb
And then here:
https://gist.github.com/daslicht/795dceae24740d5ca3330cd2066c38bb#file-gistfile1-txt-L65
There is another state which says "completed"
~ Marc

Finally Paypal Answered my Question:
The "approved" state just means the buyer logged into their account and approved the payment. You still need to execute the payment request, which once you do check the "state" shown in the "related_resources" section and it should say "completed", which indicates the transaction amount has been captured. The "id" shown below is the transaction identifier.
"related_resources": [
{
"sale": {
"id": "6CP443382P136134L",
"state": "completed",
"amount": {
"total": "7.47",
"currency": "USD",
Hope that helps someone else and saves time waiting for a response from paypal

Related

Paypal Missing Payer Address with Orders API V2 / Sandbox

I am setting up a payment integration with PayPal Checkout Buttons and Paypal Orders API V2, which I test in the sandbox environment (no fancy shop system in use).
When an order is paid and status is completed, the Paypal Orders API V2 returns a valid response, but I do not completely receive the payer address from my sandbox buyer account.
Payer looks like this:
"payer": {
"name": {
"given_name": "<given_name>",
"surname": "<surname>"
},
"email_address": "<email>",
"payer_id": "HEU6X43KU231",
"address": {
"country_code": "DE"
}
}
but the payer definition says that the payer should also contain:
address_line_1,
address_line_2,
admin_area_1,
postal code
I would like to use this information to send an invoice to the customer after payment is completed.
First, I thought, the address information is not available in my sandbox buyer account, because you do not find this information in the paypal dashboard (in the details of the respective sandbox account), but the address information is available at https://www.sandbox.paypal.com/businessprofile/settings/address
The whole thing would work with a shipping address, but this look like conceptual mismatch. My order item has the "category": 'DIGITAL_GOODS' and I've set the "shipping_preference": 'NO_SHIPPING', because I sell a digital product, which is automatically delivered after the payment process.
As a workaround I could also ask for the address information in the dialog in our part of the order process (in our GUI, before checkout), and prefill the paypal payment dialog with the userdata entered in our GUI, but in terms of user experience I would prefer to use the paypal data.
Does someone have a clue how to receive the payer address data?
Thanks a lot in advance
I will get the documentation clarified.
But to just answer your question, by default the address of the payer is not shared, just the country_code - to get the complete payer.address you will need to call your account manager or merchant support and they can enable it for your account if you meet their criteria.

PayPal Rest API - Sandbox Recurring Subscription Webhook Notifications

I am implementing recurring subscriptions using the Paypal Rest API. In Sandbox mode, I subscribed to all Webhook events, with the the target in mind that I will receive notifications such as when the plan and agreement are created, as well as when the recurring billing takes place. Whilst I am receiving the notifications for the plan and agreement, I am not receiving any notifications for the daily billing that is supposed to take place. The 'payment_definitions' section of the: Billing Plan created notification can be seen below. It clearly states that the frequency is: Day and frequency_interval is 1.
"payment_definitions": [
{
"name": "Standard Plan",
"type": "REGULAR",
"frequency": "Day",
"frequency_interval": "1",
"amount": {
"currency": "EUR",
"value": "40"
},
"cycles": "11",
"charge_models": [],
"id": "PD-01A711327R015545F37WM7QI"
}
],
I was under the impression that a notification such PAYMENT.SALE.COMPLETED can and should be used in the Webhook listener to extend the user's subscription on a monthly basis (I am using 'DAY' frequency just for testing purposes, for the time being).
Is this the way it should work? Perhaps, there should be no Webhook notification when the scheduled billing takes place? Perhaps such a model is what should be used: a yearly subscription is given, and if no cancelled notification takes place it is simply left to run out its course?
Or does it just not work in Sandbox, perhaps? Note than in the Webhook logs within the PayPal developer, the only notifications present are related to Billing Plan Created and Billing Subscription Created. There are several instances done on the 17th and 19th April, so there should have been at least 4 notifications of daily billing ever since.

Can I sell PayPal product with BlueSnap and charge it later that day for additional cost?

I use BlueSnap API to sell products, using PayPal. In my website, I send the shoppers to PayPal without them filling-in any shipping details - once they log in to PayPal I get those details from their BlueSnap account.
But the problem is that I don't know where the shoppers are located before sending them to PayPal, so there's the issue of shipping and tax that may need to be added on top of the product price.
Is there any way for me to send the shopper to PayPal for a certain amount – let's say $50 - and later according to the shipping details add a $7 surcharge without the shopper re-approving the deal?
I usually use this Payment API call:
{
"amount": 50,
"softDescriptor": "My SD",
"currency": "USD",
"paypalTransaction": {
"cancelUrl": "http://www.cancelURL.com",
"returnUrl": "http://www.returnURL.com"
},
"transactionFraudInfo": {"fraudSessionId": 1234}
}
There's no obvious spot for potential surcharge, so I'm not sure if that's even possible – and what are the limitations? I read this documentation and couldn't get a clear picture. https://developers.bluesnap.com/v8976-JSON/docs/create-paypal-transaction
I'd appreciate any help!
BlueSnap has a few flows to handle PayPal purchases – and from what you're describing, it looks like the split-step PayPal flow should work for you. When you send the request via the API, simply send this (POST):
{
"merchantTransactionId": "mysurchagetransaction",
"softDescriptor": "SOFTDESC",
"amount": "50.00",
"currency": "USD",
"payerInfo": {
"firstName": "John",
"lastName": "Doe"
},
"paypalTransaction": {
"transactionType": "AUTH_ONLY",
"returnUrl": "http://www.returnURL.com",
"cancelUrl": "http://www.cancelURL.com",
"maxAmount": "70.00"
}
}
The $70 is your limit – you can go as high as 40% more than the amount, otherwise BlueSnap will not allow the transaction. The idea is that at this point, you want to send the Shopper to PayPal for a $50 purchase – but you expect a potential surcharge once you know where they're from, up to $70 potentially. The response to this API call will include the order ID (keep it for later!), as well as the usual redirect link to PayPal. Your shopper will be redirected there, approve $50 and then be redirected again to your returnURL (your website).
When the shopper returns, you get a BlueSnap shopper ID – and it will have all the shipping data taken from PayPal. To look at the data, you can retrieve the shopper the usual way: https://developers.bluesnap.com/v8976-JSON/docs/retrieve-vaulted-shopper.
Now comes the second step, which is recommended to take place within a few hours (PayPal has a time window). You consider the shopper's shipping address for tax/shipping surcharges, and then you send this capture funds API call (PUT):
{
"amount": "58.00",
"currency": "USD",
"paypalTransaction": {
"orderId": "4006145",
"transactionType": "CAPTURE"
}
}
Note that you chose to charge $58, so you didn't use your full $70 max amount. That's fine, and the shopper will have no record in PayPal of the $70 you considered charging – just the $58. Also, the shopper didn't have to re-approve the purchase, or login again to PayPal. Although it isn't mandatory, I would recommend you tell the shopper the amount you plan to charge when they return to your website – if it's applicable to the flow of your site.
I hope I helped!

Can I sell PayPal pre-paid products on BlueSnap? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have an account with BlueSnap, where I offer my shoppers to buy using PayPal. I use the payment API when I send credit card orders, and in that I can separate Authorization and capture like this:
{
"amount": 100,
"vaultedShopperId": xxxx1240,
"recurringTransaction": "ECOMMERCE",
"softDescriptor": "MYSOFT",
"currency": "USD",
"cardTransactionType": "AUTH_ONLY"
}
And capture later with this:
{
"cardTransactionType": "CAPTURE",
"transactionId": xxxxx77363
}
But I don't know how to do this for PayPal transactions. The reason I need delay the capture is because I want to sell a pre-ordered item, and I don't want to charge the shopper in PayPal until I get the product ready to ship.
I'm using the Payment API, and I wasn't sure how I can separate the purchase to two stages/phases. I looked in the documentation and I couldn't find a simple answer. Is there a way to do this?
BlueSnap has a few ways to interact with PayPal. Through the Payment API they have three flows, each for a specific scenario:
the standard flow is used for the basic PayPal purchase.
split-step flow is where you first send a shopper to PayPal and authorize the payment and capture later that day.
delayed capture is where you send the shopper to PayPal, then create a pending order in PayPal - and you can capture the funds months later.
For the problem you're describing, it sounds like the delayed capture flow is the best fit.
The full API is here: https://developers.bluesnap.com/v8976-JSON/docs/update-paypal-transaction, and https://developers.bluesnap.com/v8976-JSON/docs/create-paypal-transaction.
You can start off by sending a create order request (via POST):
{
"merchantTransactionId": "testtransaction1",
"softDescriptor": "ABC COMPANY",
"amount": "100.00",
"currency": "USD",
"payer-info": {
"firstName": "John",
"lastName": "Doe"
},
"paypalTransaction": {
"transactionType": "SET_ORDER",
"returnUrl": "http://www.returnURL.com",
"cancelUrl": "http://www.cancelURL.com",
"maxAmount": "120.00"
}
}
After this is sent the response will include a PayPal redirection URL and the BlueSnap order ID (save for later). Send your shopper there.
After the shopper has returned from PayPal and you are sure you want to set a pending order (and for how much) send this request (via PUT):
{
"amount": "105.00",
"currency": "USD",
"paypalTransaction": {
"orderId": "4006145",
"transactionType": "DO_ORDER"
}
}
The order ID in this request was provided in the first step. Now you can wait until your product has arrived and is ready for shipping. Once it's shipped (which can be weeks after step 2) you can send the capture request to get the money (via PUT):
{
"amount": "104.00",
"currency": "USD",
"paypalTransaction": {
"orderId": "4006145",
"transactionType": "CAPTURE"
}
}
Note: you cannot capture for more money than you send in step 2 - so consider the potential surcharges when you're creating the pending order!
Hope it helped :)

Paypal : We are not able to process payment using PayPal account at this time. Please return to the merchant

I'm trying to accept Paypal payments and i used Express Checkout C# SDK.
But when i'm trying to do a payment, i'm getting a paypal page with this message
"We are not able to process payment using PayPal account at this time. Please return to the merchant" and a button to return to merchant site (cancel url)".
Automatically created accounts (country FR) are not working so i tried to create US accounts not working too. All my accounts are verified.
I tried also to clean my browser cookies (see this post)
Does anyone have a guess ?
Thanks
I am having a similar problem. What I noticed is that if the buyer test account only has a credit card as funding option, then I get the error as soon as I login with the test account. If, on the other hand, the test account also has a Banking Account funding option, then the login succeeds, but I can only choose the Banking Account option and not the credit card to complete the payment.
If in your case you don't need to test the credit card option, perhaps this could be a solution.
Also, on the official PayPal documentation I read that, in order to accept credit cards, you need to upgrade the business account to a Pro account:
https://developer.paypal.com/docs/classic/lifecycle/sb_about-accounts/
I tried that, but it did not help in my case
The simple solution is add "allowed_payment_method": "INSTANT_FUNDING_SOURCE"
"transactions": [
{
"amount": {
"total": data.grandTotal,
"currency": "AUD",
"details": {
"subtotal": (data.subTotal - totalDiscount).toFixed(2),
"shipping": data.shipping,
"handling_fee": data.handling,
"insurance": data.insurance
}
},
"description": "My orders",
"payment_options": {
"allowed_payment_method": "INSTANT_FUNDING_SOURCE"
},