PayPal Item(s) w/ Description on Review Page - paypal

Using the PayPal REST api, I'm passing in this to new payments:
transactions: [
{
amount: {
total: "10.00",
currency: "USD",
details: {
subtotal: "10.00"
}
},
description: "My item description."
}
],
Snippet of the actual request
On the PayPal approve page, though, only the subtotal is displayed - nowhere does the description show up, nor do individual item listings - only the subtotal in USD shows up.
How can I make individual items with descriptions in the REST API checkout? I'm using &useraction=commit by the way.

You would need to pass over the line items in the SetExpressCheckout API call that you are making. There is a list of variable that can be passed over in the developers guide. I have checked with our engineers, and this feature has not been pushed live yet. Line items will be supported, but the feature is not yet live with the New REST API's.

Related

How to place an order as guest in eBay Sandbox

Hi I'm trying to place an order on the Sandbox environment as a guest assuming that no Paypal account would be needed to be added for the guest. I'm using the below REST APIs in that order to get this done.
I have a Listing (published offer) with the id 1xxxxxxxxxx4 in sandbox
I called the Order API -> initiateGuestCheckoutSession (Item ID : v1|1xxxxxxxxxx4|0)
I called the Order API -> initiateGuestPayment with below request body
{
"paymentMethodType": "WALLET",
"paymentMethodBrandType": "PAYPAL_CHECKOUT"
}
Got this as part of the response
"providedPaymentInstrument": {
"paymentMethodType": "WALLET",
"paymentInstrumentReference": {
"externalReferenceId": "2QG41254DS871200X"
}
I called Order API -> placeGuestOrder (Session Id : v1|1xxxxxxxxxx4|123365312 )
{ "marketingTerms": [
{"marketingTermsAccepted": false,
"marketingTypes": [ "OFFER", "SURVEY", "PROMOTION" ],
"marketingChannels": [ "EMAIL" ] } ]
}
I'm getting below for response 400 Bad request
{
"errors": [
{
"errorId": 15004,
"domain": "API_ORDER",
"category": "REQUEST",
"message": "If this is a eBay member checkout, this error indicates that the buyer does not have a PayPal account linked to their eBay account. If this is a guest checkout, this indicates that the buyer's credit card information is missing. In both cases, submit the buyer's credit card information."
}
]
}
So I have these questions in mind.
Am I calling the right APIs, in the correct order? or am I missing
something?
How do I add credit card information to this guest buyer?
If I'm to add credit card information to this guest buyer, are there
any TEST Credit cards that could be used for this purpose?
If linking a TEST Paypal to this scenario how should it be done?
To avoid all this can't we set "Cash On Delivery" option for orders?
if so how do you set that?
Thanks in advance, appreciate any help I could get on this matter guys.

How to set category for PayPal Smart Buttons?

When I view the transaction details in Paypal sandbox as buyer, it says "Category: flights".
Is it possible to change that - or is this automatically determined by Paypal? (The documentation only knows about item category physical/digital, but setting this value doesn't change anything.)
My code:
actions.order.create({
purchase_units: [{
"items":[
{"name":"ARGENTINISCHES H\u00dcFTSTEAK","unit_amount":{"currency_code":"EUR","value":"12.50"},"quantity":1,"sku":"FG_001"},
{"name":"Beilagensalat","unit_amount":{"currency_code":"EUR","value":"3.50"},"quantity":1,"sku":"FG_008"}
],
"amount":{
"currency_code":"EUR",
"value":"16.00",
"breakdown":{"item_total":{"currency_code":"EUR","value":"16.00"}}
}
}],
application_context: {
payment_method: {payee_preferred: "IMMEDIATE_PAYMENT_REQUIRED"},
shipping_preference: "NO_SHIPPING"
}
});
This is an account setting, not an integration issue.
You can try editing the category of the sandbox Business account you are receiving the payment with, via https://www.sandbox.paypal.com/businessmanage/account/aboutBusiness -> Update
But since it's sandbox, you can also just not worry about it. The setting in sandbox will not have any relation to any live account this integration ever processes payment with.

How to enable PayPal for Google Pay online

I have got a task to use Google Pay with PayPal in web applications and for that I have gone through numbers of posts over the internet, but not found any well documentation or guide. I have found only google pay codes with payment-gateway mostly and PayPal uses documentation only on PayPal and google blogs, I found that while using it with payment gateway, we don't need any self-created tokenization codes to pass in payment method but when we go with PayPal we must have to use DIRECT token specification method that means we have to create tokenization self for rotation or may be I didn't get it right. My question is that, do we still need public key while working with payment gateway or it belongs to direct method only. I am successfully running payment-gateway integration with test environment but not got any success over PayPal.
While learning about Direct method I understand that we have need to use public key in both payment request and in google pay developer profile but how we can run PayPal in test environment still not found neither any sample nor any success over that.
Below are links I have tried you can use for reference:
https://developers.google.com/pay/api/web/guides/tutorial
https://developers.google.com/pay/api/web/guides/resources/sample-tokens
https://developers.google.com/pay/api/web/reference/request-objects#purchasecontext
https://developers.google.com/pay/api/web/reference/request-objects#gateway
https://developers.google.com/pay/api/web/guides/paymentrequest/tutorial
https://stackoverflow.com/search?page=5&tab=Relevance&q=integrate%20google%20pay
https://developer.paypal.com/docs/archive/checkout/how-to/googlepay-integration/
https://developers.google.com/pay/api/web/guides/tutorial
Here you can see sample of json for payment request in google pay with PayPal.
{
"apiVersion":2,
"apiVersionMinor":0,
"allowedPaymentMethods":[
{
"type":"PAYPAL",
"parameters":{
"purchase_context":{
"payment_intent":"AUTHORIZE",
"purchase_units":[
{
"reference_id":"PUHF",
"description":"Sporting Goods",
"custom_id":"CUST-HighFashions",
"soft_descriptor":"HighFashions",
"payee":{
"merchant_id":"xxxxx"
},
"shipping":{
"method":"United States Postal Service",
"address":{
"name":{
"full_name":"John Doe"
},
"address_line_1":"123 Townsend St",
"address_line_2":"Floor 6",
"admin_area_2":"San Francisco",
"admin_area_1":"CA",
"postal_code":"94107",
"country_code":"US"
}
}
}
]
}
},
"tokenizationSpecification":{
"type":"DIRECT"
}
}
],
"transactionInfo":{
"displayItems":[
{
"label":"Subtotal",
"type":"SUBTOTAL",
"price":"1.00"
},
{
"label":"Tax",
"type":"TAX",
"price":"1.00"
}
],
"countryCode":"US",
"currencyCode":"INR",
"totalPriceStatus":"FINAL",
"totalPrice":"1.00",
"totalPriceLabel":"Total"
},
"merchantInfo":{
"merchantName":"shopgradframes"
},
"callbackIntents":[
"SHIPPING_ADDRESS",
"SHIPPING_OPTION",
"PAYMENT_AUTHORIZATION"
],
"shippingAddressRequired":false,
"shippingAddressParameters":{
"allowedCountryCodes":[
"US"
],
"phoneNumberRequired":true
},
"shippingOptionRequired":false
}
I think we can't use direct method in test environment because this may need merchant details, i have also some doubt over test token given in google blog, you can see that below:
https://developers.google.com/pay/api/web/guides/resources/sample-tokens
I also didn't understand how we can use those test token, do we have to pass it our payment gateway for processing or other stuff.

Include a message/note field in a PayPal API payment

I am building a really simple payment form where the user can enter an amount and a thank you message. I have got it successfully working with just the amount but I cannot get add a message field and get it to come through!
Here is just the payment function of my JavaScript:
payment: function(data, actions) {
return actions.payment.create({
payment: {
transactions: [
{
amount: {
total: window.transactionAmount,
currency: 'GBP'
},
note_to_payee: document.getElementById('custom-message').value,
description: 'A gift to Martin.',
custom: 'This is a test custom field',
payee: {
"email": "martin#[hidden].com"
}
}
]
},
experience: {
input_fields: {
no_shipping: 1,
allow_note: true
}
}
});
},
I have tried setting custom and note_to_payee but neither seem to be recorded on either the notification email or the data that is logged in the recipient's account.
I have also tried turning on the ability for the payer to add a note by setting allow_note: true in the experience config but that does nothing!
Please help, just any way of passing through a little message with the payment is all I need.
It took PayPal Support team 4 days to come back with the answer that No, it cannot be done.
Here's their full response:
With regard to your request, I have to inform you that "note to seller" (allow_note:true) field is only available in the older PayPal payment experience, and is not available in the newer payment experience.
Unfortunately, there's nothing the caller can do at this time to force an old or new experience and we recommend to collect this information in your website where possible.
So it looks like they've dropped one of the nicest and most simple features of the PayPal checkout which was the ability to include a friendly little note.
Now, my only option is to build a whole back-end system with API end-points and extend my JavaScript just to record my payer's note. Meanwhile, every email notification I receive will continue to contain that annoying lie: "The buyer hasn't entered any instructions".
PayPal: Please, either implement a feature in your new process or remove/hide the feature! Don't do a half-way job. You take 10% of all my transactions, I expect better.
A workaround for this would be to use an "option variable" to create a textbox in your checkout flow. An example of an option variable would be "os0" and "on0".
Here is an example on our website on how you would implement this: https://www.paypal.com/us/cgi-bin/webscr?cmd=_pdn_xclick_options_help_outside
https://developer.paypal.com/sdk/js/reference/#onapprove
paypal.Buttons({
createOrder: function(data, actions) {
...
},
onApprove: function(data, actions) {
// This function captures the funds from the transaction.
return actions.order.capture().then(function(details) {
// This function shows a transaction success message to your buyer
alert('Transaction ' + transaction.status + transaction.id);
window.location.href = 'https://www.yoursite.com/page.php?trnsid='+ transaction.id;
});
}
}).render('#paypal-button-container');
You can do a redirect onApprove.
If the transaction was completed redirect the user to a page with a FORM THAT GET/capture the transactionID (associate the message with a transaction) and ADD a MESSAGE TEXTAREA so user can send some notes after payment.

PayPal Adaptive Payments with single item

I have developed a small API that uses PayPal Adaptive Payments to create a chain payment.
Here is my current JSON body that I send to PayPal:
{
actionType: "PAY",
currencyCode: currency_code,
feesPayer: "SECONDARYONLY",
memo: product_name,
receiverList: {
receiver: [{
amount: payment_amount,
email: primary_email,
primary: true
}, {
amount: payment_amount-(0.03*payment_amount),
email: secondary_email,
primary: false
}]
},
returnUrl: "http://example.com/payment-success",
cancelUrl: "http://example.com/payment-cancel",
requestEnvelope: {
errorLanguage: "en_US"
},
trackingId: product_id
}
It works perfectly. The full amount is sent to the primary user, and then 97% of the full amount is sent to the secondary user.
Although, I would like to each of my items so that their quantity is always 1. My site is dynamic and allows users to create items all the time with their own price, name, etc. I would like to mark the item as purchased on my site after someone checks out with PayPal so that no one can buy it again, hence removing the purchase button.
I understand how to do that with Webhooks (provided by PayPal), although what if two or more users press the purchase button on my website and are checking out with PayPal at the same time?
You would need to put your own contorl over the concurrency in this case, as PayPal does not provide this uniqueness validation upon payment attempts in adaptive payments.
Here's how you may put the control in the front-end
Generate a unique invoiceId for each dynamic purchase button on the front-end
Collect the payment details (recievers, amount, invoiceID, etc) with your purchase button, and post the payloads to your API action page (when user submit the purchase button).
In your API action page, validate & save (into database) the invoiceId field to avoid duplicated puschase attempts (placing a status of ordered), and then invoke the PayPal pay API call to generate the PAY-KEY. Put the invoiceId in the payload:receiver object for tracking purpose in the PayPal callback and transaction reports:
receiverList: {
receiver: [{
amount: payment_amount,
email: primary_email,
invoiceId: uniqueId,
primary: true
}, {
amount: payment_amount-(0.03*payment_amount),
email: secondary_email,
primary: false
}]
},
Buyer is redirected with the PAY-KEY and completes the transaction
Webhook/IPN triggered and you'd mark your database entry as purchased
Note on Step#3,
In this flow there're actually 3 status of your purchase button: 1-available, 2-ordered, 3-purchased, this way you have control over it always as a single purchase
Incase buyer drops off(canceling or AFK or closing browser) in Step#4, you may clear the ordered status after 3 hours (PayPal PAY-KEY lifecycle)