These docs are for v4.0.2. Click to read the latest docs for v4.3.0.

User Address For Payment

Merchants who store customers' billing address information may fill in those details during the customer's checkout process using this API.

📘

API Method

User Address For Payment

🚧

References

SDK Payment Classes
SDK Payment Enums

 

1. Prepare Customer Billing Address Details

To prepare the customer's billing address, refer to the parameters below.

UserBillingAddress userBillingAddress = new UserBillingAddress();
userBillingAddress.setAddress1("300 Raffle Place");
userBillingAddress.setAddress2("#20-01");
userBillingAddress.setAddress3("Raffle place building 101");
userBillingAddress.setCity("Singapore");
userBillingAddress.setCountryCode("SG");
userBillingAddress.setPostalCode("32799");
userBillingAddress.setState("Singapore");
 
UserAddress userAddress = new UserAddressBuilder()
                          .setUserBillingAddress(userBillingAddress)
                          .build();
UserBillingAddress *userBillingAddress = [UserBillingAddress alloc];
userBillingAddress.address1 = @"300 Raffle Place";
userBillingAddress.address2 = @"#20-01";
userBillingAddress.address3 = @"Raffle place building 101";
userBillingAddress.city = @"Singapore";
userBillingAddress.countryCode = @"SG";
userBillingAddress.postalCode = @"32799";
userBillingAddress.state = @"Singapore";
 
UserAddress *userAddress = [[[UserAddressBuilder alloc]
                              userBillingAddress: userBillingAddress]
                              build];
let userBillingAddress: UserBillingAddress = UserBillingAddress()
userBillingAddress.address1 = "300 Raffle Place"
userBillingAddress.address2 = "#20-01"
userBillingAddress.address3 = "Raffle place building 101"
userBillingAddress.city = "Singapore"
userBillingAddress.countryCode = "SG"
userBillingAddress.postalCode = "32799"
userBillingAddress.state = "Singapore"
         
let userAddress: UserAddress = UserAddressBuilder()
                               .userBillingAddress(userBillingAddress)
                               .build()

 

2. Construct Payment Request

Set the user address in the request

PaymentCode paymentCode = new PaymentCode("CC");
 
PaymentRequest paymentRequest = new CardPaymentBuilder(paymentCode, "4111111111111111")
                                .setExpiryMonth(12)
                                .setExpiryYear(2022)
                                .setSecurityCode("123")
                                .setUserAddress(userAddress)
                                .build();
PaymentCode *paymentCode = [[PaymentCode alloc] initWithChannelCode: @"CC"];
 
PaymentRequest *paymentRequest = [[[[[[[CardPaymentBuilder alloc] initWithPaymentCode: paymentCode cardNo: @"4111111111111111"]
                                        expiryMonth: 12]
                                        expiryYear: 2022]
                                        securityCode: @"123"]
                                        userAddress: userAddress]
                                        build];
let paymentCode: PaymentCode = PaymentCode(channelCode: "CC")
 
let paymentRequest: PaymentRequest = CardPaymentBuilder(paymentCode: paymentCode, "4111111111111111")
                                     .expiryMonth(12)
                                     .expiryYear(2022)
                                     .securityCode("123")
                                     .userAddress(userAddress)
                                     .build()

 

3. Construct Payment Transaction Request

TransactionResultRequest transactionResultRequest = new TransactionResultRequestBuilder(paymentToken)
                                                    .with(paymentRequest)
                                                    .build();
TransactionResultRequest *transactionResultRequest = [[[[TransactionResultRequestBuilder alloc] initWithPaymentToken: paymentToken]
                                                         withPaymentRequest: paymentRequest]
                                                         build];
let transactionResultRequest: TransactionResultRequest = TransactionResultRequestBuilder(paymentToken: paymentToken)
                                                         .with(paymentRequest)
                                                         .build()

 

Full Sample Code

The following sample code demonstrates parameters and requests for each step of the process.

//Step 1: Construct customer billing address information.
UserBillingAddress userBillingAddress = new UserBillingAddress();
userBillingAddress.setAddress1("300 Raffle Place");
userBillingAddress.setAddress2("#20-01");
userBillingAddress.setAddress3("Raffle place building 101");
userBillingAddress.setCity("Singapore");
userBillingAddress.setCountryCode("SG");
userBillingAddress.setPostalCode("32799");
userBillingAddress.setState("Singapore");
 
UserAddress userAddress = new UserAddressBuilder()
                          .setUserBillingAddress(userBillingAddress)
                          .build();
 
//Step 2: Construct payment request and add user address into request.
PaymentCode paymentCode = new PaymentCode("CC");
 
PaymentRequest paymentRequest = new CardPaymentBuilder(paymentCode, "4111111111111111")
                                .setExpiryMonth(12)
                                .setExpiryYear(2022)
                                .setSecurityCode("123")
                                .setUserAddress(userAddress)
                                .build();
 
//Step 3: Construct transaction request.
TransactionResultRequest transactionResultRequest = new TransactionResultRequestBuilder(paymentToken)
                                                    .with(paymentRequest)
                                                    .build();
//Step 1: Construct customer billing address information.
UserBillingAddress *userBillingAddress = [UserBillingAddress alloc];
userBillingAddress.address1 = @"300 Raffle Place";
userBillingAddress.address2 = @"#20-01";
userBillingAddress.address3 = @"Raffle place building 101";
userBillingAddress.city = @"Singapore";
userBillingAddress.countryCode = @"SG";
userBillingAddress.postalCode = @"32799";
userBillingAddress.state = @"Singapore";
 
UserAddress *userAddress = [[[UserAddressBuilder alloc]
                              userBillingAddress: userBillingAddress]
                              build];
 
//Step 2: Construct payment request and add user address into request.
PaymentCode *paymentCode = [[PaymentCode alloc] initWithChannelCode: @"CC"];
 
PaymentRequest *paymentRequest = [[[[[[[CardPaymentBuilder alloc] initWithPaymentCode: paymentCode cardNo: @"4111111111111111"]
                                        expiryMonth: 12]
                                        expiryYear: 2022]
                                        securityCode: @"123"]
                                        userAddress: userAddress]
                                        build];
 
//Step 3: Construct transaction request.
TransactionResultRequest *transactionResultRequest = [[[[TransactionResultRequestBuilder alloc] initWithPaymentToken: paymentToken]
                                                         withPaymentRequest: paymentRequest]
                                                         build];
//Step 1: Construct customer billing address information.
let userBillingAddress: UserBillingAddress = UserBillingAddress()
userBillingAddress.address1 = "300 Raffle Place"
userBillingAddress.address2 = "#20-01"
userBillingAddress.address3 = "Raffle place building 101"
userBillingAddress.city = "Singapore"
userBillingAddress.countryCode = "SG"
userBillingAddress.postalCode = "32799"
userBillingAddress.state = "Singapore"
         
let userAddress: UserAddress = UserAddressBuilder()
                               .userBillingAddress(userBillingAddress)
                               .build()
    
//Step 2: Construct payment request and add user address into request.
let paymentCode: PaymentCode = PaymentCode(channelCode: "CC")
 
let paymentRequest: PaymentRequest = CardPaymentBuilder(paymentCode: paymentCode, "4111111111111111")
                                     .expiryMonth(12)
                                     .expiryYear(2022)
                                     .securityCode("123")
                                     .userAddress(userAddress)
                                     .build()
         
//Step 3: Construct transaction request.
let transactionResultRequest: TransactionResultRequest = TransactionResultRequestBuilder(paymentToken: paymentToken)
                                                         .with(paymentRequest)
                                                         .build()