How to enable PayPal for Google Pay online - paypal

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.

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.

Google Action sends response as "Sorry Something went wrong. Please try again later." in the Transaction flow

I am using the orders version 2 APIs of Physical transaction using Google Pay and using Stripe as the payment gateway.
While testing the app using Stripe test publishable I am able to make transactions successfully but when I use the Stripe Live publishable key to generate the chargeable token from Google, the assistant replies with "Something went wrong. Please try again later.". This is happening when I make the conv.ask(new TransactionDecision({})) call.
I get the same response using either of the keys when I disable the Sandbox in the action console simulator.
This response has no error attached with it so I am unable to figure out the cause.
Here is the code-
conv.ask(new TransactionDecision({
orderOptions: {
requestDeliveryAddress: false,
},
paymentOptions: {
googleProvidedOptions: {
prepaidCardDisallowed: false,
supportedCardNetworks: ['VISA', 'AMEX', 'MASTERCARD'],
tokenizationParameters: {
// Tokenization parameter data will be provided by
// a payment processor, like Stripe, Braintree, Vantiv, etc.
parameters: {
'gateway': 'stripe',
'stripe:version': '2019-05-16',
'stripe:publishableKey': process.env.CS_ENV === 'prod' ? process.env.STRIPE_LIVE_PUBLISHABLE_KEY : process.env.STRIPE_TEST_PUBLISHABLE_KEY
},
tokenizationType: 'PAYMENT_GATEWAY',
},
},
},
proposedOrder: order,
}));

Paypal Smart Payment Buttons and create subscriptions give me a RESOURCE_NOT_FOUND error

I'm using a Sandbox and I created a paypal plan with Paypal PHP SDK and activated it.
I'm following the integration guide to create a subscription to this plan (https://developer.paypal.com/docs/subscriptions/integrate/#4-create-a-subscription).
But when I clic on the yellow button I have a Javascript Error in the console :
Error: Create Subscription Api response error:
{
"name": "RESOURCE_NOT_FOUND",
"message": "The specified resource does not exist.",
"debug_id": "23912dc1195d",
"details": [
{
"issue": "INVALID_RESOURCE_ID",
"description": "Requested resource ID was not found."
}
],
"links": [
{
"href": "https://developer.paypal.com/webapps/developer/docs/api/#INVALID_RESOURCE_ID",
"rel": "information_link",
"method": "GET"
}
]
}
I checked if the plan exists and it's OK with the Paypal PHP SDK.
Here is the Javascript code used :
<script src="https://www.paypal.com/sdk/js?client-id=sandbox_paypal_client_id&vault=true"></script>
<div id="paypal-button-container"></div>
<script>
// paypal.Buttons().render('#paypal-button-container');
paypal.Buttons({
createSubscription: function(data, actions) {
return actions.subscription.create({
'plan_id': 'P-8N6112936N290211KKMN5MZI'
});
},
onApprove: function(data, actions) {
alert('You have successfully created subscription ' + data.subscriptionID);
}
}).render('#paypal-button-container');
</script>
In the paypal developer dashboard I see the API call for this action, but in orange...
Thanks in advance for your help.
I also ran into this problem. My confusion when following the Subscriptions Integration instructions was that I thought the SDK would work with Subscription Plans (API endpoint /billing/plans), but at the time of writing it doesn't (at least the PHP and .NET versions) - the SDK only works with the older Billing Plans (/payments/billing-plans) which are very similarly named (Plans for short).
As #giannisrig says, you have to call the Subscription Plans part of the API directly (/billing/plans). I hope they'll update the SDK soon - this seems like an important missing feature.
In addition to what Harvey Kadyanji said make sure that:
The Plan is in active state
That the plan was created through the Subscriptions API and Catalog Products API
If you are following the steps provided from paypal in this link:
https://developer.paypal.com/docs/subscriptions/integrate/ you will have to use the Subscriptions API to create the Plans and not the Billing Plans and Billing Agreements APIs.
Use the sandbox business account associated with the sandbox client ID you're using and make the paypal smart subscription or plan through there. The planId and clientId need to belong to the same sandbox account.
I had the same problem and the following solved my issues:
Make sure the sandbox_paypal_client_id provided is valid
Make sure the plan_id exists
Add the plan name in the request e.g.
{
'plan_id': 'P-8N6112936N290211KKMN5MZI',
'name': 'Monthly plan'
}
Probably you are loading the button script with "client-id=sb" or no client id specified. In order to work with plans you created via API you need to explicitly set "client-id" to the client-id of your REST SDK app when loading the script. Then the buttons will find your created plan.
I also answered to basically the same problem in the PayPal community forum

Does PayPal Rest API have the classic useraction equivalent

Is there a way to skip the 2 step confirmation process using the PayPal REST Api?
I've successfully implemented the standard process using the PayPal REST api, which takes the user to the PayPal site where they enter their credentials and then get presented with the order summary with the option to "continue" With the text - "youre almost done. You will confirm your payment on xxxx store".
Is there a way we can skip this step - so not returning the user to my site where they then again have to review the order and select "make payment", but rather display the "pay now" button at PayPal, which will execute payment?
I've searched, and the classic API seems to handle this by adding the url parameter, useraction commit. If only I could find an equivalent for the REST api.
I had the same problem and I got an answer from the PayPal support.
TL;DR: Just append &useraction=commit to the approval_url.
They told me the REST API redirection URL is a regular Express Checkout redirection URL and therefore you can use the same parameter.
If you do a payment API call like:
curl -v https://api.sandbox.paypal.com/v1/payments/payment
-H "Content-Type:application/json"
-H "Authorization:Bearer ACCESS_TOKEN_HERE"
-d '{
"transactions": [{
"amount": {
"currency":"USD",
"total":"12"
},
"description":"creating a payment"
}],
"payer": {
"payment_method":"paypal"
},
"intent":"sale",
"redirect_urls": {
"cancel_url":"https://devtools-paypal.com/guide/pay_paypal/curl?cancel=true",
"return_url":"https://devtools-paypal.com/guide/pay_paypal/curl?success=true"
}
}'
You will get the following response:
{
"id":"PAY-XYZ",
"create_time":"2015-02-26T15:14:27Z",
"update_time":"2015-02-26T15:14:28Z",
"state":"created",
"intent":"sale",
"payer":{
"payment_method":"paypal",
"payer_info":{
"shipping_address":{
}
}
},
"transactions":[
{
"amount":{
"total":"12.00",
"currency":"USD",
"details":{
"subtotal":"12.00"
}
},
"description":"creating a payment",
"related_resources":[
]
}
],
"links":[
{
"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAY-XYZ",
"rel":"self",
"method":"GET"
},
{
"href":"https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-FOOBAR",
"rel":"approval_url",
"method":"REDIRECT"
},
{
"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAY-XYZ/execute",
"rel":"execute",
"method":"POST"
}
]
}
In this response you get the approval url
https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-FOOBAR
and you just have to programmatically extend it with the parameter &useraction=commit.
So you redirect your user to
https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-FOOBAR&useraction=commit
Examples are from the PayPal Developer Tools.
This use case does exist on the REST side of things, but currently only available via the Mobile SDKs. For more details look into https://developer.paypal.com/docs/integration/mobile/make-future-payment/
When users are paying with PayPal in web, redirection to PayPal is still necessary in the REST ecosystem.

PayPal REST API 500 internal service error only in live

I am using the Paypal PHP REST API SDK, but I can reproduce the problem using curl too. I am able to get a token without a problem. This only occurs when I'm submitting a live payment. I can switch to sandbox and submit an identical payment successfully.
As you can see below this is a very basic payment. I don't see how there could possibly be a problem with the information being submitted.
I have no shortage of debug IDs since this happens every time, but here is the last one I got: 049eee254433f
{
"intent":"sale",
"payer":{
"payment_method":"credit_card",
"funding_instruments":[
{
"credit_card":{
"type":"visa",
"number":"(removed)",
"cvv2":"(removed)",
"expire_month":"1",
"expire_year":"2016",
"first_name":"(removed)",
"last_name":"(removed)"
}
}
]
},
"transactions":[
{
"amount":{
"total":"11.98",
"currency":"USD"
}
}
]
}
The issue, according to the debug ID, is that you are not sending the billing address along with the card information. The option to include/not include the billing address with your request is based upon your merchant account setup. In order to rectify the above error, please provide the billing address in your request.
https://developer.paypal.com/webapps/developer/docs/api/#creditcard-object