plenigo/CheckoutHelper.pm untested

filter: Statementstmt 0.0% 0 / 22 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 30 CC 2 SCAR 12.0
CC
2
Cov
0%
getPurchaseId
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 3.3
1 package plenigo::CheckoutHelper;
2  
3 =head1 NAME
4  
5 plenigo::CheckoutHelper - A utility class offering support for checkout functionality.
6  
7 =head1 SYNOPSIS
8  
9 use plenigo::CheckoutHelper;
10  
11 my $use_stage = 0; # set if stage system should be used
12 my $configuration = plenigo::Configuration->new(access_token => 'ACCESS_TOKEN', use_stage => $use_stage);
13
14 my $offer = plenigo::Offer->createPlenigoOffer('CUSTOMER_ID', 'CUSTOMER_IP_ADDRESS', ((plenigoOfferId => 'OFFER_ID1')));
15 my $checkout_helper = plenigo::CheckoutHelper->new(configuration => $configuration);
16 my $purchase_id = $checkout_helper->getPurchaseId($offer);
17  
18 =head1 DESCRIPTION
19  
20 plenigo::CheckoutHelper provides functionality to prepare a plenigo checkout.
21  
22 =cut
23  
24 use Moo;
25 use Carp qw(confess);
26 use Crypt::JWT qw(encode_jwt);
27 use Data::UUID;
28  
29 our $VERSION = '3.0002';
30  
31 has configuration => (
32 is => 'ro',
33 required => 1
34 );
35  
36 =head1 METHODS
37  
38 =cut
39  
40 =head2 getPurchaseId($offer)
41  
42 Get purchase id necessary for plenigo checkout.
43  
44 =cut
45  
46 sub getPurchaseId {
47 my ($self, $offer) = @_;
48  
49 my $rest_client = plenigo::RestClient->new(configuration => $self->configuration);
50 my %result = $rest_client->post('checkout/preparePurchase', {}, $offer);
51  
52 if ($result{'response_code'} == 404) {
53 plenigo::Ex->throw({ code => 404, message => 'There is no customer for the customer id passed.' });
54 }
55  
56 return %{$result{'response_content'}};
57 }
58  
59 1;