All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.sphere.sdk.orders.commands.updateactions.AddPayment Maven / Gradle / Ivy

There is a newer version: 1.0.0-M26
Show newest version
package io.sphere.sdk.orders.commands.updateactions;

import io.sphere.sdk.commands.UpdateActionImpl;
import io.sphere.sdk.models.Reference;
import io.sphere.sdk.models.Referenceable;
import io.sphere.sdk.orders.Order;
import io.sphere.sdk.payments.Payment;

import java.util.Optional;

/**
 *
 * This action adds a payment to the PaymentInfo. The payment must not be assigned to another Order or active Cart yet.
 *
 * {@doc.gen intro}
 *
 * {@include.example io.sphere.sdk.orders.commands.OrderUpdateCommandTest#addPayment()}
 *
 * @see Payment
 * @see Order#getPaymentInfo()
 * @see RemovePayment
 */
public class AddPayment extends UpdateActionImpl {
    private final Reference payment;

    private AddPayment(final Reference payment) {
        super("addPayment");
        this.payment = payment;
    }

    public static AddPayment of(final Referenceable payment) {
        return new AddPayment(Optional.ofNullable(payment).map(Referenceable::toReference).orElse(null));
    }

    public Reference getPayment() {
        return payment;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy