I've been using Stripe. When checkout X will create a Payment Intent every time a customer arrives on the checkout. This will result into an "Incomplete" payment.
I integrete STRIPE in my .Net Core application. Here the code below :
public void Pay(CardInfo cardInfo, double amount)
{
StripeConfiguration.ApiKey = _paramList["secretKey"];
State = PaymentState.Pending;
try
{
var options = new SessionCreateOptions
{
Mode = "payment",
SuccessUrl = "https://example.com/success",
CancelUrl = "https://example.com/cancel",
Customer = cardInfo.Owner,
CustomerEmail = cardInfo.ParamList["email"],
PaymentMethodTypes = new List<string>
{
"card",
},
LineItems = new List<SessionLineItemOptions>
{
new SessionLineItemOptions
{
Amount = Convert.ToInt64(amount.ToString().Replace(",","")),
Currency = "eur",
Quantity = 1,
Name = _paramList["account"]
},
},
};
var service = new SessionService();
service.Create(options);
State = PaymentState.Accepted;
}
catch (StripeException error)
{
State = PaymentState.Error;
PaymentReturn = error.Message;
Logger.Write(string.Format("Error STRIPE payment status {0} : ",PaymentReturn));
}
}
In my form payment, I'm not using stripe form but I've created one and I retrieve all information that I need (Card Number, CVV, Expiration, Email and Amount)
When using Stripe Checkout, a PaymentIntent is created under the hood to support the SCA compliant payment. If the session is not completed, the PaymentIntent will remain in state incomplete. This. part is entirely normal.
Integrating with Stripe using a checkout session, but not redirecting to the Stripe hosted Checkout is not a supported integration. If you would like to support handling the card fields yourself, then an integration using Stripe.js and Elements is the best way forward [1]. If you would like to continue using Stripe Checkout as it offers so much functionality out of the box, then once the session is created, you should use redirectToCheckout() from Stripe.js [2] to send the user to Stripe Checkout.
[1] https://stripe.com/docs/payments/accept-a-payment?integration=elements
[2] https://stripe.com/docs/payments/accept-a-payment#redirect-customers
Related
I am trying to provide Google payment service using nestjs.
const GoogleReceiptVerify = require('google-play-billing-validator');
...
constructor(
grv = new GoogleReceiptVerify({
email: myClientMail,
key: myClientSecret,
});
)
...
async googleValide(body){
const data = Buffer.from(messageData, 'base64').toString('utf8');
const jsonData = JSON.parse(data);
const receipt = {
packageName: jsonData.packageName,
productId: jsonData.subscriptionNotification.subscriptionId,
purchaseToken: jsonData.subscriptionNotification.purchaseToken,
};
const promiseData = await grv.verifySub(receipt);
const payload = promiseData.payload;
}
Above is my code.
When user pays for a subscription, user get the exact price.
However, when upgrade, user will see the price of subscription product, not the actual payment amount.
I wonder how to check the actual amount paid, not the price of the subscription product.
curreny : 'USD',
actualAmount : '1.5'
The payment receipt received by e-mail will indicate the actual payment price.
I have been trying to insert a Google calendar event via Google service account that was created for an app in my dev console, but I am continually getting a helpless 404 response back on the Execute method. In the overview of the dev console I can see that the app is getting requests because there are instances of errors on the calendar.events.insert method. There is no information on what is failing. I need this process to use the Service account process instead of OAuth2 so as to not require authentication each time a calendar event needs to be created.
I have set up the service account, given the app a name, have the p12 file referenced in the project. I've also, gone into a personal calendar and have shared with the service account email address. Also, beyond the scope of this ticket, I have created a secondary app, through an administration account and have granted domain wide access to the service account only to receive the same helpless 404 error that this is now giving.
Error Message: Google.Apis.Requests.RequestError
Not Found [404]
Errors [Message[Not Found] Location[ - ] Reason[notFound] Domain[global]
Any help identifying a disconnect or error would be greatly appreciated.
var URL = #"https://www.googleapis.com/calendar/v3/calendars/testcalendarID.com/events";
string serviceAccountEmail = "createdserviceaccountemailaq#developer.gserviceaccount.com";
var path = Path.Combine(HttpRuntime.AppDomainAppPath, "Files/myFile.p12");
var certificate = new X509Certificate2(path, "notasecret",
X509KeyStorageFlags.Exportable);
ServiceAccountCredential credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(serviceAccountEmail)
{
Scopes = new[] { Google.Apis.Calendar.v3.CalendarService.Scope.Calendar },
}.FromCertificate(certificate));
BaseClientService.Initializer initializer = new
BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Test App"
};
Google.Apis.Calendar.v3.CalendarService calservice = new Google.Apis.Calendar.v3.CalendarService(initializer);
string timezone = System.TimeZone.CurrentTimeZone.StandardName;
var calendarEvent = new Event()
{
Reminders = new Event.RemindersData()
{
UseDefault = true
},
Summary = title,
Description = description,
Location = location,
Start = new EventDateTime()
{
//DateTimeRaw = "2014-12-24T10:00:00.000-07:00",
DateTime = startDateTime,
TimeZone = "America/Phoenix"
},
End = new EventDateTime()
{
//DateTimeRaw = "2014-12-24T11:00:00.000-08:00",
DateTime = endDateTime,
TimeZone = "America/Phoenix"
},
Attendees = new List<EventAttendee>()
{
new EventAttendee()
{
DisplayName = "Joe Shmo",
Email = "joeshmoemail#email.com",
Organizer = false,
Resource = false
}
}
};
var insertevent = calservice.Events.Insert(calendarEvent, URL);
var requestedInsert = insertevent.Execute();
I had the same problem. The solution was to add an email client, whose calendar event you want to send.
Credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(serviceAccountEmail)
{
Scopes = Scopes,
User = "example_client_email#gmail.com"
}.FromCertificate(certificate));
So I found out that for this to work, You need to make sure that you access the google.Admin account for referencing the service account Client ID of the app you created.
Another thing that helps is making sure the timezone is in the following format "America/Phoenix"
I have now successfully created events through the service account WITHOUT authentication.
The Stripe is configured with mvc application. but need to send email receipt to customer after successful payment done. If not wrong this can do after webhook event gathered. but couldn't find exact code or api for email payment receipt in c#. any guidelines please.
Edited:
Sorry, I thought someone knew about stripe...
my code is
var myCustomer = new StripeCustomerCreateOptions();
// set these properties if it makes you happy
myCustomer.Email = "email#me.com";
myCustomer.Description = "test: email#me.com";
myCustomer.CardNumber = "4242424242424242";
myCustomer.CardExpirationYear = "2016";
myCustomer.CardExpirationMonth = "10";
myCustomer.CardName = "Red Swan";
myCustomer.CardCvc = "223";
myCustomer.PlanId = "testPremium";
myCustomer.Quantity = 1;
var customerService = new StripeCustomerService();
StripeCustomer stripeCustomer = customerService.Create(myCustomer);
var chargeService = new StripeChargeService();
var stripeCharge = chargeService.Create(myCharge);
This code creates the customer on Stripe as well as performs the payment aganist the plan id that provided... but for sending the mail (generated payment receipt by stripe) to this customer, I need guidelines for code.
I tried for code :
var myCharge = new StripeChargeCreateOptions
{
CustomerId = stripeCustomer.Id,
Currency = "gbp",
Amount=1000,
ReceiptEmail="customer#email.com"
};
var chargeService = new StripeChargeService();
var stripeCharge = chargeService.Create(myCharge);
but not working.
I am developing web application on ASP.NET. In application users can purchase article for money.
For work with PayPal I using PayPal Merchant SDK for .NET package. Application work good with sandbox but with live display error: "This transaction is invalid". Please return to the recipient's website to complete your transaction using their regular checkout flow."
When user click on purchase button I execute code:
// only for live
var paypalConfig = new Dictionary<string, string> {
{"account1.applicationId", "<APP-LIVEID>"},
{"account1.apiUsername", "<username>"},
{"account1.apiPassword", "<pass>"},
{"account1.apiSignature", "<signature>"},
{"mode", "live"}};
try
{
var currency = CurrencyCodeType.USD;
var paymentItem = new PaymentDetailsItemType
{
Name = "item",
Amount = new BasicAmountType(currency, amount.ToString()),
ItemCategory = ItemCategoryType.DIGITAL,
};
var paymentItems = new List<PaymentDetailsItemType>();
paymentItems.Add(paymentItem);
var paymentDetail = new PaymentDetailsType();
paymentDetail.PaymentDetailsItem = paymentItems;
paymentDetail.PaymentAction = PaymentActionCodeType.SALE;
paymentDetail.OrderTotal = new BasicAmountType(currency, amount.ToString());
paymentDetail.SellerDetails = new SellerDetailsType {
PayPalAccountID= sellerEmail
};
var paymentDetails = new List<PaymentDetailsType>();
paymentDetails.Add(paymentDetail);
var ecDetails = new SetExpressCheckoutRequestDetailsType {
ReturnURL = returnUrl,
CancelURL = cancelUrl,
PaymentDetails = paymentDetails,
};
var request = new SetExpressCheckoutRequestType
{
Version = "104.0",
SetExpressCheckoutRequestDetails = ecDetails,
};
var wrapper = new SetExpressCheckoutReq
{
SetExpressCheckoutRequest = request
};
var service = new PayPalAPIInterfaceServiceService(paypalConfig);
var setECResponse = service.SetExpressCheckout(wrapper);
if (sandbox)
return "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token={0}".FormatWith(setECResponse.Token);
return "https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&TOKEN={0}".FormatWith(setECResponse.Token);
}
// # Exception log
catch (System.Exception ex)
{
// Log the exception message
Console.WriteLine("Error Message : " + ex.Message);
}
After all I redirect user to url with received TOKEN.
For my application, registered on PayPal, I set in options only "Adaptive Payments > Basic Payments > Checkout, Send Money or Parallel Payments"
Why live paypal payments can not work? What is the reason?
Removed
ItemCategory = ItemCategoryType.DIGITAL,
and all work
From previous experiences this problem usually comes from having a "null" token because of some mistake in the "setExpressCheckout" request (where, in the express checkout flow, you ask paypal for a transaction token).
Basically, you ask paypal for a token so you can build the redirect URL, but you make some mistake and paypal gives you an error but no token, so you build the URL with no token (or a wrong one).
If you try to redirect the user to the checkout URL ( https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token={...}&useraction={...}) with an empty token you will get this error.
Actually I'm trying to know of there can be other causes...
I am using paypal ios sdk for payment. I tried to pay with credit card in sandbox mode. I am getting State=pending.It accepts my creditcard details but When I click on charge credit card It procees for that and then I got response from paypal :
{
client = {
environment = sandbox;
"paypal_sdk_version" = "1.3.3";
platform = iOS;
"product_name" = "PayPal iOS SDK";
};
payment = {
amount = "122.00";
"currency_code" = USD;
"short_description" = "Paying to MYAPP";
};
"proof_of_payment" = {
"rest_api" = {
"payment_id" = "PAY-6SB360568W1073911KLY6KAI";
state = pending;
};
};
}
It was working fine in NoNetwork/mockmode. Paypal login is also working in sandbox mode. Does I am missing some thing with credit card?
You most likely have Payment Review enabled for the receiving account. To disable this, click the profile link under the account in your sandbox account list and turn off payment review on the settings tab.