Here is my code for checking out with a credit card. Using PayPal Trans works fine but I am missing something for credit card trans.
HttpContext CurrContext = HttpContext.Current;
APIContext apiContext = Configuration.GetAPIContext();
Item item = new Item();
item.name = _ItemDescription;
item.currency = "USD";
item.price = _Amount;
item.quantity = "1";
item.sku = _UPC;
List<Item> itms = new List<Item>();
itms.Add(item);
ItemList itemList = new ItemList();
itemList.items = itms;
Address billingAddress = new Address();
billingAddress.city = ciTxBx.Text;
billingAddress.country_code = "US";
billingAddress.line1 = ad1TxBx.Text;
billingAddress.line2 = ad2TxBx.Text;
billingAddress.postal_code = pcTxBx.Text;
billingAddress.state = stRcb.SelectedValue.ToString();
CreditCard crdtCard = new CreditCard();
crdtCard.billing_address = billingAddress;
crdtCard.cvv2 = scTxBx.Text;
crdtCard.expire_month = Convert.ToInt32(emonthTxBx.Text);
crdtCard.expire_year = Convert.ToInt32(eyearTxBx.Text);
crdtCard.first_name = ccfnTxBx.Text;
crdtCard.last_name = cclnTxBx.Text;
crdtCard.number = ccnTxBx.Text;
crdtCard.type = ConvertLower(cctRcb.SelectedValue.ToString());
Details details = new Details();
details.tax = "0";
details.shipping = "0";
details.subtotal = _Amount;
Amount amont = new Amount();
amont.currency = "USD";
amont.total = _Amount;
amont.details = details;
Transaction tran = new Transaction();
tran.amount = amont;
tran.description = _ItemDescription;
tran.item_list = itemList;
List<Transaction> transactions = new List<Transaction>();
transactions.Add(tran);
FundingInstrument fundInstrument = new FundingInstrument();
fundInstrument.credit_card = crdtCard;
List<FundingInstrument> fundingInstrumentList = new List<FundingInstrument>();
fundingInstrumentList.Add(fundInstrument);
PayerInfo pi = new PayerInfo();
pi.email = emTxBx.Text;
pi.first_name = fnTxBx.Text;
pi.last_name = lnTxBx.Text;
pi.shipping_address = billingAddress;
Payer payr = new Payer();
payr.funding_instruments = fundingInstrumentList;
payr.payment_method = "credit_card";
payr.payer_info = pi;
Payment paymnt = new Payment();
paymnt.intent = "sale";
paymnt.payer = payr;
paymnt.transactions = transactions;
try
{
Payment createdPayment = paymnt.Create(apiContext);
CurrContext.Items.Add("ResponseJson", JObject.Parse(createdPayment.ConvertToJson()).ToString(Formatting.Indented));
}
catch (PayPal.Exception.PayPalException ex)
{
if (ex.InnerException is PayPal.Exception.ConnectionException)
{
CurrContext.Response.Write(((PayPal.Exception.ConnectionException)ex.InnerException).Response);
}
else
{
CurrContext.Response.Write(ex.Message);
}
}
CurrContext.Items.Add("RequestJson", JObject.Parse(paymnt.ConvertToJson()).ToString(Formatting.Indented));
Anyone know why I am receiving a "No payload for this request" message?