Payment
Get Payment Methods
Gets a collection of PaymentMethod
objects.
Usage
var paymentMethods = UCommerce.Api.TransactionLibrary.GetPaymentMethods(); var danishPaymentMethods = UCommerce.Api.TransactionLibrary.GetPaymentMethods(denmark);
Parameters
Parameter | Type | Details |
---|---|---|
country | Country | Specifying which country defined in Ucommerce, to get the payment methods from |
Create Payment
Creates a new payment of the specified amount, by requesting the specified IPaymentMethodService
.
Usage
UCommerce.Api.TransactionLibrary.CreatePayment(newPaymentMethodId, requestPayment: false); UCommerce.Api.TransactionLibrary.ExecuteBasketPipeline(); HttpContext.Current.Response.Redirect("Preview.aspx");
Parameters
Parameter | Type | Details |
---|---|---|
paymentMethodId | int | The id of the payment method to use for the payment. |
amount | decimal | The payment amount. This is the current basket order total by default. |
requestPayment | bool | If the payment should be requested immediately. Set to true by default. |
overwriteExisting | bool | If the existing payment on the current customer's basket should be overwritten. Set to true by default. |
Request Payments
Marked as obsolete from version 7.18. Please see the section Request Payment Page URL.
Requests the payments, and potentially redirects customers to the payment gateway.
Usage
UCommerce.Api.TransactionLibrary.RequestPayments();
Request Payment
Marked as obsolete from version 7.18. Please see the section Request Payment Page URL.
Requests a single payment, and potentially redirects customers to the payment gateway.
Usage
UCommerce.Api.TransactionLibrary.RequestPayment(1);
Parameters
Parameter | Type | Details |
---|---|---|
paymentId | int | The id of the payment to request |
Request Payment Page URL
In version 7.18 TransactionLibrary.RequestPayments() and TransactionLibrary.RequestPayment() have been marked as obsolete. This change does not affect current implementations of payment providers, it is a reminder of the fact, that the old methods will be removed soon and we suggest using the new way of requesting payments which you can see in the code below.
var payment = TransactionLibrary.GetBasket().PurchaseOrder.Payments.First(); string paymentUrl = TransactionLibrary.GetPaymentPageUrl(payment); Response.Redirect(paymentUrl); // or in MVC return Redirect(paymentUrl);
The code does the same as RequestPayment() did in the past, but now the redirect is explicitly in the client, which is the behavior that is required across all of our CMSs.
Checkout
Converts a Basket
to a PurchaseOrder
, and executes the checkout pipeline for the current basket.
This method is generally only used if you don't use a payment provider since the payment providers usually handles this step automatically.
Usage
UCommerce.Api.TransactionLibrary.Checkout();