io.sphere.sdk.carts.commands.updateactions.AddPayment Maven / Gradle / Ivy
package io.sphere.sdk.carts.commands.updateactions;
import io.sphere.sdk.carts.Cart;
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.carts.commands.CartUpdateCommandTest#addPayment()}
*
* @see Payment
* @see Cart#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