Requesting a Payment {#samsungpay-requesting-payment}
=====================================================

1. Use the `startSamsungPay()` API method in the `PaymentManager` class. The `PaymentManager` class includes the following API methods:

   #### ADDITIONAL INFORMATION

   * `startSamsungPay()`---requests to initiate payment with Samsung Pay.
   * `updateAmount()`---updates the transaction amount if shipping address or card information is updated by Samsung Pay.
   * `updateAmountFailed()`---returns an error code when the new amount cannot be updated because of a wrong address.
2. Request the `startSamsungPay()` API method and include the following data:

   #### ADDITIONAL INFORMATION

   * `PaymentInfo`---contains payment information.
   * `PID`---the product ID created in the Samsung Pay Partner Portal.
   * `StatusListener`---the result of the payment request is delivered to `StatusListener`. This listener should be registered before you call the `startSamsungPay()` API method.

   When you request the `startSamsungPay()` API method, the Samsung Pay online payment sheet is displayed on your application. The customer selects a registered card for payment and can also update the billing and shipping address.  
   The payment reply is delivered as one of the following events to `StatusListener`:

   * `onSuccess()`---this event is requested when Samsung Pay confirms the payment. It includes `encryptedPaymentCredential` in JSON format:
     * **method:** Payment protocol: 3-D Secure.
     * **merchant_ref:** Merchant reference code.
     * **billing_address.street**: Number, street name.
     * **billing_address.state_province:** Two-letter state code.
     * **billing_address.zip_postal_code:** Five-character zip code.
     * **billing_address.city:** City name.
     * **billing_address.county:**Two-letter country code.
     * **3ds.type:** `S` for Samsung Pay. Encrypted.
     * **3ds.version:** Current version `100`. Encrypted.
     * **3ds.data:** Base64-encoded payment data. Encrypted.
       {#samsungpay-requesting-payment_ul_wd1_dhr_2pb} Refer to the Samsung Pay developer website for information on how to decrypt the encrypted payment credential.

* `onFailure()`---this event is requested when the transaction fails. It returns an error code and error message.

Example: Request startSamsungPay() API Method {#samsungpay-ex-req-startsp-method}
=================================================================================

```
public void onPayButtonClicked(View v) {
    // Call startSamsungPay() method of PaymentManager class.
    // To create a transaction request for makeTransactionDetails() in
    the following code, see Example: Transaction Request Structure.
    try {
        mPaymentManager.startSamsungPay(makeTransactionDetails(), "enter
        product ID",
mStatusListener);
    } catch (NullPointerException e) {
    e.printStackTrace();
    }
}

private PaymentManager.StatusListener mStatusListener = new
PaymentManager.StatusListener() {
    @Override
    public void onFailure(int errCode, String msg) {
        Log.d(TAG, " onFailed );
    }
    @Override
    public void onSuccess(PaymentInfo arg0, String result) {
        Log.d(TAG, "onSuccess ");
    };                        
```

