public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { fragmentView = inflater.Inflate(Resource.Layout.activity_main, container, false); Button proceedButton = (Button)fragmentView.FindViewById(Resource.Id.proceed_button); proceedButton.Click += (s, e) => { paymentSetupRequest = buildPaymentRequest(fragmentView); paymentRequestListener.onPaymentRequested(paymentSetupRequest); }; return(fragmentView); }
private PaymentSetupRequest buildPaymentRequest(View view) { PaymentSetupRequest paymentRequest = new PaymentSetupRequest(); String amountValueString = ((EditText)view.FindViewById(Resource.Id.orderAmountEntry)).Text.ToString(); String amountCurrencyString = ((EditText)view.FindViewById(Resource.Id.orderCurrencyEntry)).Text.ToString(); paymentRequest.setAmount(new Amount(AmountUtil.ParseMajorAmount(amountCurrencyString, amountValueString), amountCurrencyString)); paymentRequest.setCountryCode(((EditText)view.FindViewById(Resource.Id.countryEntry)).Text.ToString()); paymentRequest.setShopperLocale(((EditText)view.FindViewById(Resource.Id.shopperLocaleEntry)).Text.ToString()); paymentRequest.setShopperIP(((EditText)view.FindViewById(Resource.Id.shopperIpEntry)).Text.ToString()); paymentRequest.setMerchantAccount(((EditText)view.FindViewById(Resource.Id.merchantAccountEntry)).Text.ToString()); paymentRequest.setMerchantReference(((EditText)view.FindViewById(Resource.Id.merchantReferenceEntry)).Text.ToString()); paymentRequest.setPaymentDeadline(((EditText)view.FindViewById(Resource.Id.paymentDeadlineEntry)).Text.ToString()); paymentRequest.setReturnURL(((EditText)view.FindViewById(Resource.Id.returnUrlEntry)).Text.ToString()); return(paymentRequest); }
public void onPaymentRequested(PaymentSetupRequest paymentSetupRequest) { merchantServerUrl = TextUtils.IsEmpty(merchantServerUrl) ? SERVER_URL : merchantServerUrl; merchantApiSecretKey = TextUtils.IsEmpty(merchantApiSecretKey) ? API_KEY : merchantApiSecretKey; merchantApiHeaderKeyForApiSecretKey = TextUtils.IsEmpty(merchantApiHeaderKeyForApiSecretKey) ? API_HEADER_KEY : merchantApiHeaderKeyForApiSecretKey; if (TextUtils.IsEmpty(merchantApiSecretKey) || TextUtils.IsEmpty(merchantApiHeaderKeyForApiSecretKey) || TextUtils.IsEmpty(merchantServerUrl)) { //Toast.makeText(getApplicationContext(), "Server parameters have not been configured correctly", Toast.LENGTH_SHORT).show(); return; } this.paymentSetupRequest = paymentSetupRequest; if (paymentRequest != null) { paymentRequest.Cancel(); } paymentRequest = new PaymentRequest(this, this, paymentRequestDetailsListener); paymentRequest.Start(); }