
public class NormalSheetFragment extends Fragment implements View.OnClickListener {
// ......
private ImageView samsungPayButton;
// ......
private void initView() {
// ......
samsungPayButton = (ImageView) fragmentView.findViewById(R.id.samsungpaybutton);
// SDK Method Test Buttons Listeners
// ......
samsungPayButton.setOnClickListener(this);
// SDK Method Test Buttons
@Override
public void onClick(View v) {
switch (v.getId()) {
//......
case R.id.samsungpaybutton:
samsungPayButton.setVisibility(View.GONE);
startInAppPay();
break;
//......
}
}
private void checkSamsungPayStatus() {
Bundle bundle = new Bundle();
bundle.putString(SamsungPay.PARTNER_SERVICE_TYPE,
SamsungPay.ServiceType.INAPP_PAYMENT.toString());
PartnerInfo partnerInfo = new PartnerInfo(serviceId, bundle);
SamsungPay samsungPay = new SamsungPay(context, partnerInfo);
try {
samsungPay.getSamsungPayStatus(new StatusListener() {
@Override
public void onSuccess(int status, Bundle bundle) {
switch (status) {
case SamsungPay.SPAY_NOT_SUPPORTED:
// Samsung Pay is not supported
samsungPayButton.setVisibility(View.INVISIBLE);
break;
case SamsungPay.SPAY_NOT_READY:
// Activate Samsung Pay or update Samsung Pay, if needed
samsungPayButton.setVisibility(View.INVISIBLE);
break;
case SamsungPay.SPAY_READY:
// Samsung Pay is ready
samsungPayButton.setVisibility(View.VISIBLE);
break;
default:
// Not expected result
samsungPayButton.setVisibility(View.INVISIBLE);
break;
}
}
@Override
public void onFail(int errorCode, Bundle bundle) {
samsungPayButton.setVisibility(View.INVISIBLE);
Log.d(TAG, "checkSamsungPayStatus onFail() : " + errorCode);
}
});
/*
* Thrown if the callback passed is null.
*/
} catch (NullPointerException e) {
e.printStackTrace();
}
}
//......
ArrayList<PaymentManager.Brand> brandList = new ArrayList<>(); // If the supported brand is not specified, all card brands in Samsung Pay are // listed in the Payment Sheet. brandList.add(PaymentManager.Brand.MASTERCARD); brandList.add(PaymentManager.Brand.VISA); brandList.add(PaymentManager.Brand.AMERICANEXPRESS);
Only the list of accepted card brands enrolled in Samsung Pay is then displayed. If supported brands are not specified, all card brands in Samsung Pay are listed in the payment sheet.


and follow the onscreen instructions to add a card. PaymentInfo paymentInfo = new PaymentInfo.Builder() // ...... // Merchant requires billing address from Samsung Pay and sends the shipping address to //Samsung Pay. // Show both billing and shipping address on the payment sheet. .setAddressInPaymentSheet(PaymentInfo.AddressInPaymentSheet.NEED_BILLING_SEND_SHIPPING) // Option is either SEND_SHIPPING or NEED_BILLING_SEND_SHIPPING, shipping address should be set // from merchant app .setShippingAddress(shippingAddress) // ...... .build();








