Table of Contents

Class PaymentResponse

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

The PaymentResponse interface of the Payment Request API is returned after a user selects a payment method and approves a payment request.

[Value("PaymentResponse")]
public class PaymentResponse : EventTarget
Inheritance
PaymentResponse
Inherited Members

Remarks

Constructors

PaymentResponse()

public PaymentResponse()

Properties

Details

The details read-only property of the
PaymentResponse interface returns a JSON-serializable object that
provides a payment method specific message used by the merchant to process the
transaction and determine a successful funds transfer.

[Value("details")]
public Object Details { get; }

Property Value

Object

An object. This data is returned by the payment app that satisfies the payment request. Developers need to consult whomever controls the URL for the expected shape of the details object.

Remarks

MethodName

The methodName read-only
property of the PaymentResponse interface returns a string uniquely
identifying the payment handler selected by the user.

[Value("methodName")]
public string MethodName { get; }

Property Value

string

A string uniquely identifying the payment handler being used to
process the payment. This may be either a standardized identifier, or a URL used by the
payment processor to handle payments. See
how merchant validation works.

Remarks

This string may be either
one of the standardized payment method identifiers or a URL used by the payment handler
to process payments.

See also on MDN

Onpayerdetailchange

[Value("onpayerdetailchange")]
public EventHandlerNonNull Onpayerdetailchange { get; set; }

Property Value

EventHandlerNonNull

PayerEmail

The payerEmail read-only property of the PaymentResponse
interface returns the email address supplied by the user. This option is only present
when the requestPayerEmail option is set to true in the
options object passed to the
'PaymentRequest.PaymentRequest' constructor.

[Value("payerEmail")]
public string? PayerEmail { get; }

Property Value

string

A string.

Remarks

PayerName

The payerName read-only property of the
PaymentResponse interface returns the name supplied by the user. This
option is only present when the requestPayerName option is set to
true in the options parameter of the
'PaymentRequest.PaymentRequest' constructor.

[Value("payerName")]
public string? PayerName { get; }

Property Value

string

A string containing the payer name.

Remarks

PayerPhone

The payerPhone read-only property of the PaymentResponse
interface returns the phone number supplied by the user. This option is only present
when the requestPayerPhone option is set to true in the
options object passed to the
'PaymentRequest.PaymentRequest' constructor.

[Value("payerPhone")]
public string? PayerPhone { get; }

Property Value

string

A string.

Remarks

RequestId

The requestId read-only property of the
PaymentResponse interface returns the free-form identifier supplied by
the PaymentResponse() constructor by details.id.

[Value("requestId")]
public string RequestId { get; }

Property Value

string

A string.

Remarks

ShippingAddress

The shippingAddress read-only property of
the PaymentRequest interface returns a 'PaymentAddress' object
containing the shipping address provided by the user.

[Value("shippingAddress")]
public ContactAddress? ShippingAddress { get; }

Property Value

ContactAddress

A PaymentAddress object providing details comprising the shipping
address provided by the user.

Remarks

ShippingOption

The shippingOption read-only property of
the PaymentRequest interface returns the ID attribute of the shipping
option selected by the user. This option is only present when the
requestShipping option is set to true in the
options object passed to the
'PaymentRequest.PaymentRequest' constructor.

[Value("shippingOption")]
public string? ShippingOption { get; }

Property Value

string

A string.

Remarks

Methods

Complete(PaymentComplete, PaymentCompleteDetails)

The PaymentRequest method
complete() of the Payment Request API notifies the
user agent that the user interaction is over, and causes any remaining
user interface to be closed.

[Value("complete")]
public Task<GlobalObject.Undefined> Complete(PaymentComplete result = PaymentComplete.Fail, PaymentCompleteDetails details = null)

Parameters

result PaymentComplete
details PaymentCompleteDetails

Returns

Task<GlobalObject.Undefined>

A Promise which resolves with no input value once the payment interface
has been fully closed. If an error occurs, the promise instead rejects, returning one of
the exceptions listed below.

Remarks

This method must be called after the user accepts
the payment request and the Promise returned by the
'PaymentRequest.Show' method is resolved.

See also on MDN

Retry(PaymentValidationErrors)

The PaymentResponse interface's
retry() method makes it possible to ask the user to
retry a payment after an error occurs during processing.

[Value("retry")]
public Task<GlobalObject.Undefined> Retry(PaymentValidationErrors errorFields = null)

Parameters

errorFields PaymentValidationErrors

Returns

Task<GlobalObject.Undefined>

A Promise which is resolved when the payment is successfully completed.
The promise is rejected with an appropriate exception value if the payment fails again.Typically you will use this by calling Show(Task<PaymentDetailsUpdate>),
then entering a loop or recursive function that checks the
PaymentResponse for errors or other reasons to retry the payment request.
If a retry is needed, the loop calls retry(), then loops back to check the
response when it comes in. The loop exits only when the user either cancels the payment
request or the request is successful.See the example below for a thorough example, but the basic
concept, in outline form, is:

Remarks

This lets your app
gracefully deal with situations such as invalid shipping addresses or declined credit
cards.

-PaymentResponse interface.

See also on MDN

ToJSON()

The toJSON() method of the PaymentResponse interface is a {{Glossary("Serialization","serializer")}}; it returns a JSON representation of the PaymentResponse object.

[Value("toJSON")]
public Object ToJSON()

Returns

Object

A {{jsxref("JSON")}} object that is the serialization of the PaymentResponse object.

Remarks