Business-Payr
view release on metacpan or search on metacpan
lib/Business/Payr/PaymentSession.pm view on Meta::CPAN
package Business::Payr::PaymentSession;
=head1 NAME
Business::Payr::PaymentSession - class representing a Payr payment session
returned by the C</thirdparty/user-login/> endpoint.
=head1 SYNOPSIS
my $Session = $Payr->create_payment_session( '[email protected]' );
# Embed the payment interface in your page
print $Session->iframe_html;
# Or build the URL yourself
my $url = $Session->url;
=head1 DESCRIPTION
A C<Business::Payr::PaymentSession> object is returned by
L<Business::Payr/create_payment_session>. It encapsulates the temporary
session URL (valid for 15 minutes) that is used to embed the Payr payment
iframe into your platform.
=cut
use strict;
use warnings;
use feature qw/ signatures /;
use Moose;
no warnings qw/ experimental::signatures /;
use namespace::autoclean;
use Carp qw/ confess /;
=head1 ATTRIBUTES
=over
=item url (Str, required)
The full iframe URL returned by the C</thirdparty/user-login/> endpoint,
including the session token and session ID as query parameters. This URL
is valid for B<15 minutes>.
Example:
https://sandbox.mypayr.co.uk/third-party?token=abc123&session_id=def456
=back
=cut
has 'url' => (
is => 'ro',
isa => 'Str',
required => 1,
);
=head1 METHODS
=head2 iframe_html
Returns an HTML C<< <iframe> >> snippet ready to embed in your page. The
iframe loads the Payr payment interface at the session URL.
my $html = $Session->iframe_html;
# Override default width / height
my $html = $Session->iframe_html( width => '80%', height => 800 );
Optional keyword arguments:
=over
=item width
The C<width> attribute of the iframe. Defaults to C<'100%'>.
=item height
The C<height> attribute of the iframe in pixels. Defaults to C<700>.
=back
Returns a plain string of HTML.
=cut
sub iframe_html ( $self, %args ) {
my $url = $self->url;
( run in 1.157 second using v1.01-cache-2.11-cpan-4ac696b4eb4 )