Sending OTP via Authorize.Net - c#

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.

Related

Stripe - how add connected account on the subscription (application fee amount)?

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
},
};
...

TypeInitializationException Stripe.StripeConfiguration payment

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);
}

PayPal tutorial missing references?

Trying to follow the PayPal .NET tutorial on GitHub.
I've fixed it the best I can but still getting a lot of errors related to missing functions etc. Here is what I have so far:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using PayPal.Api;
using System.Configuration;
using PayPal.Sample.Utilities;
using System.Web.Providers.Entities;
/// <summary>
/// Summary description for OAuthTokenCredential
/// </summary>
public class CredentialManager
{
Dictionary<string, string> _Config = null;
string _AccessToken = string.Empty;
APIContext _APIConText = null;
public CredentialManager()
{
// Get a reference to the config
var config = ConfigManager.Instance.GetProperties();
_Config = config;
// Use OAuthTokenCredential to request an access token from PayPal
var accessToken = new OAuthTokenCredential(config).GetAccessToken();
_AccessToken = accessToken;
//API Context
var apiContext = new APIContext(accessToken);
_APIConText = apiContext;
// Initialize the apiContext's configuration with the default configuration for this application.
apiContext.Config = ConfigManager.Instance.GetProperties();
// Define any custom configuration settings for calls that will use this object.
apiContext.Config["connectionTimeout"] = "1000"; // Quick timeout for testing purposes
// Define any HTTP headers to be used in HTTP requests made with this APIContext object
//if (apiContext.HTTPHeaders == null)
//{
// apiContext.HTTPHeaders = new Dictionary<string, string>();
//}
//apiContext.HTTPHeaders["some-header-name"] = "some-value";
}
public Payment GetPAyment(APIContext apiContext, string paymentid)
{
var payment = Payment.Get(apiContext, paymentid);
return payment;
}
public bool CreatePayment()
{
try
{
bool Success = false;
//var apiContext = Configuration.GetAPIContext();
string payerId = Request.Params["PayerID"];
if (string.IsNullOrEmpty(payerId))
{
var itemList = new ItemList()
{
items = new List<Item>()
{
new Item()
{
name = "Item Name",
currency = "USD",
price = "15",
quantity = "5",
sku = "sku"
}
}
};
var payer = new Payer() { payment_method = "paypal" };
var baseURI = Request.Url.Scheme + "://" + Request.Url.Authority + "/PaymentWithPayPal.aspx?";
var guid = Convert.ToString((new Random()).Next(100000));
var redirectUrl = baseURI + "guid=" + guid;
var redirUrls = new RedirectUrls()
{
cancel_url = redirectUrl + "&cancel=true",
return_url = redirectUrl
};
var details = new Details()
{
tax = "15",
shipping = "10",
subtotal = "75"
};
var amount = new Amount()
{
currency = "USD",
total = "100.00", // Total must be equal to sum of shipping, tax and subtotal.
details = details
};
var transactionList = new List<Transaction>();
transactionList.Add(new Transaction()
{
description = "Transaction description.",
invoice_number = Common.GetRandomInvoiceNumber(),
amount = amount,
item_list = itemList
});
var payment = new Payment()
{
intent = "sale",
payer = payer,
transactions = transactionList,
redirect_urls = redirUrls
};
var createdPayment = payment.Create(_APIConText);
var links = createdPayment.links.GetEnumerator();
while (links.MoveNext())
{
var link = links.Current;
if (link.rel.ToLower().Trim().Equals("approval_url"))
{
this.flow.RecordRedirectUrl("Redirect to PayPal to approve the payment...", link.href);
}
}
Session.Add(guid, createdPayment.id);
Session.Add("flow-" + guid, this.flow);
}
else
{
var guid = Request.Params["guid"];
var paymentId = Session[guid] as string;
var paymentExecution = new PaymentExecution() { payer_id = payerId };
var payment = new Payment() { id = paymentId };
var executedPayment = payment.Execute(apiContext, paymentExecution);
}
return Success;
}
catch(Exception ex)
{
return false;
}
}
}
I'm getting random errors on the following:
using PayPal.Sample.Utilities;
string payerId = Request.Params["PayerID"];
var baseURI = Request.Url.Scheme + "://" + Request.Url.Authority + "/PaymentWithPayPal.aspx?";
invoice_number = Common.GetRandomInvoiceNumber(),
Session.Add(guid, createdPayment.id);
Session.Add("flow-" + guid, this.flow);
var guid = Request.Params["guid"];
var paymentId = Session[guid] as string;
var executedPayment = payment.Execute(_APIConText, paymentExecution);
Errors:
"Request" does not exist
"Common" does not exist
"flow" does not exist
"session" is not valid in its current type
I think I'm just missing a reference or something. I'm trying to do it for C# ASP .Net (not MVC)
You'll find the "Common" class here
Common.GetRandomInvoiceNumber() is just generating a random number. I think you would just replace that with your own generated invoice number.

Authorized.net - Can createTransactionRequest be use for Authorize, capture and void a transaction for existing payment profile id

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 }
};
}

sending mailchimp campaign in asp.net

I'm trying to send a mail chimp campaign using asp.net, actually i created successfully the campaign and i can see it through my profile but also i want to send it through my code here is my code so if any one can help!!
private static void CreateCampaignAndSend(string apiKey, string listID)
{
Int32 TemplateID = 0;
string campaignID = string.Empty;
// compaign Create Options
var campaignCreateOpt = new campaignCreateOptions
{
list_id = listID,
subject = "subject",
from_email = "cbx#abc.com",
from_name = "abc",
template_id = TemplateID
};
// Content
var content = new Dictionary<string, string>
{
{"html", "Lots of cool stuff here."}
};
// Conditions
var csCondition = new List<campaignSegmentCondition>();
var csC = new campaignSegmentCondition {field = "interests-" + 123, op = "all", value = ""};
csCondition.Add(csC);
// Options
var csOptions = new campaignSegmentOptions {match = "all"};
// Type Options
var typeOptions = new Dictionary<string, string>
{
{"offset-units", "days"},
{"offset-time", "0"},
{"offset-dir", "after"}
};
// Create Campaigns
var campaignCreate = new campaignCreate(new campaignCreateInput(apiKey, EnumValues.campaign_type.plaintext, campaignCreateOpt, content, csOptions, typeOptions));
campaignCreateOutput ccOutput = campaignCreate.Execute();
campaignSendNow c=new campaignSendNow();
List<Api_Error> error = ccOutput.api_ErrorMessages; // Catching API Errors
if (error.Count <= 0)
{
campaignID = ccOutput.result;
}
else
{
foreach (Api_Error ae in error)
{
Console.WriteLine("\n ERROR Creating Campaign : ERRORCODE\t:" + ae.code + "\t ERROR\t:" + ae.error);
}
}
}

Categories