Can I get payer_id with "Login with Paypal"? - paypal

I'm integrating Log In with PayPal - JavaScript Button.
https://developer.paypal.com/webapps/developer/docs/integration/direct/log-in-with-paypal/js_button/
I need "payer_id" of the user who logged in with paypal.
But it's NOT included in a response.
A response of "4. Get User's PayPal Profile Data" in above integration guide is like this :
{
"family_name":"Ito",
"name":"Gen Ito",
"account_type":"BUSINESS",
"given_name":"Gen",
"user_id":"ttps://www.paypal.com/webapps/auth/identity/user/xxxxxxxxxxxxxxxxx",
"verified_account":"true",
"language":"ja_JP",
"zoneinfo":"Asia/Tokyo",
"locale":"ja_JP",
"email":"xxx#xxx",
"account_creation_date":"2011-11-18",
"birthday":"1982-08-02",
"age_range":"26-30"
}
"payer_id" is listed in below, so I thought payer_id is available.
https://developer.paypal.com/webapps/developer/docs/api/#get-user-information
Can I get payer_id with "Login with Paypal" ?
Then should I use another/other request ?

you need to submit a support ticket at www.paypal.com/mts and request access to this attribute.

Related

Paypal - "ID token context does not have required scope" error when trying to render paypal button using saved payment info

I have been trying to save customer payment details on a site, so that if a customer is logged in they can pay with a single click, instead of having to log in to paypal. To do so I have been following the official paypal guide: https://developer.paypal.com/beta/vault/during-purchase/js-sdk/paypal/
I was able to successfully save payment details. The problem is that when I try to use the saved customer_id to use those saved payment details, I get the following error: "Error: cannot get vault - ID token context does not have required scope".
What I did was the following:
Generate an id_token and access_token by sending a request to https://api-m.sandbox.paypal.com/v1/oauth2/token and specifying response_type=id_token
When rendering the paypal button, pass the generated id_token to the script tags data-user-id-token attribute.
I click the paypal button on the website. This sends a request to my backend server which generates an order by sending a request to https://api-m.sandbox.paypal.com/v2/checkout/orders/. When generating the order I use the generated access_token as a Bearer token in the "Authorization" header, as well as pass the following payment_source.paypal configuration:
"paypal": {
"attributes": {
"vault": {
"store_in_vault": "ON_SUCCESS",
"usage_type": "MERCHANT",
"customer_type": "CONSUMER"
}
}
I get an order id in the response. I pass this order id back to the client side, where the paypal sdk initates a payment flow using this id.
I finish the payment flow, and on success call my server's captureOrder endpoint. This calls https://api-m.sandbox.paypal.com/v2/checkout/orders/$id/capture, where $id is the orderID used before. I also pass the Beares access_token generated in the first step. This request returns a response containing a generated user ID that looks something like this: 560837847
I send another request to https://api-m.sandbox.paypal.com/v1/oauth2/token, this time passing a target_customer_id parameter in the request's body. The value of the parameter is the customerId generated in the 5th step.
I render the page with the paypal button again, this time passing the new id_token to the script tags data-user-id-token attribute.
The error "Error: cannot get vault - ID token context does not have required scope" appears in the developer tools console.
I have turned on "Accept payments" on the Paypal developer console as well as Vault functionality:
The id_token generated in the 6th step has the following scopes:
https://uri.paypal.com/services/invoicing
https://uri.paypal.com/services/vault/payment-tokens/read
https://uri.paypal.com/services/disputes/read-buyer
https://uri.paypal.com/services/payments/realtimepayment
https://uri.paypal.com/services/disputes/update-seller
openid
https://uri.paypal.com/services/payments/payment/authcapture
https://uri.paypal.com/services/disputes/read-seller
Braintree:Vault
https://uri.paypal.com/services/payments/refund
https://api.paypal.com/v1/vault/credit-card
https://api.paypal.com/v1/payments/.*
https://uri.paypal.com/payments/payouts
https://uri.paypal.com/services/vault/payment-tokens/readwrite
https://api.paypal.com/v1/vault/credit-card/.*
https://uri.paypal.com/services/shipping/trackers/readwrite
https://uri.paypal.com/services/subscriptions
https://uri.paypal.com/services/applications/webhooks
I cannot find any information online about what else I should do to make this work.

PayPal API login error - "Sorry, we can't log you in.."

I am using the paypal api login with this:
paypal.use( ['login'], function (login) {
login.render ({
"appid":"myAppID",
"authend": "sandbox",
"scopes":"email",
"containerid":"lippButton",
"locale":"en-us",
"returnurl":"myReturnUrl"
});
});
when I click on lippButton paypal opens with forms for email and password. When they are filled in I get the error:
Sorry, we can't log you in. If you think there's a problem with your
account, contact us and we'll help resolve it.
Even though If I redirect the user to login/complete payment it is fine. Any ideas as to what the problem is?
EDIT:
Seems like it may just be the sandbox api is down. I went here:
https://devtools-paypal.com/guide/openid/php?success=true&env=sandbox
and clicked "Try it" then clicked on the link for step 2, which pops up an identical login form that I am using and the error message persists there as well.
EDIT:
Can anyone explain how I can log in to paypal, but not from their sandbox using my paypal credentials?
I found the problem. For anyone in the future with this same problem (I'm assuming many will because it is directly following their walk through), you seem to not be able to log in via "sandbox" mode (even though their provided code sample has authend: "sandbox" in it).
Simply put in your live credentials INSTEAD of your sandbox credentials. The log in should look like this (There should be no 'authend: "sandbox"' now):
paypal.use( ['login'], function (login) {
login.render ({
"appid":"myAppID", //Use your live client ID, not your sandbox client ID.
//No authend needed.
"scopes":"email",
"containerid":"lippButton",
"locale":"en-us",
"returnurl":"myReturnUrl"
});
});
And the login now works and allows you to login.

INVALID_RESOURCE_ID when Authorization.Capture is called on an authorized payment using sandbox account

I am using PayPal.1.6.0\lib\net45\PayPal.dll
I created a payment with authorize intent and have the successfully authorized authID (Payment.Cart) and the PayPal.APi.Payment.id.
When I try to call the Authorization.Capture(apiContext, Capture) with the authID, I get
{
"name":"INVALID_RESOURCE_ID",
"message":"The requested resource ID was not found",
"information_link":"https://developer.paypal.com/webapps/developer/docs/api/#INVALID_RESOURCE_ID",
"debug_id":"d73f6a0c1b8bc"
}
I tested this using my sandbox account.
Trying the link gets me a 'page not found error'. Any clues?
I realized that i was looking at the wrong 'authorization code'. It is not the ((Payment)executedPayment).cart as posted in my original question but ((Payment)executedPayment).transactions.FirstOrDefault().authorization.id
I was able to use the correct authCode and am able to capture my authorization. executedPayment is the return value from Payment.Execute method.

PayPal Web Payments Pro Hosted - Credit Card payment confirmation page

I've implemented Website Payments Pro Hosted on my website. I can pay using the PayPal log in and it gives me the link to return to my store which is fine as I then display my order confirmation page to the user.
When the user decides to pay via credit card:
They are then redirected to a confirmation page I don't seem to have any control over:
What I've tried:
Setting auto return on in my preferences and setting a return url (both via the Profile and in my initial API call when generating the button.
Changing the Web Payments Pro confirmation page setting to On my sites confirmation page.
When the payment is taken via credit card, I'd like to redirect the user to my actual payment confirmation page. Is this possible?
It turns out that showHostedThankyouPage=true was causing this issue.
I am using the .NET button API to generate the request for the iFrame like so:
var service = new PayPalAPIInterfaceServiceService(GetConfig(request));
var createButtonResponse = service.BMCreateButton(new BMCreateButtonReq
{
BMCreateButtonRequest = new BMCreateButtonRequestType
{
ButtonType = ButtonTypeType.PAYMENT,
ButtonCode = ButtonCodeType.TOKEN,
ButtonCountry = countryCodeType,
ButtonVar = new List<string>
{
String.Format("subtotal={0}", _salesOrderPriceService.GetGrossTotal(request.Order)),
String.Format("notify_url={0}", request.NotifyUrl),
String.Format("return={0}", request.ReturnUrl),
String.Format("invoice={0}", request.Order.Id),
String.Format("currency_code={0}", request.Order.Currency.Code),
String.Format("cancel_return={0}", request.CancelReturnUrl),
"billing_first_name=test",
"billing_last_name=tset",
"billing_address1=test",
"billing_city=test",
"billing_state=tes",
"billing_zip=test",
"billing_country=GB",
"template=templateD",
"paymentaction=sale",
"business=tset"
}
}
});
I had showHostedThankyouPage=true included in the name value pairs which was causing the issue. Removing it sorted it out.

Paypal cancel subscription created via paypal standard subscription button

I use paypal standard subscription button for manage subscription system in my site
I configure ipn i got 2 ipn notification with txn_type subscr_signup and subscr_payment and i have subscr_id param there also.
So i have few questions:
1) how can i get subscription state (active, suspend, canceled, etc) by subscr_id? (i tried GetRecurringPaymentsProfileDetails but it can be used when subscription was created by express checkout only). i getting error 'Subscription Profiles not supported by Recurring Payment APIs'.
2) how to manage subscription state by subscr_id? (also tried ManageRecurringPaymentsProfileStatus, but getting error 'The profile ID is invalid' all the time)
You can use the "TransactionSearch" API to get the details for any profile( even for the one created using the PayPal subscription button ) .With this you can get the info like when profile was created , updated ,suspended etc . I have included the sample request and response , might be it can help you :
NVP Request:
USER=XXXXXXXXXX&PWD=XXXXXXXXXXXX&SIGNATURE=XXXXXX&VERSION=109.0&METHOD=TransactionSearch&STARTDATE=2014-01-24T00:00:00Z&TRANSACTIONCLASS=SUBSCRIPTION&PROFILEID=I-FXMKNUUEP6XL
NVP Response:
L_TIMESTAMP0=2014-02-17T16:19:50Z
L_TIMESTAMP1=2014-02-17T16:19:51Z
L_TIMESTAMP2=2014-03-17T14:02:39Z
L_TIMESTAMP3=2014-04-17T15:26:44Z
L_TIMESTAMP4=2014-05-09T17:18:37Z
L_TIMESTAMP5=2014-05-09T17:19:15Z
L_TIMESTAMP6=2014-05-09T17:19:40Z
L_TIMESTAMP7=2014-05-17T15:26:31Z
L_TIMESTAMP8=2014-06-17T15:55:14Z
L_TIMESTAMP9=2014-07-17T16:14:01Z
L_TIMESTAMP10=2014-08-17T16:06:44Z
L_TIMESTAMP11=2014-09-17T15:55:04Z
L_TIMEZONE0=GMT
L_TIMEZONE1=GMT
L_TIMEZONE2=GMT
L_TIMEZONE3=GMT
L_TIMEZONE4=GMT
L_TIMEZONE5=GMT
L_TIMEZONE6=GMT
L_TIMEZONE7=GMT
L_TIMEZONE8=GMT
L_TIMEZONE9=GMT
L_TIMEZONE10=GMT
L_TIMEZONE11=GMT
L_TYPE0=Recurring Payment
L_TYPE1=Recurring Payment
L_TYPE2=Recurring Payment
L_TYPE3=Recurring Payment
L_TYPE4=Recurring Payment
L_TYPE5=Recurring Payment
L_TYPE6=Recurring Payment
L_TYPE7=Recurring Payment
L_TYPE8=Recurring Payment
L_TYPE9=Recurring Payment
L_TYPE10=Recurring Payment
L_TYPE11=Recurring Payment
L_EMAIL1=XXXXXXXXXXXXXXXX
L_EMAIL2=XXXXXXXXXXXXXXXX
L_EMAIL3=XXXXXXXXXXXXXXXX
L_EMAIL7=XXXXXXXXXXXXXXXX
L_EMAIL8=XXXXXXXXXXXXXXXX
L_EMAIL9=XXXXXXXXXXXXXXXX
L_EMAIL10=XXXXXXXXXXXXXXXX
L_EMAIL11=XXXXXXXXXXXXXXXX
L_NAME0=Eshan Personal Test Account
L_NAME1=Eshan Personal Test Account
L_NAME2=Eshan Personal Test Account
L_NAME3=Eshan Personal Test Account
L_NAME4=Eshan Personal Test Account
L_NAME5=Eshan Personal Test Account
L_NAME6=Eshan Personal Test Account
L_NAME7=Eshan Personal Test Account
L_NAME8=Eshan Personal Test Account
L_NAME9=Eshan Personal Test Account
L_NAME10=Eshan Personal Test Account
L_NAME11=Eshan Personal Test Account
L_TRANSACTIONID0=I-FXMKNUUEP6XL
L_TRANSACTIONID1=0AR10991U1333214W
L_TRANSACTIONID2=1GX902663D9811358
L_TRANSACTIONID3=0K568033VD746381F
L_TRANSACTIONID4=I-FXMKNUUEP6XL
L_TRANSACTIONID5=I-FXMKNUUEP6XL
L_TRANSACTIONID6=I-FXMKNUUEP6XL
L_TRANSACTIONID7=4A4539330Y180244M
L_TRANSACTIONID8=94165672XW4156934
L_TRANSACTIONID9=12791760JH4394641
L_TRANSACTIONID10=36E095146V2526231
L_TRANSACTIONID11=5ED26578AA878723D
L_STATUS0=Created
L_STATUS1=Completed
L_STATUS2=Completed
L_STATUS3=Completed
L_STATUS4=Updated
L_STATUS5=Updated
L_STATUS6=Updated
L_STATUS7=Completed
L_STATUS8=Completed
L_STATUS9=Completed
L_STATUS10=Completed
L_STATUS11=Pending
L_AMT1=50.00
L_AMT2=50.00
L_AMT3=50.00
L_AMT7=50.00
L_AMT8=50.00
L_AMT9=50.00
L_AMT10=50.00
L_AMT11=50.00
L_CURRENCYCODE1=USD
L_CURRENCYCODE2=USD
L_CURRENCYCODE3=USD
L_CURRENCYCODE7=USD
L_CURRENCYCODE8=USD
L_CURRENCYCODE9=USD
L_CURRENCYCODE10=USD
L_CURRENCYCODE11=USD
L_FEEAMT1=-1.75
L_FEEAMT2=-1.75
L_FEEAMT3=-1.75
L_FEEAMT7=-1.75
L_FEEAMT8=-1.75
L_FEEAMT9=-1.75
L_FEEAMT10=-1.75
L_FEEAMT11=0.00
L_NETAMT1=48.25
L_NETAMT2=48.25
L_NETAMT3=48.25
L_NETAMT7=48.25
L_NETAMT8=48.25
L_NETAMT9=48.25
L_NETAMT10=48.25
L_NETAMT11=50.00
TIMESTAMP=2014-10-07T11:05:34Z
CORRELATIONID=5bb22082c58de
ACK=Success
VERSION=109.0
BUILD=000000