1. Check out our companion app, Forums for Android! Download from Google Play

android paypal invoice order with more than one item

Discussion in 'Application Development' started by krishnaveni, Jan 25, 2013.

  1. krishnaveni

    krishnaveni Well-Known Member
    Thread Starter
    55

    Dec 16, 2011
    158
    0
    55
    chennai
    Hi.,

    I have to develop one Android shopping cart application with Paypal payment integration.

    Here I have to pass the product title, qty ,price to Paypal.

    Here I have to run the Android application and add the 2 product means the last added product detail only pass to Paypal.

    How can I pass all the added product detail is send to Paypal.

    This is my code:

    [HIGH]
    private PayPalPayment payWithPaypal() {
    PayPalPayment newPayment = new PayPalPayment();
    BigDecimal sPrice = new BigDecimal(total);
    newPayment.setSubtotal(sPrice);
    newPayment.setCurrencyType("USD");
    newPayment.setRecipient("mercy._1357640918_biz@gmail.com");
    newPayment.setMerchantName("My Merchant");
    newPayment.setPaymentType(PayPal.PAYMENT_TYPE_GOODS);

    PayPalInvoiceData invoice = new PayPalInvoiceData();
    invoice.setTax(new BigDecimal("1.25"));
    invoice.setShipping(new BigDecimal("4.50"));

    PayPalInvoiceItem item1 = new PayPalInvoiceItem();

    StringBuffer sb = new StringBuffer();
    sb.append("<html><body><table>");

    for (int i = 0; i < Constants.mItem_Detail.size(); i++) {

    String title = Constants.mItem_Detail.get(i).get(SingleMenuItem.KEY_PNAME);

    String qty = Constants.mItem_Detail.get(i).get(SingleMenuItem.KEY_QTY);

    String cost = Constants.mItem_Detail.get(i).get(SingleMenuItem.KEY_PRICE);

    String total = Constants.mItem_Detail.get(i).get(SingleMenuItem.KEY_TOTAL);

    total_count=total_count+Integer.parseInt(qty);
    item1.setName(title);
    item1.setQuantity(total_count);
    item1.setUnitPrice(new BigDecimal(cost));
    item1.setTotalPrice(new BigDecimal(total));
    }

    sb.delete(0, sb.length());
    invoice.getInvoiceItems().add(item1);
    newPayment.setInvoiceData(invoice);

    newPayment.setDescription("Quite a simple payment");
    newPayment.setCustomID("8873482296");
    newPayment.setIpnUrl("http://www.exampleapp.com/ipn");
    newPayment.setMemo("Hi! I'm making a memo for a simple payment.");

    Intent paypalIntent = PayPal.getInstance().checkout(newPayment, this);
    this.startActivityForResult(paypalIntent, 1);

    return newPayment;
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    switch(resultCode) {
    case Activity.RESULT_OK:
    String payKey = data.getStringExtra(PayPalActivity.EXTRA_PAY_KEY);
    Toast.makeText(this,"Payment Successful",Toast.LENGTH_LONG).show();
    Intent intent = new Intent(PayPalIntegrationActivity.this,InvoiceOrder.class);

    intent.putExtra("GrandTotal", total);
    intent.putExtra("Title",status);

    startActivity(intent);
    break;
    case Activity.RESULT_CANCELED:
    Toast.makeText(this,"Payment Cancel",Toast.LENGTH_LONG).show();
    break;
    case PayPalActivity.RESULT_FAILURE:
    Toast.makeText(this,"Payment Failed",Toast.LENGTH_LONG).show();
    String errorID = data.getStringExtra(PayPalActivity.EXTRA_ERROR_ID);
    String errorMessage = data.getStringExtra(PayPalActivity.EXTRA_ERROR_MESSAGE);
    break;
    }
    }
    public interface PayPalResultDelegate{
    void onPaymentSucceeded(String payKey, String paymentStatus);
    void onPaymentFailed(String paymentStatus, String correlationID,
    String payKey, String errorID, String errorMessage);
    void onPaymentCanceled(String paymentStatus);
    }
    }
    [/HIGH]
     

    Advertisement

  2. krishnaveni

    krishnaveni Well-Known Member
    Thread Starter
    55

    Dec 16, 2011
    158
    0
    55
    chennai
    Hi.,

    I have to sent the more than one item detail to paypal.

    I have used below code:
    Here i have to run the app means am getting following output:

    <html><body><table><tr><td>java books</td><td>2 *30.00</td>= <td>60.00</td></tr><tr><td>android books</td><td>1*65.00</td>= <td>65.00</td></tr>


    But i need the o/p like table format:

    Java books 2 30.00 60.00
    Android books 1 65.00 65.00


    How can i do????

    please help me...
     

Share This Page

Loading...