Why the data of paypal webhook notify, event_type and resource.status do not match - paypal

I simplified the data structure received from paypal callback, why event_type is PAYMENT.CAPTURE.COMPLETED but resource.status is PENDING
{
"id": "xxxx",
"event_version": "1.0",
"create_time": "2022-05-30T06:17:22.994Z",
"resource_type": "capture",
"resource_version": "2.0",
"event_type": "PAYMENT.CAPTURE.COMPLETED",
// ...
"resource": {
"id": "xxxx",
"status": "PENDING",
"status_details": {
"reason": "PENDING_REVIEW"
}
// ...
},
}

Captured PayPal payments can be under review for many reasons. If the webhook's details aren't enough for you, examine the payment in www.paypal.com and/or have one of the account owners contact PayPal's support.

Related

How Can I make multiple payments in paypal?

I try to use PayPal payments API to provide parrallel payments to the multiple merchants in the single checkout. I want use this on marketplace and I want to make payments from one buyer to several sellers without intermediate account, How Can I do this?
I considered the payouts (https://developer.paypal.com/docs/payouts/integrate/api-integration/#prerequisites), but I can use this way only on my paypal account
"items": [
{
"recipient_type": "EMAIL",
"amount": {
"value": "9.87",
"currency": "USD"
},
"note": "Thanks for your patronage!",
"sender_item_id": "201403140001",
"receiver": "receiver2#example.com"
},
{
"recipient_type": "EMAIL",
"amount": {
"value": "9.85",
"currency": "USD"
},
"note": "Thanks for your patronage!",
"sender_item_id": "201403140001",
"receiver": "receiver#example.com"
}
I want send post like this, for one customer on my website and several seller.

PayPal hide order total

I am using PayPal's REST API to implement paying via PayPal into my website. When I send an approval request to PayPal it always shows the order total. I really don't want to show this. At the point in which we are asking for approval the user won't even know what their total order amount will be. Is there anyway to hide the order total on the PayPal page?
Are you sending line items in your API request? For example:
"item_list": {
"items": [{
"name": "Test",
"sku": "18",
"price": "7.47",
"currency": "USD",
"quantity": "1"
}
]
}
If you send the items array, the price will be displayed in PayPal's payment page.
However, you can just send a total amount, and it won't appear during buyer approval, for example:
{
"intent": "sale",
"redirect_urls": {
"return_url": "http://URL.com/restapi_test/_payments_execute-an-approved-paypal-payment.html",
"cancel_url": "http://URL.com/restapi_test/_payments_create-a-payment-paypal.html"
},
"payer": {
"payment_method": "paypal"
},
"transactions": [{
"amount": {
"total": "7.47",
"currency": "USD"
},
"description": "This is the payment transaction description."
}]
}

Paypal Batch Payout behavior on item error

With the batch payout API for Paypal, if I send a request with multiple items and there is an error with one of them, will the ones without an error still go through? Or will they all fail?
For example, if I sent a payload of:
{
"sender_batch_header": {
"sender_batch_id": "batch_8",
"email_subject": "You have a payment"
},
"items": [
{
"recipient_type": "EMAIL",
"amount": {
"value": 1.0,
"currency": "USD"
},
"receiver": "test_user#example.com",
"note": "Thank you.",
"sender_item_id": "item_1"
},
{
"recipient_type": "EMAIL",
"amount": {
"value": 1.0,
"currency": "USD"
},
"receiver": "bad_email_address",
"note": "Thank you.",
"sender_item_id": "item_1"
}]
}
Will the payout to test_user#example.com go through since the other item has an invalid email address?
Thanks
If you use
"receiver": "bad_email_address",
PayPal will throw out error as "bad_email_address" is not in email format, the whole payout can't go through, no money sent out.
If you use
"receiver": "bad_email_address#email.com",
The email address is not existed, but it's email format, the whole payment will go through, existed PayPal receiver will get the money, this un-existed email transaction will in Unclaimed status. If someone register this email address, then this person will get the money.

PayPal Billing Agreement - No approval_url or redirect_url after creation

I am trying to set up Billing Agreements using PayPal REST API with paypal-rest-api-sdk for Java on PayPal Sandbox. So, far I've been able to create a billing plan and pass it's id to create a Billing Agreement. However, the response that I get after creating a Billing Agreement does not have approval_url and redirect_url. The following is my request
{
"name": "MYOP Recurring Contribution Agreement",
"description": "Agreement for MYOP Recurring Contributions",
"start_date": "2014-12-13T06:26:32Z",
"payer": {
"payment_method": "credit_card",
"funding_instruments": [
{
"credit_card": {
"number": "XXXXXXXXXXXX",
"type": "visa",
"expire_month": 1,
"expire_year": 2015,
"cvv2": 874,
"first_name": "Joe",
"last_name": "Young",
"billing_address": {
"line1": "52 N Main ST",
"city": "Johnstown",
"country_code": "US",
"postal_code": "43210",
"state": "OH"
}
}
}
]
},
"plan": {
"id": "P-85A16162MC374104FU7KAYMQ"
}
}
As a response to my create Billing Agreement request, I receive only the following:
{
"id": "I-77GK9WNNV04U",
"links": [
{
"href": "https://api.sandbox.paypal.com/v1/payments/billing-agreements/I-77GK9WNNV04U",
"rel": "self",
"method": "GET"
}
]
}
When I fetch the created Billing Agreement with a GET request on the agreement id, I receive information about the agreement that has a 'links' array that does not contain approval_url or redirect_url.
I am unable to proceed to send the payer to an approval url to then execute the agreement. Help please.
You are using ("payment_method":"credit_card") Change the ("Payment_method":"PAYPAL")
'{
"name": "T-Shirt of the Month Club Plan",
"description": "Template creation.",
"start_date": "2016-03-31T00:37:04Z",
"plan": {
"id":"'.$plan_id.'"
},
"payer": {
"payment_method": "PAYPAL"
},
"shipping_address": {
"line1": "111 First Street",
"city": "Saratoga",
"state": "CA",
"postal_code": "95070",
"country_code": "US"
}
}';
Thanks
The approval and the redirect url is only applicable when you make the PayPal Payments so that the buyers can login to their PayPal account and approve the transaction .
Since you are making the billing agreement on credit card , the recurring profile will be created right away and need not go thru any redirect url .

PayPal REST API: how to do an immediate payment and without asking for shipping address

I'm trying to use PayPal REST API instead of PayPal Classic API but it seems that the REST API is lacking two features that the Classic API has:
immediate payment: when the user goes to PayPal page show him a "Pay now" button instead of a "Continue" button and "You’re almost done. You will confirm your payment on ..." phrase.
no shipping address: avoid asking the user to confirm his shipping address while on PayPal page (in Classic API is done with NOSHIPPING=1 parameter, if I remember well)
So my question is: is it possibile do perform an immediate payment without asking for shipping address using REST API? Do I have to go back to Classic API?
I provide here a little more informations about how I'm using the PayPal REST API.
I'm using the PayPal REST Java SDK.
This is a sample request:
{
"intent": "sale",
"payer": {
"payment_method": "paypal"
},
"transactions": [
{
"amount": {
"currency": "USD",
"total": "5",
"details": {
"subtotal": "5"
}
},
"description": "This is the payment transaction description.",
"item_list": {
"items": [
{
"quantity": "1",
"name": "Item 1",
"price": "5",
"currency": "USD"
}
]
}
}
],
"redirect_urls": {
"return_url": "http://XXX/handlePayment.jsp?guid\u003dXXX",
"cancel_url": "http://XXX/cancelPayment.jsp?guid\u003dXXX"
}
}
And its response:
{
"id": "XXX",
"create_time": "2014-06-29T08:52:55Z",
"update_time": "2014-06-29T08:52:55Z",
"state": "created",
"intent": "sale",
"payer": {
"payment_method": "paypal",
"payer_info": {
"shipping_address": {}
}
},
"transactions": [
{
"amount": {
"total": "5.00",
"currency": "USD",
"details": {
"subtotal": "5.00"
}
},
"description": "This is the payment transaction description.",
"item_list": {
"items": [
{
"name": "Item 1",
"price": "5.00",
"currency": "USD",
"quantity": "1"
}
]
}
}
],
"links": [
{
"href": "https://api.sandbox.paypal.com/v1/payments/payment/XXX",
"rel": "self",
"method": "GET"
},
{
"href": "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=XXX",
"rel": "approval_url",
"method": "REDIRECT"
},
{
"href": "https://api.sandbox.paypal.com/v1/payments/payment/XXX/execute",
"rel": "execute",
"method": "POST"
}
]
}
While delving through the REST API I came across this
I believe this means you don't have to go about creating any "Profiles" as such, and can just pass them along with the payment call...
Further explanation as requested :)
Below is an example of passing PayPal experience parameters along with a particular payment call using the Client-side JS method for Express checkout.
payment: function(data, actions) {
return actions.payment.create({
payment: {
transactions: [
{
amount: { total: '1.00', currency: 'USD' }
}
]
},
experience: {
input_fields: {
no_shipping: 1
}
}
});
},
Hope that makes enough sense to you guys! :)
Unfortunately, the REST API is still a long ways behind the Classic API with features it provides. These features you mentioned are things I've seen come up quite a bit, and to my knowledge they are not yet available with the REST services.
I personally have stuck with Classic as they provide everything and I really see no advantage to using REST myself. If you happen to be working with PHP (which I always do) you may be interested in my class library for PayPal. It makes all of the Classic API calls very quick and easy for you, and it's available on Packagist so you can use with Composer easily.
The REST API now supports no-shipping with the Payment Experience APIs.
You need to create a web experience profile and supply no_shipping as an input field. Then use the profile ID when creating the payment.
The profile ID doesn't need to be recreated every time.
appreciate that this post hasn't had any activity for a while but...
i hit on the exact same problem and used this post as a start point for my own question:
paypal api: take immediate payment without a shipping address
it's taken a bit of trial and error but i you can create a one off web profile with 'no_shipping' set to 1, store the id that it creates and then pass that in with future payments that don't require a shipping address.
still haven't figured out how to get rid of the 'You're almost done. You will confirm your payment on xxx.' but my payment process is a far better place than it was!
hope this helps someone out there as this no shipping issue is one that a lot of people appear to be hitting with the paypal api...
I tried using the experience section of the API and apart from still not being able to force a locale code have been able to disable shipping and go straight to billing:
payment: {
transactions: [{
invoice_number: document.getElementById("ReqTxt").value,
amount: {
total: document.getElementById("InvoiceAmt").innerText,
currency: document.getElementById("Currency").innerText
}
}]
},
experience: {
input_fields: {
no_shipping: 1
},
flow_config: {
landing_page_type:'billing'
}
}
you can also see this page. It is possible to set the user action in the flow_config section too
For 'Pay Now' instead of 'Continue' on Paypal I use a special param in approval url:
$approvalUrl = $payment->getApprovalLink().'&useraction=commit';
Result:
https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=TOKEN&useraction=commit