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);
Related
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.
I'm following the example provided in the Stripe documentation on Previewing Proration using the Stripe.NET library to try to find the amount that will be charged when a customer upgrades from Plan A to Plan B.
However, when I use the code sample in the documentation, I get an error:
UpcomingInvoiceOptions options = new UpcomingInvoiceOptions()
{
CustomerId = "cus_XXXXXXXXXXXXX",
SubscriptionProrationDate = DateTime.UtcNow,
SubscriptionItems = new List<InvoiceSubscriptionItemOptions>()
{
new InvoiceSubscriptionItemOptions()
{
Id = "si_XXXXXXXXXXXXXX", // Current Sub Item
PlanId = "plan_XXXXXXXXXXXX" // New plan
}
}
};
InvoiceService service = new InvoiceService();
var result = service.Upcoming(options);
The last line throws a Stripe.StripeException: You cannot update a subscription item without a subscription.
Turns out options.SubscriptionId is a required field for this action if you don't call service.Get first.
The following code produces the correct results:
UpcomingInvoiceOptions options = new UpcomingInvoiceOptions()
{
CustomerId = "cus_XXXXXXXXXXXXX",
SubscriptionId = "sub_XXXXXXXXXXXX",
SubscriptionProrationDate = DateTime.UtcNow,
SubscriptionItems = new List<InvoiceSubscriptionItemOptions>()
{
new InvoiceSubscriptionItemOptions()
{
Id = "si_XXXXXXXXXXXXXX", // Current Sub Item
PlanId = "plan_XXXXXXXXXXXX" // New plan
}
}
};
InvoiceService service = new InvoiceService();
var result = service.Upcoming(options);
This is my code for sending email.
private void SendEmail(Guid accountToGuid)
{
string name = GetName(service, accountToGuid);
#region Email
Entity fromParty = new Entity("activityparty");
fromParty["partyid"] = new EntityReference("systemuser", ownerId);
Entity toParty = new Entity("activityparty");
toParty["partyid"] = new EntityReference("account", accountToGuid);
Entity Email = new Entity("email");
Email.Attributes["from"] = new Entity[] { fromParty };
Email.Attributes["to"] = new Entity[] { toParty };
Email.Attributes["subject"] = "Hello " + name;
Email.Attributes["description"] = "Your account has been confirmed by Admin";
Email.Attributes["ownerid"] = new EntityReference("systemuser", ownerId);
Guid EmailId = service.Create(Email);
SendEmailRequest req = new SendEmailRequest();
req.EmailId = EmailId;
req.IssueSend = true;
req.TrackingToken = "";
SendEmailResponse res = (SendEmailResponse)service.Execute(req);
#endregion
}
Lets say, I already sent an email to account. Email will display in activities section. How to retrieve it from SDK?
You need to perform either:
(Full examples in links)
Retrieve - When you already know the record Id, email Id in your case.
RetrieveMultiple - When you don't know the record Id, but you are going to search based on some other criteria, e.g. emails related to the account Id.
I am trying to Create a billing agreement with payment method:credit card.
Here is my code:
public void CreateBillingAgreement()
{
var config = ConfigManager.Instance.GetProperties();
var accessToken = new OAuthTokenCredential(config).GetAccessToken();
var apiContext = new APIContext(accessToken);
//Note: Billing agreements for credit card payments execute automatically when created. There is no need for the user to approve the agreement or to execute the agreement.
var credit_card = new CreditCard()
{
billing_address = new Address()
{
city = "Johnstown",
country_code = "US",
line1 = "52 N Main ST",
postal_code = "43210",
state = "OH"
},
cvv2 = "874",
first_name = "Test",
last_name = "abc",
expire_month = **,
expire_year = ****,
number = "********",
type = "visa"
};
List<FundingInstrument> funding_instruments = new List<FundingInstrument>();
var fund = new FundingInstrument
{
credit_card = credit_card
};
funding_instruments.Add(fund);
var payer = new Payer
{
payment_method = "credit_card",
funding_instruments = funding_instruments
};
var shipping_address = new ShippingAddress
{
line1 = "1234",
city = "California",
state = "California",
postal_code = "95070",
country_code = "US"
};
string Date = DateTime.Now.ToString("yyyy-MM-ddTHH:MM:ssZ");
//Make API call
var agreement = new Agreement
{
name = "T-Shirt of the Month Club Agreement",
description = "Agreement for T-Shirt of the Month Club Plan",
start_date = Date,
plan = new Plan
{
id = "P-*****************"
},
payer = payer,
shipping_address = shipping_address
};
var CreateExecuteAgreement = agreement.Create(apiContext);
But getting this error,
//{"name":"DPRP_DISABLED","message":"DPRP is disabled for this
merchant.","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#DPRP_DISABLED","debug_id":"********"}
}
DPRP = DirectPayment Recurring Payments. This is very specific.
To use this you would need to be using "PayPal Website Payments Pro 3.0", where you would typically use the DoDirectPayment API to process credit cards, and that is $30/mo.
On top of that, you need to add Recurring Payments, and then you would use the CreateRecurringPaymentsProfile API with credit card details included directly (which must be what this SDK you're using is doing). This is considered DPRP, and this is an additional $30/mo on top of the fee for Pro.
Many people get confused because if you sign up for "Payments Pro Recurring Billing" they will probably put you into the PayFlow version, in which case you would need to use the PayFlow API instead of DoDirectPayment / CreateRecurringPaymentsProfile.
So the first thing you need to do is very which version of Payments Pro you are using, and then verify whether or not you have Recurring Payments / Billing enabled on top of that.
I am using paypal API for .NET to create payments.
My exact code in Console Application:
// Get a reference to the config
var config = ConfigManager.Instance.GetProperties();
// Use OAuthTokenCredential to request an access token from PayPal
var accessToken = new OAuthTokenCredential(config).GetAccessToken();
var apiContext = new APIContext(accessToken);
var p = new Payment();
p.intent = "sale";
p.payer = new Payer();
p.payer.payment_method = "credit_card"; //paypal or credit_card
var t = new Transaction();
t.amount = new Amount();
t.amount.currency = "GBP";
t.amount.total = "10.00";
t.amount.details = new Details();
t.amount.details.subtotal = "6.00";
t.amount.details.tax = "2.00";
t.amount.details.shipping = "2.00";
t.item_list = new ItemList();
t.item_list.items = new List<Item>();
var i1 = new Item();
i1.quantity = "1";
i1.name = "OBJETO TESTE";
i1.price = "6.00";
i1.currency = "GBP";
i1.sku = "TESTE";
t.item_list.items.Add(i1);
var a = new ShippingAddress();
a.recipient_name = "ADDRESS";
a.line1 = "LINE1";
a.line2 = "LINE2";
a.city = "LONDOM";
a.country_code = "GB";
a.postal_code = "NW19EA";
t.item_list.shipping_address = a;
p.transactions = new List<Transaction>();
p.transactions.Add(t);
p.redirect_urls = new RedirectUrls();
p.redirect_urls.cancel_url = string.Format("{0}{1}", "http://localhost:3161/", "Order/CancelPayment");
p.redirect_urls.return_url = string.Format("{0}{1}", "http://localhost:3161/", "Order/CompletePayment");
var payment = Payment.Create(apiContext, p);
If I change payment method to paypal, its working. if I send credit_card I get error 500.
debug_id: 30e0f1bb08d3f
configuration: live
Merchants from UK cannot make Direct(Credit Card) Payments using REST API.
You will need to upgrade your account to PRO to make use of Direct Card Payments.
Only US merchants can make direct card payments in REST API without a PRO account.