i could i add user to supergroup / channel using tlsharp
i tried:
var contacts = new TLVector<TLInputPhoneContact>();
contacts.Add(new TLInputPhoneContact { FirstName = "xxx", LastName = "xxx", Phone = "xxx" });
var req = new TLRequestImportContacts()
{
Contacts = contacts
};
var contact = client.SendRequestAsync<TLImportedContacts>(req).GetAwaiter().GetResult();
I have tried some think like this:
List<TLInputUser> users= new List<TLInputUser>();
foreach (TeleSharp.TL.TLUser user in users)
{
usuarios.Add(new TLInputUser
{
UserId = user.Id,
AccessHash = user.AccessHash.Value
});
}
TeleSharp.TL.Channels.TLRequestInviteToChannel r = new TeleSharp.TL.Channels.TLRequestInviteToChannel
{
Channel = new TLInputChannel
{
ChannelId = tlChannel.Id,
AccessHash = tlChannel.AccessHash.Value
},
Users = new TLVector<TLAbsInputUser>(users)
};
But I received the exception USER_NOT_MUTUAL_CONTACT. Is there any other option to add a user to a group?
Thank you very much.
Related
I try add subscription method to my project where customer can subscription product from other user. But i have problem because when i use it:
LineItems = new List<SessionLineItemOptions>
{
new SessionLineItemOptions
{
Price = "{{PRICE_ID}}",
Quantity = 1,
},
},
Mode = "subscription",
SuccessUrl = "https://example.com/success",
CancelUrl = "https://example.com/cancel",
PaymentIntentData = new SessionPaymentIntentDataOptions
{
ApplicationFeeAmount = 123,
},
};
var requestOptions = new RequestOptions
{
StripeAccount = "{{CONNECTED_ACCOUNT_ID}}",
};
var service = new SessionService();
Session session = service.Create(options, requestOptions);
But I have error „You can not pass payment_intent_data in subscription mode".
Can i add application fee amount with linked account to subscription? Is payment usually the only option?
PS. I create my product like this:
var options = new ProductCreateOptions
{
Name = "new product",
DefaultPriceData = new ProductDefaultPriceDataOptions
{
UnitAmount = price,
Currency = "pln"
},
Expand = new List<string> { "default_price" }
};
var requestOptions = new RequestOptions
{
StripeAccount = stripeAccountId,
};
_productService.Create(options, requestOptions);
You'd use https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-subscription_data-application_fee_percent instead.
var options = new Stripe.Checkout.SessionCreateOptions
{
...
SubscriptionData = new Stripe.Checkout.SessionSubscriptionDataOptions
{
ApplicationFeePercent = 10
},
};
...
I'm trying to use Stripe on my web following this Stripe doc: https://stripe.com/docs/legacy-checkout/webforms but when i debug the code throws a TypeInitializationException on both create(), the customer and charge.
if (Request.Form["stripeToken"] != null)
{
var optionsCustomer = new CustomerCreateOptions
{
Email = Request.Form["stripeEmail"].ToString(),
Source = Request.Form["stripeToken"].ToString(),
};
var serviceCustomer = new CustomerService();
Customer customer = serviceCustomer.Create(optionsCustomer);
var optionsCharge = new ChargeCreateOptions
{
Amount = 1099,
Currency = "eur",
};
var serviceCharge = new ChargeService();
serviceCharge.Create(optionsCharge);
}
After upgrading to the latest version of Stripe.Net.
I'm trying to create a new custom connect account, which includes a bank account, with the .Net API and Stripe is throwing this exception.
This account can only be updated with an account token, because it was originally created with an account token. (Attempted to update param 'account_token' directly.)
I'm assigning the AccountToken I'm generating from Stripe.js and that seems to be generating ok. Additionally I have no issue adding an external bank to a already created connect account. I just can't seem to create a new custom account
Here is my c# code
AccountDobOptions dobOptions = new AccountDobOptions()
{
Day = yogaProfile.Birthdate.Day,
Month = yogaProfile.Birthdate.Month,
Year = yogaProfile.Birthdate.Year
};
AddressOptions addressOptions = new AddressOptions()
{
City = bankDetails.City,
Country = bankDetails.CountryCode,
State = bankDetails.CountryCode == "US" ? bankDetails.USStateCode : bankDetails.NonUSStateCode,
PostalCode = bankDetails.PostalCode,
Line1 = bankDetails.AddressLine1,
Line2 = bankDetails.AddressLine2
};
AccountLegalEntityOptions legal = new AccountLegalEntityOptions();
legal.Dob = dobOptions;
legal.Type = "individual";
legal.Address = addressOptions;
legal.FirstName = accountFullName.Split(' ')[0];
legal.LastName = accountFullName.Split(' ')[1];
//legal.SSNLast4 = bankDetails.LastFourSSN;
AccountTosAcceptanceOptions tosOptions = new AccountTosAcceptanceOptions()
{
Date = DateTime.UtcNow,
Ip = clientIpAddress != null ? clientIpAddress : GetUserIpAddress()
};
var accountOptions = new AccountCreateOptions()
{
Email = yogaProfile.ApplicationUser.Email,
Type = AccountType.Custom,
Country = bankDetails.CountryCode,
LegalEntity = legal,
TosAcceptance = tosOptions,
AccountToken = stripeToken,
//TransferScheduleInterval = "weekly",
ExternalBankAccount = new AccountBankAccountOptions()
};
var accountService = new AccountService();
Account account = accountService.Create(accountOptions);
Is there any options for sending OTP while Credit/Debit card payment in authorize.net.
if there is no option how to achieve this
This is the code for getting response from the Authorized.Net
public static ANetApiResponse Run(CustomerDetail cd,decimal amount)
{
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;
ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
{
name = ConfigurationManager.AppSettings["AuthorizeNetLogin"],
ItemElementName = ItemChoiceType.transactionKey,
Item = ConfigurationManager.AppSettings["AuthorizeNetTransactionKey"],
};
var creditCard = new creditCardType
{
cardNumber = Convert.ToString(cd.cardnumber),
expirationDate = cd.expirationdate,
};
var paymentType = new paymentType { Item = creditCard };
var transactionRequest = new transactionRequestType
{
transactionType = transactionTypeEnum.authOnlyTransaction.ToString(), // authorize only
amount = amount,
payment = paymentType
};
var request = new createTransactionRequest { transactionRequest = transactionRequest };
var controller = new createTransactionController(request);
controller.Execute();
var response = controller.GetApiResponse();
return response;
}
Authorize.Net does not support One Time Password as Authorize.Net does not support money transfers.
For customer with existing payment profile id(Saved credit card) we are using "createCustomerProfileTransactionController" as follow for authorization.
public createCustomerProfileTransactionResponse AuthorizePaymentProfile(int customerProfileId, int customerPaymentProfileId, decimal amount)
{
createCustomerProfileTransactionResponse response = null;
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = environment;
// define the merchant information (authentication / transaction id)
ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
{
name = apiLoginID,
ItemElementName = ItemChoiceType.transactionKey,
Item = apiTransactionKey,
};
//construct request
var request = new createCustomerProfileTransactionRequest
{
merchantAuthentication = new merchantAuthenticationType
{
name = apiLoginID,
ItemElementName = ItemChoiceType.transactionKey,
Item = apiTransactionKey
},
transaction = new profileTransactionType
{
Item = new profileTransAuthOnlyType
{
customerProfileId = customerProfileId.ToString(),
customerPaymentProfileId = customerPaymentProfileId.ToString(),
amount = amount
}
},
extraOptions = "x_duplicate_window=1"
};
//Prepare Request
var controller = new createCustomerProfileTransactionController(request);
controller.Execute();
//Send Request to EndPoint
response = controller.GetApiResponse();
return response;
}
And for customer without existing payment profile id we using "createTransactionRequest" as follow for authorization.
public createTransactionResponse AuthorizeOneTimePayment(Card cardInfo, decimal amount)
{
createTransactionResponse response = null;
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = environment;
//define the merchant information (authentication / transaction id)
ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
{
name = apiLoginID,
ItemElementName = ItemChoiceType.transactionKey,
Item = apiTransactionKey,
};
var creditCard = new creditCardType
{
cardNumber = cardInfo.CardNumber,// "4111111111111111",
expirationDate = cardInfo.ExpirationDate// "0718"
//cardCode=cardInfo.VerificationCode
};
//standard api call to retrieve response
var paymentType = new paymentType { Item = creditCard };
string firstName = string.Empty;
string lastName = string.Empty;
if (!string.IsNullOrWhiteSpace(cardInfo.BillingName))
{
string[] name = GetBillName(cardInfo.BillingName);
firstName = name[0];
lastName = name[1];
}
var transactionRequest = new transactionRequestType
{
transactionType = transactionTypeEnum.authOnlyTransaction.ToString(), // authorize only
amount = amount,
payment = paymentType,
billTo = new customerAddressType
{
firstName = firstName,
lastName = lastName,
address = cardInfo.BillingAddress,
city = cardInfo.BillingCity,
state = cardInfo.BillingState,
zip = cardInfo.BillingZipCode
}
};
var request = new createTransactionRequest { transactionRequest = transactionRequest };
// instantiate the controller that will call the service
var controller = new createTransactionController(request);
controller.Execute();
// get the response from the service (errors contained if any)
response = controller.GetApiResponse();
return response;
}
And following same technique for capture and void a transaction.
My question is can we use "createTransactionRequest" for all transaction like authorize, capture and void a transaction for both customer having payment profile id and one time customer.
I could find any clue in authorize.net on line documentation. Please guide us how to do that.
Yes, you can use createTransactionRequest for Auth/Capture, Auth Only, Prior Auth and Capture, Void and Refund by changing the transactionRequestType and paymentType.
For anyone with the same question, like me, here is the answer.
Note that Order is optional, and obviously profile is optional.
...
var transactionRequest = new transactionRequestType {
transactionType = transactionTypeEnum.authOnlyTransaction.ToString(),
amount = amount,
order = new orderType { invoiceNumber = OrderID, description = desc },
profile = getCustomerPaymentProfile(CustomerProfileId, creditProfileID)
};
...
private customerProfilePaymentType getCustomerPaymentProfile(string CustomerProfileId, string creditProfileID) {
return new customerProfilePaymentType {
customerProfileId = CustomerProfileId,
paymentProfile = new paymentProfile { paymentProfileId = creditProfileID }
};
}