Amazon-MWS

 view release on metacpan or  search on metacpan

lib/Amazon/MWS/Uploader.pm  view on Meta::CPAN

                                                  {
                                                   shipping_confirmation_error => "$fault->{code} $fault->{error}",
                                                  },
                                                  {
                                                   amazon_order_id => $ord,
                                                   shipping_confirmation_job_id => $job_id,
                                                   shop_id => $self->_unique_shop_id,
                                                  }));
        }
        else {
            # this looks good
            $self->_exe_query($self->sqla->update('amazon_mws_orders',
                                                  {
                                                   shipping_confirmation_ok => 1,
                                                  },
                                                  {
                                                   amazon_order_id => $ord,
                                                   shipping_confirmation_job_id => $job_id,
                                                   shop_id => $self->_unique_shop_id
                                                  }));
        }

lib/Amazon/MWS/Uploader.pm  view on Meta::CPAN

=head2 register_ship_order_errors($job_id, $result);

Same arguments as above, but for shipping notifications.

=cut

sub register_errors {
    my ($self, $job_id, $result) = @_;
    # first, get the list of all the skus which were scheduled for this job
    # we don't have a products hashref anymore.
    # probably we could parse back the produced xml, but looks like an overkill.
    # just mark them as redo and wait for the next cron call.
    my @products = $self->skus_in_job($job_id);
    my $errors = $result->skus_errors;
    my @errors_with_sku = grep { $_->{sku} } @$errors;
    # turn it into an hash
    my %errs = map { $_->{sku} => {job_id => $job_id, code => $_->{code}, error => $_->{error}} } @errors_with_sku;

    foreach my $sku (@products) {
        if ($errs{$sku}) {
            $self->_exe_query($self->sqla->update('amazon_mws_products',

lib/Amazon/MWS/Uploader.pm  view on Meta::CPAN

                }
            }
            elsif ($report->{shipping_confirmation_job_id}) {
                print "Skipping ship-confirm for order $report->{amazon_order_id} $report->{shop_order_id}: pending\n";
            }
            else {
                push @orders_to_notify, $ord;
            }
        }
        else {
            die "It looks like you are trying to send a shipping confirmation "
              . " without prior order acknowlegdement. "
                . "At least in the amazon_mws_orders there is no trace of "
                  . "$report->{amazon_order_id} $report->{shop_order_id}";
        }
    }
    return unless @orders_to_notify;
    my $feed_content = $self->shipping_confirmation_feed(@orders_to_notify);
    # here we have only one feed to upload and check
    my $job_id = $self->prepare_feeds(shipping_confirmation => [{
                                                                 name => 'shipping_confirmation',

lib/Amazon/MWS/XML/OrderlineItem.pm  view on Meta::CPAN



sub currency {
    return shift->ItemPrice->{CurrencyCode};
}

=head2 price

Amazon report the item price's as the sum of the items, not the
individual price. So we have to do a division for what we know as the
item's price. This looks ugly anyway.

From
L<http://docs.developer.amazonservices.com/en_US/orders/2013-09-01/Orders_ListOrderItems.html>:

The selling price of the order item. Note that an order item is an
item and a quantity. This means that the value of ItemPrice is equal
to the selling price of the item multiplied by the quantity ordered.
Note that ItemPrice excludes ShippingPrice and GiftWrapPrice.

=cut

t/shipping-confirmation.t  view on Meta::CPAN

                       merchant_order_item_code => 1234567,
                       merchant_fulfillment_item_id => 1234567,
                       quantity => 2,
                      },
                     ],
           );

$shipped_order = Amazon::MWS::XML::ShippedOrder->new(%shipped);
is_deeply ([ split(/\n/, $uploader->shipping_confirmation_feed($shipped_order)) ],
           [ split(/\n/, $expected) ],
           "Feed looks ok");



( run in 0.329 second using v1.01-cache-2.11-cpan-64827b87656 )