private void setKeyResponseObjects(PayPalAPIInterfaceServiceService service, BMGetInventoryResponseType response) { HttpContext CurrContext = HttpContext.Current; CurrContext.Items.Add("Response_apiName", "BMGetInventory"); CurrContext.Items.Add("Response_redirectURL", null); CurrContext.Items.Add("Response_requestPayload", service.getLastRequest()); CurrContext.Items.Add("Response_responsePayload", service.getLastResponse()); Dictionary<string, string> responseParams = new Dictionary<string, string>(); responseParams.Add("Correlation Id", response.CorrelationID); responseParams.Add("API Result", response.Ack.ToString()); if (response.Ack.Equals(AckCodeType.FAILURE) || (response.Errors != null && response.Errors.Count > 0)) { CurrContext.Items.Add("Response_error", response.Errors); } else { CurrContext.Items.Add("Response_error", null); responseParams.Add("Is inventory tracked", response.TrackInv); responseParams.Add("Is Profit & Loss tracked", response.TrackPnl); responseParams.Add("Item Number", response.ItemTrackingDetails.ItemNumber); responseParams.Add("Item Quantity", response.ItemTrackingDetails.ItemQty); responseParams.Add("Item Cost", response.ItemTrackingDetails.ItemCost); responseParams.Add("Item Alert threshold quantity", response.ItemTrackingDetails.ItemAlert); responseParams.Add("Soldout URL", response.SoldoutURL); } CurrContext.Items.Add("Response_keyResponseObject", responseParams); Server.Transfer("../APIResponse.aspx"); }
protected void Submit_Click(object sender, EventArgs e) { // Create request object DoReferenceTransactionRequestType request = new DoReferenceTransactionRequestType(); populateRequestObject(request); // Invoke the API DoReferenceTransactionReq wrapper = new DoReferenceTransactionReq(); wrapper.DoReferenceTransactionRequest = request; // Configuration map containing signature credentials and other required configuration. // For a full list of configuration parameters refer in wiki page // [https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters] Dictionary<string, string> configurationMap = Configuration.GetAcctAndConfig(); // Create the PayPalAPIInterfaceServiceService service object to make the API call PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap); // # API call // Invoke the DoReferenceTransaction method in service wrapper object DoReferenceTransactionResponseType doReferenceTxnResponse = service.DoReferenceTransaction(wrapper); // Check for API return status setKeyResponseObjects(service, doReferenceTxnResponse); }
public ActionResult AgreementConfirmed(string token) { var service = new PayPalAPIInterfaceServiceService(); var request = new CreateBillingAgreementReq { CreateBillingAgreementRequest = new CreateBillingAgreementRequestType(token) }; var response = service.CreateBillingAgreement(request); if (response.Ack == AckCodeType.SUCCESS) { var billingAgreementId = response.BillingAgreementID; // store the billing agreement id in a cookie Response.Cookies.Add(new HttpCookie("pp_aid", billingAgreementId) { Expires = DateTime.Now.AddDays(365) }); return View(new AgreementConfirmedViewData { BillingAgreementId = billingAgreementId }); } else { foreach (var error in response.Errors) { ModelState.AddModelError("__FORM", error.LongMessage); } } return View("Error"); }
private void processResponse(PayPalAPIInterfaceServiceService service, EnterBoardingResponseType response) { HttpContext CurrContext = HttpContext.Current; CurrContext.Items.Add("Response_apiName", "EnterBoarding"); if (response.Token != null) { string baseUrl = ConfigurationManager.AppSettings["PAYPAL_REDIRECT_URL"].ToString().ToLower(); CurrContext.Items.Add("Response_redirectURL", baseUrl + "_partner-onboard-flow&onboarding_token=" + response.Token); } CurrContext.Items.Add("Response_requestPayload", service.getLastRequest()); CurrContext.Items.Add("Response_responsePayload", service.getLastResponse()); Dictionary<string, string> keyParameters = new Dictionary<string, string>(); keyParameters.Add("Correlation Id", response.CorrelationID); keyParameters.Add("API Result", response.Ack.ToString()); if (response.Errors != null && response.Errors.Count > 0) { CurrContext.Items.Add("Response_error", response.Errors); } else { CurrContext.Items.Add("Response_error", null); } if (!response.Ack.Equals(AckCodeType.FAILURE)) { } CurrContext.Items.Add("Response_keyResponseObject", keyParameters); Server.Transfer("../APIResponse.aspx"); }
protected void Submit_Click(object sender, EventArgs e) { // Create request object DoVoidRequestType request = new DoVoidRequestType(); // (Required) Original authorization ID specifying the authorization to void or, to void an order, the order ID. // Important: If you are voiding a transaction that has been reauthorized, use the ID from the original authorization, and not the reauthorization. request.AuthorizationID = authorizationId.Value; // (Optional) Informational note about this void that is displayed to the buyer in email and in their transaction history. if (note.Value != string.Empty) { request.Note = note.Value; } // Invoke the API DoVoidReq wrapper = new DoVoidReq(); wrapper.DoVoidRequest = request; // Configuration map containing signature credentials and other required configuration. // For a full list of configuration parameters refer in wiki page // [https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters] Dictionary<string, string> configurationMap = Configuration.GetAcctAndConfig(); // Create the PayPalAPIInterfaceServiceService service object to make the API call PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap); // # API call // Invoke the DoVoid method in service wrapper object DoVoidResponseType doVoidResponse = service.DoVoid(wrapper); // Check for API return status setKeyResponseObjects(service, doVoidResponse); }
protected void Submit_Click(object sender, EventArgs e) { // Create request object BMGetButtonDetailsRequestType request = new BMGetButtonDetailsRequestType(); // (Required) The ID of the hosted button whose details you want to obtain. request.HostedButtonID = hostedID.Value; // Invoke the API BMGetButtonDetailsReq wrapper = new BMGetButtonDetailsReq(); wrapper.BMGetButtonDetailsRequest = request; // Configuration map containing signature credentials and other required configuration. // For a full list of configuration parameters refer in wiki page // (https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters) Dictionary<string, string> configurationMap = Configuration.GetAcctAndConfig(); // Creating service wrapper object to make an API call by loading configuration map. PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap); BMGetButtonDetailsResponseType response = service.BMGetButtonDetails(wrapper); // Check for API return status setKeyResponseObjects(service, response); }
protected void Submit_Click(object sender, EventArgs e) { // Create request object SetCustomerBillingAgreementRequestType request = new SetCustomerBillingAgreementRequestType(); SetCustomerBillingAgreementRequestDetailsType requestDetails = new SetCustomerBillingAgreementRequestDetailsType(); requestDetails.BuyerEmail = buyerEmail.Value; requestDetails.ReturnURL = returnUrl.Value; requestDetails.CancelURL = cancelUrl.Value; BillingAgreementDetailsType baDetails = new BillingAgreementDetailsType(); baDetails.BillingAgreementDescription = billingAgreementText.Value; baDetails.BillingType = (BillingCodeType) Enum.Parse( typeof(BillingCodeType), billingType.SelectedValue); requestDetails.BillingAgreementDetails = baDetails; request.SetCustomerBillingAgreementRequestDetails = requestDetails; // Invoke the API SetCustomerBillingAgreementReq wrapper = new SetCustomerBillingAgreementReq(); wrapper.SetCustomerBillingAgreementRequest = request; PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(); SetCustomerBillingAgreementResponseType setCustomerBillingAgreementResponse = service.SetCustomerBillingAgreement(wrapper); // Check for API return status setKeyResponseObjects(service, setCustomerBillingAgreementResponse); }
// A helper method used by APIResponse.aspx that returns select response parameters // of interest. private void setKeyResponseObjects(PayPalAPIInterfaceServiceService service, AddressVerifyResponseType response) { HttpContext CurrContext = HttpContext.Current; CurrContext.Items.Add("Response_apiName", "AddressVerify"); CurrContext.Items.Add("Response_redirectURL", null); CurrContext.Items.Add("Response_requestPayload", service.getLastRequest()); CurrContext.Items.Add("Response_responsePayload", service.getLastResponse()); Dictionary<string, string> keyResponseParameters = new Dictionary<string, string>(); keyResponseParameters.Add("Correlation Id", response.CorrelationID); keyResponseParameters.Add("API Result", response.Ack.ToString()); if (response.Ack.Equals(AckCodeType.FAILURE) || (response.Errors != null && response.Errors.Count > 0)) { CurrContext.Items.Add("Response_error", response.Errors); } else { CurrContext.Items.Add("Response_error", null); keyResponseParameters.Add("Address confirmation code", response.ConfirmationCode.ToString()); keyResponseParameters.Add("Street address match", response.StreetMatch.ToString()); keyResponseParameters.Add("Zip code match", response.ZipMatch.ToString()); } CurrContext.Items.Add("Response_keyResponseObject", keyResponseParameters); Server.Transfer("../APIResponse.aspx"); }
protected void Submit_Click(object sender, EventArgs e) { // Create request object ManageRecurringPaymentsProfileStatusRequestType request = new ManageRecurringPaymentsProfileStatusRequestType(); ManageRecurringPaymentsProfileStatusRequestDetailsType details = new ManageRecurringPaymentsProfileStatusRequestDetailsType(); request.ManageRecurringPaymentsProfileStatusRequestDetails = details; details.ProfileID = profileId.Value; details.Action = (StatusChangeActionType) Enum.Parse(typeof(StatusChangeActionType), action.SelectedValue); if (note.Value != "") { details.Note = note.Value; } // Invoke the API ManageRecurringPaymentsProfileStatusReq wrapper = new ManageRecurringPaymentsProfileStatusReq(); wrapper.ManageRecurringPaymentsProfileStatusRequest = request; PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(); ManageRecurringPaymentsProfileStatusResponseType manageProfileStatusResponse = service.ManageRecurringPaymentsProfileStatus(wrapper); // Check for API return status setKeyResponseObjects(service, manageProfileStatusResponse); }
private void setKeyResponseObjects(PayPalAPIInterfaceServiceService service, DoUATPExpressCheckoutPaymentResponseType response) { HttpContext CurrContext = HttpContext.Current; CurrContext.Items.Add("Response_apiName", "DoUATPExpressCheckoutPayment"); CurrContext.Items.Add("Response_redirectURL", null); CurrContext.Items.Add("Response_requestPayload", service.getLastRequest()); CurrContext.Items.Add("Response_responsePayload", service.getLastResponse()); Dictionary<string, string> responseParams = new Dictionary<string, string>(); responseParams.Add("Correlation Id", response.CorrelationID); responseParams.Add("API Result", response.Ack.ToString()); if (response.Ack.Equals(AckCodeType.FAILURE) || (response.Errors != null && response.Errors.Count > 0)) { CurrContext.Items.Add("Response_error", response.Errors); } else { CurrContext.Items.Add("Response_error", null); responseParams.Add("Transaction Id", response.DoExpressCheckoutPaymentResponseDetails.PaymentInfo[0].TransactionID); responseParams.Add("UATP number", response.UATPDetails.UATPNumber); } CurrContext.Items.Add("Response_keyResponseObject", responseParams); Server.Transfer("../APIResponse.aspx"); }
protected void Submit_Click(object sender, EventArgs e) { // Create request object AddressVerifyRequestType request = new AddressVerifyRequestType(); // (Required) Email address of a PayPal member to verify. request.Email = email.Value; // (Required) First line of the billing or shipping postal address to verify. To pass verification, the value of Street must match the first 3 single-byte characters of a postal address on file for the PayPal member. request.Street = street.Value; // (Required) Postal code to verify. To pass verification, the value of Zip must match the first 5 single-byte characters of the postal code of the verified postal address for the verified PayPal member. request.Zip = zip.Value; // Invoke the API AddressVerifyReq wrapper = new AddressVerifyReq(); wrapper.AddressVerifyRequest = request; // Configuration map containing signature credentials and other required configuration. // For a full list of configuration parameters refer in wiki page // [https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters] Dictionary<string, string> configurationMap = Configuration.GetAcctAndConfig(); // Create the PayPalAPIInterfaceServiceService service object to make the API call PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap); // # API call // Invoke the AddressVerify method in service wrapper object AddressVerifyResponseType addressVerifyResponse = service.AddressVerify(wrapper); // Check for API return status setKeyResponseObjects(service, addressVerifyResponse); }
protected void Submit_Click(object sender, EventArgs e) { // Create request object DoUATPExpressCheckoutPaymentRequestType request = new DoUATPExpressCheckoutPaymentRequestType(); DoExpressCheckoutPaymentRequestDetailsType paymentDetails = new DoExpressCheckoutPaymentRequestDetailsType(); request.DoExpressCheckoutPaymentRequestDetails = paymentDetails; paymentDetails.PayerID = payerID.Value; paymentDetails.Token = token.Value; paymentDetails.PaymentAction = (PaymentActionCodeType) Enum.Parse(typeof(PaymentActionCodeType), paymentAction.SelectedValue); // Set payment amount CurrencyCodeType currency = (CurrencyCodeType) Enum.Parse(typeof(CurrencyCodeType), currencyID.Value); paymentDetails.PaymentDetails.Add(new PaymentDetailsType()); paymentDetails.PaymentDetails[0].OrderTotal = new BasicAmountType(currency, amount.Value); // Invoke the API DoUATPExpressCheckoutPaymentReq wrapper = new DoUATPExpressCheckoutPaymentReq(); wrapper.DoUATPExpressCheckoutPaymentRequest = request; // Configuration map containing signature credentials and other required configuration. // For a full list of configuration parameters refer in wiki page // [https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters] Dictionary<string, string> configurationMap = Configuration.GetAcctAndConfig(); PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap); DoUATPExpressCheckoutPaymentResponseType response = service.DoUATPExpressCheckoutPayment(wrapper); // Check for API return status setKeyResponseObjects(service, response); }
// # GetExpressCheckout API Operation // The GetExpressCheckoutDetails API operation obtains information about an Express Checkout transaction public GetExpressCheckoutDetailsResponseType GetExpressCheckoutDetailsAPIOperation() { // Create the GetExpressCheckoutDetailsResponseType object GetExpressCheckoutDetailsResponseType responseGetExpressCheckoutDetailsResponseType = new GetExpressCheckoutDetailsResponseType(); try { // Create the GetExpressCheckoutDetailsReq object GetExpressCheckoutDetailsReq getExpressCheckoutDetails = new GetExpressCheckoutDetailsReq(); // A timestamped token, the value of which was returned by `SetExpressCheckout` response GetExpressCheckoutDetailsRequestType getExpressCheckoutDetailsRequest = new GetExpressCheckoutDetailsRequestType("EC-11U13522TP7143059"); getExpressCheckoutDetails.GetExpressCheckoutDetailsRequest = getExpressCheckoutDetailsRequest; // Create the service wrapper object to make the API call PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(); // # API call // Invoke the GetExpressCheckoutDetails method in service wrapper object responseGetExpressCheckoutDetailsResponseType = service.GetExpressCheckoutDetails(getExpressCheckoutDetails); if (responseGetExpressCheckoutDetailsResponseType != null) { // Response envelope acknowledgement string acknowledgement = "GetExpressCheckoutDetails API Operation - "; acknowledgement += responseGetExpressCheckoutDetailsResponseType.Ack.ToString(); logger.Info(acknowledgement + "\n"); Console.WriteLine(acknowledgement + "\n"); // # Success values if (responseGetExpressCheckoutDetailsResponseType.Ack.ToString().Trim().ToUpper().Equals("SUCCESS")) { // Unique PayPal Customer Account identification number. This // value will be null unless you authorize the payment by // redirecting to PayPal after `SetExpressCheckout` call. logger.Info("Payer ID : " + responseGetExpressCheckoutDetailsResponseType.GetExpressCheckoutDetailsResponseDetails.PayerInfo.PayerID + "\n"); Console.WriteLine("Payer ID : " + responseGetExpressCheckoutDetailsResponseType.GetExpressCheckoutDetailsResponseDetails.PayerInfo.PayerID + "\n"); } // # Error Values else { List<ErrorType> errorMessages = responseGetExpressCheckoutDetailsResponseType.Errors; foreach (ErrorType error in errorMessages) { logger.Debug("API Error Message : " + error.LongMessage); Console.WriteLine("API Error Message : " + error.LongMessage + "\n"); } } } } // # Exception log catch (System.Exception ex) { // Log the exception message logger.Debug("Error Message : " + ex.Message); Console.WriteLine("Error Message : " + ex.Message); } return responseGetExpressCheckoutDetailsResponseType; }
protected void Submit_Click(object sender, EventArgs e) { // Create request object GetBalanceRequestType request = new GetBalanceRequestType(); // (Optional) Indicates whether to return all currencies. It is one of the following values: // * 0 – Return only the balance for the primary currency holding. // * 1 – Return the balance for each currency holding. // Note: This field is available since version 51. Prior versions return only the balance for the primary currency holding. request.ReturnAllCurrencies = returnAllCurrencies.SelectedValue; // Invoke the API GetBalanceReq wrapper = new GetBalanceReq(); wrapper.GetBalanceRequest = request; // Configuration map containing signature credentials and other required configuration. // For a full list of configuration parameters refer in wiki page // [https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters] Dictionary<string, string> configurationMap = Configuration.GetAcctAndConfig(); // Create the PayPalAPIInterfaceServiceService service object to make the API call PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap); // # API call // Invoke the GetBalance method in service wrapper object GetBalanceResponseType getBalanceResponse = service.GetBalance(wrapper); // Check for API return status processResponse(service, getBalanceResponse); }
protected void Submit_Click(object sender, EventArgs e) { // Create request object DoUATPAuthorizationRequestType request = new DoUATPAuthorizationRequestType(); request.UATPDetails = new UATPDetailsType(); request.UATPDetails.UATPNumber = uatpNumber.Value; request.UATPDetails.ExpMonth = Convert.ToInt32(expMonth.Value); request.UATPDetails.ExpYear = Convert.ToInt32(expYear.Value); request.TransactionEntity = (TransactionEntityType) Enum.Parse(typeof(TransactionEntityType), transactionEntity.SelectedValue); CurrencyCodeType currency = (CurrencyCodeType) Enum.Parse( typeof(CurrencyCodeType), currencyID.Value); request.Amount = new BasicAmountType(currency, amount.Value); // Invoke the API DoUATPAuthorizationReq wrapper = new DoUATPAuthorizationReq(); wrapper.DoUATPAuthorizationRequest = request; // Configuration map containing signature credentials and other required configuration. // For a full list of configuration parameters refer in wiki page // [https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters] Dictionary<string, string> configurationMap = Configuration.GetAcctAndConfig(); PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap); DoUATPAuthorizationResponseType response = service.DoUATPAuthorization(wrapper); // Check for API return status setKeyResponseObjects(service, response); }
protected void Submit_Click(object sender, EventArgs e) { // Create request object BillOutstandingAmountRequestType request = new BillOutstandingAmountRequestType(); BillOutstandingAmountRequestDetailsType details = new BillOutstandingAmountRequestDetailsType(); request.BillOutstandingAmountRequestDetails = details; details.ProfileID = profileId.Value; if (currencyCode.SelectedIndex != 0 && amount.Value != "") { CurrencyCodeType currency = (CurrencyCodeType) Enum.Parse(typeof(CurrencyCodeType), currencyCode.SelectedValue); details.Amount = new BasicAmountType(currency, amount.Value); } if (note.Value != "") { details.Note = note.Value; } // Invoke the API BillOutstandingAmountReq wrapper = new BillOutstandingAmountReq(); wrapper.BillOutstandingAmountRequest = request; PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(); BillOutstandingAmountResponseType response = service.BillOutstandingAmount(wrapper); // Check for API return status setKeyResponseObjects(service, response); }
private void setKeyResponseObjects(PayPalAPIInterfaceServiceService service, DoUATPAuthorizationResponseType response) { HttpContext CurrContext = HttpContext.Current; CurrContext.Items.Add("Response_apiName", "DoUATPAuthorization"); CurrContext.Items.Add("Response_redirectURL", null); CurrContext.Items.Add("Response_requestPayload", service.getLastRequest()); CurrContext.Items.Add("Response_responsePayload", service.getLastResponse()); Dictionary<string, string> responseParams = new Dictionary<string, string>(); responseParams.Add("Correlation Id", response.CorrelationID); responseParams.Add("API Result", response.Ack.ToString()); if (response.Ack.Equals(AckCodeType.FAILURE) || (response.Errors != null && response.Errors.Count > 0)) { CurrContext.Items.Add("Response_error", response.Errors); } else { CurrContext.Items.Add("Response_error", null); responseParams.Add("Transaction Id", response.AuthorizationCode); responseParams.Add("Payment status", response.AuthorizationInfo.PaymentStatus.ToString()); if (response.AuthorizationInfo.PendingReason != null) { responseParams.Add("Pending reason", response.AuthorizationInfo.PendingReason.ToString()); } } CurrContext.Items.Add("Response_keyResponseObject", responseParams); Server.Transfer("../APIResponse.aspx"); }
protected void Submit_Click(object sender, EventArgs e) { PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(); GetExpressCheckoutDetailsReq getECWrapper = new GetExpressCheckoutDetailsReq(); getECWrapper.GetExpressCheckoutDetailsRequest = new GetExpressCheckoutDetailsRequestType(token.Value); GetExpressCheckoutDetailsResponseType getECResponse = service.GetExpressCheckoutDetails(getECWrapper); // Create request object DoExpressCheckoutPaymentRequestType request = new DoExpressCheckoutPaymentRequestType(); DoExpressCheckoutPaymentRequestDetailsType requestDetails = new DoExpressCheckoutPaymentRequestDetailsType(); request.DoExpressCheckoutPaymentRequestDetails = requestDetails; requestDetails.PaymentDetails = getECResponse.GetExpressCheckoutDetailsResponseDetails.PaymentDetails; requestDetails.Token = token.Value; requestDetails.PayerID = payerId.Value; requestDetails.PaymentAction = (PaymentActionCodeType) Enum.Parse(typeof(PaymentActionCodeType), paymentAction.SelectedValue); // Invoke the API DoExpressCheckoutPaymentReq wrapper = new DoExpressCheckoutPaymentReq(); wrapper.DoExpressCheckoutPaymentRequest = request; DoExpressCheckoutPaymentResponseType doECResponse = service.DoExpressCheckoutPayment(wrapper); // Check for API return status setKeyResponseObjects(service, doECResponse); }
protected void Submit_Click(object sender, EventArgs e) { // Create request object GetBillingAgreementCustomerDetailsRequestType request = new GetBillingAgreementCustomerDetailsRequestType(); // (Required) The time-stamped token returned in the SetCustomerBillingAgreement response. // Note: The token expires after 3 hours. request.Token = token.Value; // Invoke the API GetBillingAgreementCustomerDetailsReq wrapper = new GetBillingAgreementCustomerDetailsReq(); wrapper.GetBillingAgreementCustomerDetailsRequest = request; // Configuration map containing signature credentials and other required configuration. // For a full list of configuration parameters refer in wiki page // [https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters] Dictionary<string, string> configurationMap = Configuration.GetAcctAndConfig(); // Create the PayPalAPIInterfaceServiceService service object to make the API call PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap); // # API call // Invoke the GetBillingAgreementCustomerDetails method in service wrapper object GetBillingAgreementCustomerDetailsResponseType getBillingAgreementCustomerDetailsResponse = service.GetBillingAgreementCustomerDetails(wrapper); // Check for API return status setKeyResponseObjects(service, getBillingAgreementCustomerDetailsResponse); }
// A helper method used by APIResponse.aspx that returns select response parameters // of interest. You must process API response objects as applicable to your application private void setKeyResponseObjects(PayPalAPIInterfaceServiceService service, DoExpressCheckoutPaymentResponseType doECResponse) { Dictionary<string, string> responseParams = new Dictionary<string, string>(); responseParams.Add("Correlation Id", doECResponse.CorrelationID); responseParams.Add("API Result", doECResponse.Ack.ToString()); HttpContext CurrContext = HttpContext.Current; if (doECResponse.Ack.Equals(AckCodeType.FAILURE) || (doECResponse.Errors != null && doECResponse.Errors.Count > 0)) { CurrContext.Items.Add("Response_error", doECResponse.Errors); } else { CurrContext.Items.Add("Response_error", null); responseParams.Add("EC Token", doECResponse.DoExpressCheckoutPaymentResponseDetails.Token); responseParams.Add("Transaction Id", doECResponse.DoExpressCheckoutPaymentResponseDetails.PaymentInfo[0].TransactionID); responseParams.Add("Payment status", doECResponse.DoExpressCheckoutPaymentResponseDetails.PaymentInfo[0].PaymentStatus.ToString()); if (doECResponse.DoExpressCheckoutPaymentResponseDetails.PaymentInfo[0].PendingReason != null) { responseParams.Add("Pending reason", doECResponse.DoExpressCheckoutPaymentResponseDetails.PaymentInfo[0].PendingReason.ToString()); } if (doECResponse.DoExpressCheckoutPaymentResponseDetails.BillingAgreementID != null) responseParams.Add("Billing Agreement Id", doECResponse.DoExpressCheckoutPaymentResponseDetails.BillingAgreementID); } CurrContext.Items.Add("Response_keyResponseObject", responseParams); CurrContext.Items.Add("Response_apiName", "DoExpressChecoutPayment"); CurrContext.Items.Add("Response_redirectURL", null); CurrContext.Items.Add("Response_requestPayload", service.getLastRequest()); CurrContext.Items.Add("Response_responsePayload", service.getLastResponse()); Server.Transfer("../APIResponse.aspx"); }
protected void Submit_Click(object sender, EventArgs e) { // Create request object EnterBoardingRequestType request = new EnterBoardingRequestType(); EnterBoardingRequestDetailsType boardingDetails = new EnterBoardingRequestDetailsType(); boardingDetails.ProductList = productList.Value; boardingDetails.ProgramCode = programCode.Value; boardingDetails.ImageUrl = imageUrl.Value; request.EnterBoardingRequestDetails = boardingDetails; // Invoke the API EnterBoardingReq wrapper = new EnterBoardingReq(); wrapper.EnterBoardingRequest = request; // Configuration map containing signature credentials and other required configuration. // For a full list of configuration parameters refer in wiki page // [https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters] Dictionary<string, string> configurationMap = Configuration.GetAcctAndConfig(); PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap); EnterBoardingResponseType enterBoardingResponse = service.EnterBoarding(wrapper); // Check for API return status processResponse(service, enterBoardingResponse); }
/// <summary> /// Processes the Authorize and AuthorizeAndCapture transactions /// </summary> /// <param name="invoice">The <see cref="IInvoice"/> to be paid</param> /// <param name="payment">The <see cref="IPayment"/> record</param> /// <param name="args"></param> /// <returns>The <see cref="IPaymentResult"/></returns> public IPaymentResult ProcessPayment(IInvoice invoice, IPayment payment, ProcessorArgumentCollection args) { var setExpressCheckoutRequestDetails = new SetExpressCheckoutRequestDetailsType { ReturnURL = String.Format("{0}/App_Plugins/Merchello.PayPal/PayPalExpressCheckout.html?InvoiceKey={1}&PaymentKey={2}&PaymentMethodKey={3}", GetWebsiteUrl(), invoice.Key, payment.Key, payment.PaymentMethodKey), CancelURL = "http://localhost/cancel", PaymentDetails = new List<PaymentDetailsType> { GetPaymentDetails(invoice) } }; var setExpressCheckout = new SetExpressCheckoutReq(); var setExpressCheckoutRequest = new SetExpressCheckoutRequestType(setExpressCheckoutRequestDetails); setExpressCheckout.SetExpressCheckoutRequest = setExpressCheckoutRequest; var config = new Dictionary<string, string> { {"mode", "sandbox"}, {"account1.apiUsername", _settings.ApiUsername}, {"account1.apiPassword", _settings.ApiPassword}, {"account1.apiSignature", _settings.ApiSignature} }; var service = new PayPalAPIInterfaceServiceService(config); var responseSetExpressCheckoutResponseType = service.SetExpressCheckout(setExpressCheckout); // If this were using a service we might want to store some of the transaction data in the ExtendedData for record payment.ExtendedData.SetValue("RedirectUrl", "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=" + responseSetExpressCheckoutResponseType.Token); return new PaymentResult(Attempt<IPayment>.Succeed(payment), invoice, false); }
// A helper method used by APIResponse.aspx that returns select response parameters // of interest. private void setKeyResponseObjects(PayPalAPIInterfaceServiceService service, ReverseTransactionResponseType response) { HttpContext CurrContext = HttpContext.Current; CurrContext.Items.Add("Response_apiName", "ReverseTransaction"); CurrContext.Items.Add("Response_redirectURL", null); CurrContext.Items.Add("Response_requestPayload", service.getLastRequest()); CurrContext.Items.Add("Response_responsePayload", service.getLastResponse()); Dictionary<string, string> keyResponseParameters = new Dictionary<string, string>(); keyResponseParameters.Add("Correlation Id", response.CorrelationID); keyResponseParameters.Add("API Result", response.Ack.ToString()); if (response.Ack.Equals(AckCodeType.FAILURE) || (response.Errors != null && response.Errors.Count > 0)) { CurrContext.Items.Add("Response_error", response.Errors); } else { CurrContext.Items.Add("Response_error", null); keyResponseParameters.Add("Reverse Transaction ID", response.ReverseTransactionResponseDetails.ReverseTransactionID); keyResponseParameters.Add("Reversal status", response.ReverseTransactionResponseDetails.Status); } CurrContext.Items.Add("Response_keyResponseObject", keyResponseParameters); Server.Transfer("../APIResponse.aspx"); }
protected void Submit_Click(object sender, EventArgs e) { // Create request object ManagePendingTransactionStatusRequestType request = new ManagePendingTransactionStatusRequestType(); // (Required) The transaction ID of the payment transaction. request.TransactionID = transactionId.Value; // (Required) The operation you want to perform on the transaction. It is one of the following values: // * Accept – Accepts the payment // * Deny – Rejects the payment request.Action = (FMFPendingTransactionActionType) Enum.Parse(typeof(FMFPendingTransactionActionType), action.SelectedValue); // Invoke the API ManagePendingTransactionStatusReq wrapper = new ManagePendingTransactionStatusReq(); wrapper.ManagePendingTransactionStatusRequest = request; // Configuration map containing signature credentials and other required configuration. // For a full list of configuration parameters refer in wiki page // [https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters] Dictionary<string, string> configurationMap = Configuration.GetAcctAndConfig(); // Create the PayPalAPIInterfaceServiceService service object to make the API call PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap); // # API call // Invoke the ManagePendingTransactionStatus method in service wrapper object ManagePendingTransactionStatusResponseType manageProfileStatusResponse = service.ManagePendingTransactionStatus(wrapper); // Check for API return status setKeyResponseObjects(service, manageProfileStatusResponse); }
private void setKeyResponseObjects(PayPalAPIInterfaceServiceService service, DoVoidResponseType doVoidResponse) { Dictionary<string, string> responseParams = new Dictionary<string, string>(); HttpContext CurrContext = HttpContext.Current; CurrContext.Items.Add("Response_keyResponseObject", responseParams); CurrContext.Items.Add("Response_apiName", "DoVoid"); CurrContext.Items.Add("Response_redirectURL", null); CurrContext.Items.Add("Response_requestPayload", service.getLastRequest()); CurrContext.Items.Add("Response_responsePayload", service.getLastResponse()); if (doVoidResponse.Ack.Equals(AckCodeType.FAILURE) || (doVoidResponse.Errors != null && doVoidResponse.Errors.Count > 0)) { CurrContext.Items.Add("Response_error", doVoidResponse.Errors); } else { CurrContext.Items.Add("Response_error", null); responseParams.Add("Authorization Id", doVoidResponse.AuthorizationID); //Selenium Test Case responseParams.Add("Acknowledgement", doVoidResponse.Ack.ToString()); } Server.Transfer("../APIResponse.aspx"); }
protected void Submit_Click(object sender, EventArgs e) { // Create request object BAUpdateRequestType request = new BAUpdateRequestType(); request.ReferenceID = referenceId.Value; if (billingAgreementStatus.SelectedIndex != 0) { request.BillingAgreementStatus = (MerchantPullStatusCodeType) Enum.Parse(typeof(MerchantPullStatusCodeType), billingAgreementStatus.SelectedValue); } if (billingAgreementText.Value != string.Empty) { request.BillingAgreementDescription = billingAgreementText.Value; } // Invoke the API BillAgreementUpdateReq wrapper = new BillAgreementUpdateReq(); wrapper.BAUpdateRequest = request; // Configuration map containing signature credentials and other required configuration. // For a full list of configuration parameters refer in wiki page // [https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters] Dictionary<string, string> configurationMap = Configuration.GetAcctAndConfig(); // Create the PayPalAPIInterfaceServiceService service object to make the API call PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap); // # API call // Invoke the BillAgreementUpdate method in service wrapper object BAUpdateResponseType billingAgreementResponse = service.BillAgreementUpdate(wrapper); // Check for API return status setKeyResponseObjects(service, billingAgreementResponse); }
private void setKeyResponseObjects(PayPalAPIInterfaceServiceService service, GetRecurringPaymentsProfileDetailsResponseType response) { Dictionary<string, string> responseParams = new Dictionary<string, string>(); responseParams.Add("API Status", response.Ack.ToString()); HttpContext CurrContext = HttpContext.Current; CurrContext.Items.Add("Response_redirectURL", null); if (response.Ack.Equals(AckCodeType.FAILURE) || (response.Errors != null && response.Errors.Count > 0)) { CurrContext.Items.Add("Response_error", response.Errors); } else { CurrContext.Items.Add("Response_error", null); GetRecurringPaymentsProfileDetailsResponseDetailsType profileDetails = response.GetRecurringPaymentsProfileDetailsResponseDetails; responseParams.Add("Profile description", profileDetails.Description); responseParams.Add("Profile status", profileDetails.ProfileStatus.ToString()); responseParams.Add("Subscriber name", profileDetails.RecurringPaymentsProfileDetails.SubscriberName); responseParams.Add("Billing start date", profileDetails.RecurringPaymentsProfileDetails.BillingStartDate); responseParams.Add("Next billing date", profileDetails.RecurringPaymentsSummary.NextBillingDate); responseParams.Add("Payment amount", profileDetails.RegularRecurringPaymentsPeriod.Amount.value + profileDetails.RegularRecurringPaymentsPeriod.Amount.currencyID.ToString()); } CurrContext.Items.Add("Response_keyResponseObject", responseParams); CurrContext.Items.Add("Response_apiName", "GetRecurringPaymentsProfileDetails"); CurrContext.Items.Add("Response_requestPayload", service.getLastRequest()); CurrContext.Items.Add("Response_responsePayload", service.getLastResponse()); Server.Transfer("../APIResponse.aspx"); }
protected void Search_Submit(object sender, EventArgs e) { // Create request object GetTransactionDetailsRequestType request = new GetTransactionDetailsRequestType(); // (Required) Unique identifier of a transaction. // Note: The details for some kinds of transactions cannot be retrieved with GetTransactionDetails. You cannot obtain details of bank transfer withdrawals, for example. request.TransactionID = transactionId.Value; // Invoke the API GetTransactionDetailsReq wrapper = new GetTransactionDetailsReq(); wrapper.GetTransactionDetailsRequest = request; // Configuration map containing signature credentials and other required configuration. // For a full list of configuration parameters refer in wiki page // [https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters] Dictionary<string, string> configurationMap = Configuration.GetAcctAndConfig(); // Create the PayPalAPIInterfaceServiceService service object to make the API call PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap); // # API call // Invoke the GetTransactionDetails method in service wrapper object GetTransactionDetailsResponseType transactionDetails = service.GetTransactionDetails(wrapper); // Check for API return status processResponse(service, transactionDetails); }
public ActionResult AuthorizeAgreement() { var service = new PayPalAPIInterfaceServiceService(); var request = new SetExpressCheckoutReq() { SetExpressCheckoutRequest = new SetExpressCheckoutRequestType { SetExpressCheckoutRequestDetails = new SetExpressCheckoutRequestDetailsType() { BillingAgreementDetails = new List<BillingAgreementDetailsType>() { new BillingAgreementDetailsType(BillingCodeType.MERCHANTINITIATEDBILLINGSINGLEAGREEMENT) { BillingAgreementDescription = "All your money are belong to us.", } }, ReturnURL = Utilities.ToAbsoluteUrl(HttpContext, Url.Action("AgreementConfirmed")), CancelURL = Utilities.ToAbsoluteUrl(HttpContext, Url.Action("AgreementCanceled")), BuyerEmail = "*****@*****.**", BrandName = "Super Legitimate Website" } } }; var response = service.SetExpressCheckout(request); var url = String.Format("https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token={0}", response.Token); return Redirect(url); }
private void processResponse(PayPalAPIInterfaceServiceService service, RefundTransactionResponseType response) { HttpContext CurrContext = HttpContext.Current; CurrContext.Items.Add("Response_apiName", "RefundTransaction"); CurrContext.Items.Add("Response_redirectURL", null); CurrContext.Items.Add("Response_requestPayload", service.getLastRequest()); CurrContext.Items.Add("Response_responsePayload", service.getLastResponse()); Dictionary<string, string> keyParameters = new Dictionary<string, string>(); keyParameters.Add("Correlation Id", response.CorrelationID); keyParameters.Add("API Result", response.Ack.ToString()); if (response.Ack.Equals(AckCodeType.FAILURE) || (response.Errors != null && response.Errors.Count > 0)) { CurrContext.Items.Add("Response_error", response.Errors); } else { CurrContext.Items.Add("Response_error", null); keyParameters.Add("Refund transaction Id", response.RefundTransactionID); keyParameters.Add("Total refunded amount", response.TotalRefundedAmount.value + response.TotalRefundedAmount.currencyID); } CurrContext.Items.Add("Response_keyResponseObject", keyParameters); Server.Transfer("../APIResponse.aspx"); }