I'm working on integrating PayPal into a client's ecommerce site. Using the sandbox, we got everything working fine. I now need to add in SetPaymentOptionsRequest to prevent the user from changing his shipping address (they enter it on our site, so they can't change it at PayPal due to different shipping costs calculated on our site). It appears to work fine, but I get a 3005 error when logging into the PayPal sandbox site to confirm the transaction. Below is the relevant code (C#):
public string MakeChainedPayment(params params) {
var request = new PayRequest {
requestEnvelope = new RequestEnvelope("en_us"),
actionType = "CREATE",
cancelUrl = this._cancelUrl,
currencyCode = this._currencyCode,
returnUrl = this._returnUrl,
ipnNotificationUrl = this._ipnNotificationUrl
};
// Some code to generate receivers, not important for this problem, I don't think
var response = this._paymentService.Pay(request);
switch (response.paymentExecStatus) {
// This always returns "CREATED", as I'd want, so good up to here.
case "CREATED":
// If I leave this code out, PayPal works fine, but I need
// this part to do the shipping address verification.
var p = new SetPaymentOptionsRequest();
p.senderOptions = new SenderOptions();
p.senderOptions.addressOverride = false;
p.senderOptions.shippingAddress = new ShippingAddressInfo {
// Setting from params: city, country, zip, state, street1, street2
};
p.payKey = response.payKey;
p.requestEnvelope = request.requestEnvelope;
SetPaymentOptionsResponse r = _paymentService.SetPaymentOptions(payOptsReq);
break;
// This always retuns r.error.Count = 0, r.responseEnvelope.ack = "SUCCESS",
// so I think I'm good to go.
}
if (this._useSandbox) {
return string.Concat("https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_ap-payment&paykey=", response.payKey);
}
return string.Concat("https://www.paypal.com/cgi-bin/webscr?cmd=_ap-payment&paykey=", response.payKey);
}
Paypal returns this message when your Paypal account's email address has not been verified. To verify your Paypal Email account, please follow the following steps:
Log into your Paypal Account. You should be in the “Overview” tab.
Click on your Email address, under “Business account overview”, you will be taken to a Web page listing your Paypal Email addresses.
Select your Primary Adress.
Click on the “Confirm” button.
Follow the rest of the Paypal instructions.
The problem was what I was passing in for the country; I was sending in "USA", and it should be "US".
Related
Just migrated to Stripe.com. I am creating a checkout session programmatically. See code snippet below. When I test, the User.Identity.GetUserId() comes back with a value and it is sent to stripe. However, when end user completes the payment, Stripe.com is not sending back the client_reference_id (it is null) in the event checkout.session.completed that I am listening to.
I get back my client_reference_id when I do payment links (send via querystring)
What am I doing wrong?
[HttpPost]
[AllowAnonymous]
public ActionResult SendToCheckout(ProcessPaymentViewModel model)
{
StripeConfiguration.ApiKey = _apiSecret;
var options = new SessionCreateOptions
{
ClientReferenceId = User.Identity.GetUserId(),
SuccessUrl = ConfigurationManager.AppSettings["BaseUrl"] + "/PaymentComplete",
CancelUrl = ConfigurationManager.AppSettings["BaseUrl"] + "/Subscribe",
LineItems = new List<SessionLineItemOptions>
{
new SessionLineItemOptions
{
Price = model.PriceId,
Quantity =long.Parse(model.Quantity)
},
},
Mode = "payment",
};
var service = new SessionService();
var session = service.Create(options);
return Redirect(session.Url);
}
reviewed stripe.com documentation. It appears I am setting it correctly. The other questions posted is one is really not answered and the other one says it should be in that webhook event. I dumped the values and it should client_reference_id: null
The code you shared looks correct and it's almost certain that you are not setting a value when you think you are.
The best path forward is to hardcode a value in your code and you should see that it works as expected and that the problem is the value you put in. What I would do is hardcode AAAA, confirm it's there, and then concat AAAA and the value in your variable and another string like AAAA-<userid>-BBBB and see that you get AAAA--BBBB because your string is null or empty.
This isn't a Stripe bug, that feature works as expected and is used widely but I've tested it quickly to confirm.
You can also look at the response on the Session creation after your code and just print session.ClientReferenceId and see that it's null right now.
I have initiated a Paypal Payment, got a token back. PayPal has redirected back to my site using the URL I set in the Payment. From here I get the users shipping address, update the shipping costs and wait for the user to confirm payment. However, at the same time (but in a separate function) I want to update the redirect urls (actually only the return_url if that's possible). I have the following code:
RedirectUrls redirUrls = new RedirectUrls()
{
cancel_url = ppmodel.CancelUrl + "&cancel=true",
return_url = ppmodel.ReturnUrl + "?guid=" + basket.OrderGuid
};
PatchRequest pRequest = new PatchRequest();
Patch pUrls = new Patch
{
op = "replace",
path = "/redirect_urls",
value = redirUrls
};
pRequest.Add(pUrls);
payment.Update(_apiContext, pRequest); --Error here
I am getting a server error 400 Bad Request. Can anyone tell me what I am doing wrong?
Hi I am trying to add a review to a location by an user
I have the following code in my Bll
public void AddReview(Guid locationId, ReviewDto review, UserDto user)
{
var location = _locationRepository.Get(locationId);
var reviewModel = new Review
{
Comment = review.Comment,
Rate = review.Rate,
Location = location,
LocationId = location.Id,
User = new User
{
Name = user.Name,
Email = user.Email,
Password = user.Password
},
UserId = user.Id
};
_reviewRepository.Add(reviewModel);
_reviewRepository.Save();
location.AddReview(reviewModel);
}
}
It's possible to sent User and Review both from Post ?
How U.R.I. should look like .. I think about
/api/location/{id}/review/user (POST)....I don't know , I would appreciate some Help ..Thanks !!
One way of doing this would be POSTing that exact payload at
/api/location/{id}/review
I'd say you'd only use the /user endpoint when accessing that resource, because it would be weird POSTing a review (basically) to the user endpoint. If you're talking about REST level 3, you could have a link from the review to the user. Alternatively you could simply embed the user inside the review resource as to get them both in one call.
That being said, the most orthodox approach would probably adding them in steps (add a review, go to the resource, follow some sort of user-add relationship and POST a user.
Question background:
I've been developing with the PayPal C# API and have implemented an 'Express Checkout' solution. This works perfectly but I can only pay with a PayPal account. I of course want the ability to also pay with Cards.
Code:
Parameters set as part of my request to the API:
encoder["METHOD"] = "SetExpressCheckout";
encoder["RETURNURL"] = returnURL;
encoder["CANCELURL"] = cancelURL;
encoder["BRANDNAME"] = "Test App";
encoder["PAYMENTREQUEST_0_AMT"] = "120.00";
encoder["PAYMENTREQUEST_0_ITEMAMT"] = "120.00";
encoder["PAYMENTREQUEST_0_PAYMENTACTION"] = "Sale";
encoder["PAYMENTREQUEST_0_CURRENCYCODE"] = "USD";
encoder["L_PAYMENTREQUEST_0_NAME1"] = "test1";
encoder["L_PAYMENTREQUEST_0_AMT1"] = "20.00";
encoder["L_PAYMENTREQUEST_0_QTY1"] = "1";
encoder["L_PAYMENTREQUEST_0_NAME2"] = "test2";
encoder["L_PAYMENTREQUEST_0_AMT2"] = "20.00";
encoder["L_PAYMENTREQUEST_0_QTY2"] = "2";
encoder["L_PAYMENTREQUEST_0_NAME3"] = "test3";
encoder["L_PAYMENTREQUEST_0_AMT3"] = "20.00";
encoder["L_PAYMENTREQUEST_0_QTY3"] = "3";
Current Implementation:
Users are taken to PayPal to pay through their account then returned to my site:
What I require:
I need the user to be able to pay both through their account or with a card if they do not have a PayPal account, then be returned to my site. Is this possible through the Express checkout? If so then how do I implement it?:
You need to make sure "PayPal Account Optional" is enabled in your PayPal account profile under Website Payment Preferences.
Then in your SetExpressCheckoutRequest you need to include the following parameters:
SOLUTIONTYPE=Sole
LANDINGPAGE=Billing
USERSELECTEDFUNDINGSOURCE=CreditCard
Then you also need to make sure you have the API version updated to at least 109.0. That should give you what you're after.
I have a website in which I process my user's customer's payments into their(my users) paypal account. I've created a paypal application and under the 3rd party settings I included the ability to process debit and credit card payments. Using a 3rd party account, I granted access through the third party permissions to my username. Through those steps I believe I have I've granted proper access on the paypal side.
Here is my c# code where I setup the configuration:
Dictionary<string, string> PaypalConfig = new Dictionary<string, string>();
PaypalConfig.Add("account1.apiUsername", "my api username");
PaypalConfig.Add("account1.apiPassword", "my api password");
PaypalConfig.Add("account1.apiSignature", "my api signature");
PaypalConfig.Add("subject", "email address of my user");
PaypalConfig.Add("account1.applicationId", "my app id");
PaypalConfig.Add("mode", "live");
OAuthTokenCredential tokenCredential = new OAuthTokenCredential("my client id", "my client secret", PaypalConfig);
string accessToken = tokenCredential.GetAccessToken();
//Code to fill in the transaction details
//Create Payment
Payment payment = new Payment();
payment.intent = "sale";
payment.payer = payer;
payment.transactions = transactions;
Payment createdPayment = payment.Create(accessToken);
When I run a transaction, the payment comes back approved but seems it is ignoring the subject, and money is deposited into MY ACCOUNT.
I found documentation on sending an invoice for a third party at https://developer.paypal.com/docs/classic/invoicing/ht_invoicing-3p/, but in the REST API I really do not see anything mentioned about processing 3rd party payments. It seems that I am missing something in regards to using the 3rd party account. Any help is appreciated!
Why dont you use simple redirect option to process the payments, this way, all you need to mention is your user's merchant email.
You need to pass the variables in the following format:
private void PayPal()
{
string _MerchantEmail = "youremailwithpaypal#domain.com";
string _ReturnURL = "https://www.yourwebsite.com/paymentsuccess";
string _CancelURL = "https://www.yourwebsite.com/paymentfailed";
string _CurrencyCode = "USD";
int _Amount = 100;
string _ItemName = "itme1"; //We are using this field to pass the order number
int _Discount = 10;
double _Tax = 1.5;
string _PayPalURL = $"https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business={_MerchantEmail}&return={_ReturnURL}&cancel_return={_CancelURL}¤cy_code={_CurrencyCode}&amount={_Amount}&item_name={_ItemName}&discount_amount={_Discount}&tax={_Tax}";
Response.Redirect(_PayPalURL);
}
You might also need a callback URL for PayPal IPN to verify the payments status. But for your question above this should work as we are already using this code in our website.