- preparePayForPaivana#
Prepare a payment for an HTTP(S) resource protected by a Paivana paywall.
The wallet requests the given
url, expects an HTTP 402 response that advertises a payment template in thePaivanaheader, instantiates that template into an order and creates (or reuses) a payment transaction for it. The returnedpaivanaredemption metadata must be kept by the client; once the payment has succeeded, it is passed to getPaivanaCookie to obtain the access cookie for the resource.Request:
The
argsmust be a PreparePayForPaivanaRequest object.Response:
On success, the result is a PreparePayForPaivanaResult object.
Side effects:
Fetches the contract terms for the Paivana-protected resource over the network and creates a payment transaction in dialog state.
Expected errors:
The caller can handle the following errors inline:
WALLET_CORE_API_BAD_REQUEST,WALLET_RECEIVED_MALFORMED_RESPONSE,WALLET_NETWORK_ERROR,WALLET_HTTP_REQUEST_THROTTLED,WALLET_HTTP_REQUEST_GENERIC_TIMEOUT,WALLET_UNEXPECTED_REQUEST_ERROR,WALLET_CONTRACT_TERMS_UNSUPPORTED.
interface PreparePayForPaivanaRequest {
// URL of the Paivana-protected resource to pay for.
url: string;
// Enables progress correlation and cancellation through
// cancelProgressToken.
progressToken?: string;
}
interface PreparePayForPaivanaResult {
// Transaction identifier of the payment transaction.
transactionId: TransactionIdStr;
paivana: PaivanaRedemption;
}
// Information needed to redeem a paid Paivana order for an
// access cookie.
interface PaivanaRedemption {
// Canonical HTTP(S) URL of the protected resource.
url: string;
// Crockford-base32 encoded 16-byte client nonce.
nonce: string;
// End of the access period used to derive the Paivana
// session ID.
expiration: TalerProtocolTimestamp;
}