I have a paypal transaction which is authorized then captured. I want to refund it using .net code of refundtransaction I have the following error:
You can not refund this type of transaction
Public Function RefundTransactionCode(ByVal refundType__1 As String, ByVal transactionId As String, ByVal amount As String, ByVal note As String, ByRef resp As RefundTransactionResponseType) As AckCodeType
Dim caller As New CallerServices()
Dim profile As IAPIProfile = ProfileFactory.createSignatureAPIProfile()
'
' WARNING: Do not embed plaintext credentials in your application code.
' Doing so is insecure and against best practices.
' Your API credentials must be handled securely. Please consider
' encrypting them for use in any production environment, and ensure
' that only authorized individuals may view or modify them.
'
' Set up your API credentials, PayPal end point, and API version.
profile.APIUsername = AppSettings("APIUsername")
profile.APIPassword = AppSettings("APIPassword")
profile.APISignature = AppSettings("APISignature")
profile.Environment = AppSettings("Environment")
caller.APIProfile = profile
' Create the request object.
Dim concreteRequest As New RefundTransactionRequestType()
concreteRequest.Version = "51.0"
' Add request-specific fields to the request.
' If (amount IsNot Nothing AndAlso amount.Length > 0) AndAlso (refundType__1.Equals("Partial")) Then
Dim amtType As New BasicAmountType()
amtType.Value = amount
amtType.currencyID = CurrencyCodeType.CAD
concreteRequest.Amount = amtType
concreteRequest.RefundType = RefundType.Full
' Else
'MsgBox(0)
'concreteRequest.RefundType = RefundType.Full
' End If
concreteRequest.RefundTypeSpecified = True
concreteRequest.TransactionID = transactionId
concreteRequest.Memo = note
' Execute the API operation and obtain the response.
' Dim pp_response As New RefundTransactionResponseType()
resp = DirectCast(caller.[Call]("RefundTransaction", concreteRequest), RefundTransactionResponseType)
Return resp.Ack
End Function
I would advise finding the transaction in your PayPal account and looking at it. It is probably an Authorization, Order, Pending transaction, or some other type of transaction.
You can only refund a capture/sale, that was sent to the account you are sending the API on behalf of*, that hasn't already been refunded.
*
Third party API calls, where you use 'subject' in your API parameters along with your username, password, and signature/certificate, are you sending API calls on behalf of the 'subject's account.
First party API calls are where you do not send subject, and only use your own API user,pass, and sig/cert
Related
I have just setup a new project and added the following scopes for "Web application".
email, and send mail
I have also enabled GMailAPI from library
After this I have created credentials. Then edit > redirect_uri
I am not sure what this uri should be but I have tried almost everything here
Gmail error message state "If you are a developer of this app see error details"
the url mentioned here : http:\x.x.x.x:1234\authorize\
with and without ending slash
P.S: when I type above uri in my browser, I get to a break point in my application
my home page url
http:\localhost\default.aspx
my calling page uri
http:\localhost\member\create.aspx
None of these work and I still get redirect_uri_mismatch Access Blocked error
My code is still running on my local machine and not available in google cloud.
vb.net code
Dim credential As UserCredential = Await GoogleWebAuthorizationBroker.AuthorizeAsync(New ClientSecrets With {
.ClientId = "xxx",
.ClientSecret = "xxx"
},
{"https://www.googleapis.com/auth/gmail.send"},
"user",
CancellationToken.None)
Update
I got to know that AuthorizeAsync is for installed applications and not for web apps, here is my updated code...which is not sending me back a token.
Public Function DoOauthAndSendEmail(subject As String, body As String, recipients As String) As Task
Dim fromEmail As String = ConfigurationSettings.AppSettings("ContactEmail")
Dim MailMessage As MailMessage = New MailMessage(fromEmail, recipients, subject, body)
'Specify whether the body Is HTML
MailMessage.IsBodyHtml = True
'Convert to MimeMessage
Dim Message As MimeMessage = MimeMessage.CreateFromMailMessage(MailMessage)
Dim rawMessage As String = Message.ToString()
Dim flow As IAuthorizationCodeFlow = New GoogleAuthorizationCodeFlow(New GoogleAuthorizationCodeFlow.Initializer With {
.ClientSecrets = New ClientSecrets With {
.ClientId = "CLIENT_ID",
.ClientSecret = "CLIENT_SECRET"
},
.Scopes = {GmailService.Scope.GmailSend}
})
Dim token As Responses.TokenResponse = New Responses.TokenResponse()
If flow IsNot Nothing And token IsNot Nothing Then
Dim credential As UserCredential = New UserCredential(flow, "user", token)
Dim success As Boolean = credential.RefreshTokenAsync(CancellationToken.None).Result
Dim gmail As GmailService = New GmailService(New Google.Apis.Services.BaseClientService.Initializer() With {
.ApplicationName = "APP_NAME",
.HttpClientInitializer = credential
})
gmail.Users.Messages.Send(New Message With {
.Raw = Base64UrlEncode(rawMessage)
}, "me").Execute()
End If
End Function
You are looking in the wrong place for the redirect uri's it is found under credentials then edit your web app client
Google OAuth2: How the fix redirect_uri_mismatch error. Part 2 server sided web applications
update Installed app
The code you are using GoogleWebAuthorizationBroker.AuthorizeAsync is used for authorizing an installed application. In this instance you need to make sure that you have created an installed application credentials on google cloud console.
How to create installed application credetilas.
You should not be seeing a redirect uri error if you have created the correct credentials type for you to match the code you are using.
Hope you all are doing well. I am new working with Google ads api. I have to retrieve information regarding keywords i.e how many people searched certain keywords , how many clicks and so on... so I have created a manager account on Google ads and under that I have created client account. In client account I have added keywords under keyword planner and I am getting all information mentioned above but I want to get it through REST API in python.
I have everything needed to access API:
(Developer token
login_customer_id
Client ID
Client Secret
refresh token) I have given this information in the .yaml file. and I assume login_customer_id is the manager account id.
Below is the code to access all the keywords information. here I have given the client_idfrom which I want to access keywords information.
import argparse
import sys
from google.ads.googleads.client import GoogleAdsClient
from google.ads.googleads.errors import GoogleAdsException
def main(client, customer_id):
ga_service = client.get_service("GoogleAdsService")
query = """
SELECT
campaign.id,
campaign.name,
ad_group.id,
ad_group.name,
ad_group_criterion.criterion_id,
ad_group_criterion.keyword.text,
ad_group_criterion.keyword.match_type,
metrics.impressions,
metrics.clicks,
metrics.cost_micros
FROM keyword_view WHERE segments.date DURING LAST_7_DAYS
AND campaign.advertising_channel_type = 'SEARCH'
AND ad_group.status = 'ENABLED'
AND ad_group_criterion.status IN ('ENABLED', 'PAUSED')
ORDER BY metrics.impressions DESC
LIMIT 50"""
# Issues a search request using streaming.
search_request = client.get_type("SearchGoogleAdsStreamRequest")
search_request.customer_id = customer_id
search_request.query = query
response = ga_service.search_stream(search_request)
for batch in response:
for row in batch.results:
campaign = row.campaign
ad_group = row.ad_group
criterion = row.ad_group_criterion
metrics = row.metrics
print(
f'Keyword text "{criterion.keyword.text}" with '
f'match type "{criterion.keyword.match_type.name}" '
f"and ID {criterion.criterion_id} in "
f'ad group "{ad_group.name}" '
f'with ID "{ad_group.id}" '
f'in campaign "{campaign.name}" '
f"with ID {campaign.id} "
f"had {metrics.impressions} impression(s), "
f"{metrics.clicks} click(s), and "
f"{metrics.cost_micros} cost (in micros) during "
"the last 7 days."
)
# [END get_keyword_stats]
if name == "main":
googleads_client=GoogleAdsClient.load_from_storage("C:\Users\AnoshpaBansari\PycharmProjects\GoogleAPI\src\creds\googleads.yaml")
parser = argparse.ArgumentParser(
description=("Retrieves a campaign's negative keywords.")
)
# The following argument(s) should be provided to run the example.
#parser.add_argument(
# "-c",
# "--customer_id",
# type=str,
#required=True,
#help="The Google Ads customer ID.",
#)
#args = parser.parse_args()
try:
main(googleads_client, "----------")
except GoogleAdsException as ex:
print(
f'Request with ID "{ex.request_id}" failed with status '
f'"{ex.error.code().name}" and includes the following errors:'
)
for error in ex.failure.errors:
print(f'\tError with message "{error.message}".')
if error.location:
for field_path_element in error.location.field_path_elements:
print(f"\t\tOn field: {field_path_element.field_name}")
sys.exit(1)
but when I run the code I receive this error. I don't know what I am doing wrong.. Can anyone please help?
enter image description here
You must login in Google Ads Manager accounts, go Tools & Settings > API Center and accept the API terms and conditions.
I'm trying to request an access token and a refresh token from Microsoft Graph, but adding "offline_access" to the scope makes the scope invalid.
This is for a service where a user gives us access to an Outlook Calendar once and after that the service checks their calendar every 20 minutes for events. I have managed to get consent and pull data when requesting access to "User.Read" and "Calendars.Read", but when I add "offline_access" I get the message The provided resource value for the input parameter 'scope' is not valid.
I have an array with the permissions I want
private static final String[] ACCESS_PERMISSIONS = {
"https://graph.microsoft.com/User.Read",
"https://graph.microsoft.com/Calendars.Read",
"https://graph.microsoft.com/offline_access",
};
and then combine and encode them
String encodedScope = URLEncoder.encode(
Arrays.stream(ACCESS_PERMISSIONS)
.reduce(
(a,b) -> a + " " + b)
.get(), "UTF-8").replace("+","%20");
which results in the string https%3A%2F%2Fgraph.microsoft.com%2FUser.Read%20https%3A%2F%2Fgraph.microsoft.com%2FCalendars.Read%20https%3A%2F%2Fgraph.microsoft.com%2Foffline_access
Then I request the tokens
String appId = "client_id=" + clientID;
String scope = "&scope=" + encodedScope;
String authCode = "&code=" + code;
String redirect = "&redirect_uri=" + redirectUri;
String grantType = "&grant_type=authorization_code";
String secret = "&client_secret=" + clientSecret;
String data = appId + scope + authCode + redirect + grantType + secret;
// Create POST request
URL url = new URL(postUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
// Configure request
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setRequestProperty("Accept", "application/json");
connection.setDoOutput(true);
// Send data
OutputStream os = connection.getOutputStream();
byte[] inputBytes = data.getBytes(ENCODING);
os.write(inputBytes, 0, inputBytes.length); // Bytes, Offset, Length
The final link then looks like
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?
client_id=[CLIENT ID]
&response_type=code
&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Fsport%2Fauth%2Foutlook
&response_mode=query
&scope=https%3A%2F%2Fgraph.microsoft.com%2FUser.Read%20https%3A%2F%2Fgraph.microsoft.com%2FCalendars.Read%20https%3A%2F%2Fgraph.microsoft.com%2Foffline_access
&state=2737
I would expect this to return an access token and a refresh token, but as previously mentioned I get the message that the resource value for the scope is not valid.
It is essential for the service to be able to refresh the tokens as it should run about a year without intervention.
The scope isn't https://graph.microsoft.com/offline_access, it is simply offline_access. Offline Access is a special AAD scope that tells it to return a Refresh Token, it isn't a Microsoft Graph scope.
You can actually drop https://graph.microsoft.com/ across the board. The only time you need to specify the FQDN is when you're requesting the default set of scopes from the app registration (i.e. https://graph.microsoft.com/.default) but that is generally only used when you're using App-Only/Daemon authentication flow (Client Credentials).
I'm developing a vb net application using twilio api.
This is my code:
Twilio.TwilioClient.Init(AccountSid, AuthToken)
Dim call_to As PhoneNumber = New PhoneNumber("...")
Dim call_from As PhoneNumber = New PhoneNumber("...")
Dim call_option As CreateCallOptions = New CreateCallOptions(call_to, call_from)
call_option.Method = "Get"
call_option.Timeout = 25
call_option.Url = New Uri(ws_url & "/GET_CALL_XML" & ws_parameter)
call_option.StatusCallback = New Uri(ws_url & "/GET_CALL_FEEDBACK" & ws_parameter)
call_option.FallbackUrl = New Uri(ws_url & "/GET_CALL_ERROR" & ws_parameter)
call_option.StatusCallbackEvent.Add("answered")
call_option.StatusCallbackEvent.Add("completed")
Dim call_ As CallResource = CallResource.Create(call_option)
The call is successfully performed.
Now the problem is:
if the user answer the call, i receive the StatusCallBack with "callstatus"="in-progress"
if the user refuse the call, i receive the StatusCallBack with "callstatus"="in-progress" equally
How can i know if the user really answer the call?
Thank you
Twilio developer evangelist here.
If the user actually answers the call, then you will get a webhook to the Url that you set, in your example, the one with the path /GET_CALL_XML.
If the user refuses the call then you will not receive a webhook to that URL.
I am creating a program using the QBFC13 that is supposed to create a deposit from an other current asset type of account to a bank account. However, when the depositadd method is executed the payee doesn't get filled in on the bank account. How do i get the Payee information filled out?
I dont have a high enough reputation to post pictures so this is a link to the picture of the field i need filled out: http://i.stack.imgur.com/nqWOh.jpg
Here is my current code:
Public Sub CreateDeposit()
On Error GoTo Errs
Dim depositadd As IDepositAdd
depositadd = msgSetRequest.AppendDepositAddRq()
depositadd.DepositToAccountRef.FullName.SetValue("checking")
depositadd.Memo.SetValue("newdeposit test")
depositadd.TxnDate.SetValue(Date.Today)
Dim depositLineAdd As IDepositLineAdd
depositLineAdd = depositadd.DepositLineAddList.Append()
depositLineAdd.ORDepositLineAdd.DepositInfo.AccountRef.ListID.SetValue("1EE0000-943382783")
depositLineAdd.ORDepositLineAdd.DepositInfo.EntityRef.ListID.SetValue("80002534-1335362979")
depositLineAdd.ORDepositLineAdd.DepositInfo.Amount.SetValue(150.0)
depositLineAdd.ORDepositLineAdd.DepositInfo.Memo.SetValue("test memo lineitem")
' send the request to QB
Dim msgSetResponse As IMsgSetResponse
msgSetResponse = qbSessionManager.DoRequests(msgSetRequest)
' check to make sure we have objects to access first
' and that there are responses in the list
If (msgSetResponse Is Nothing) Or _
(msgSetResponse.ResponseList Is Nothing) Or _
(msgSetResponse.ResponseList.Count <= 0) Then
Exit Sub
End If
' Start parsing the response list
Dim responseList As IResponseList
responseList = msgSetResponse.ResponseList
MsgBox(msgSetRequest.ToXMLString())
' go thru each response and process the response.
' this example will only have one response in the list
' so we will look at index=0
Dim response As IResponse
response = responseList.GetAt(1)
If (Not response Is Nothing) Then
If response.StatusCode <> "0" Then
MsgBox("DepositFunds unexpexcted Error - " & vbCrLf & "StatusCode = " & response.StatusCode & vbCrLf & vbCrLf & response.StatusMessage)
Else
MsgBox("The funds were successfully deposited in Checking")
MsgBox(msgSetResponse.ToXMLString())
End If
End If
Exit Sub
Errs:
MsgBox("HRESULT = " & Err.Number & " (" & Hex(Err.Number) & ") " & vbCrLf & vbCrLf & Err.Description, _
MsgBoxStyle.Critical, _
"Error in DepositFunds")
End Sub
This actually isn't an SDK issue, as it's how QuickBooks was designed. Because a deposit transaction in QuickBooks can contain multiple lines, the bank register won't show any names even if there's just one line. You can manually go to the bank register and add the name, but there's not a way to do it through the SDK. It's a two step process to even do it in QuickBooks, where you create the deposit, then go and edit it in the register.
If you need to have this information show from transaction using the SDK, then you might have to use Journal Entries instead of a Deposit transaction.