Go Back   Android Forums > Android Development > Application Development
Application Development Dev Lounge for the Coder Folks
Gamers - Check out our new sister sites!
Nintendo Wii U!    |    OUYA - $99 Android System!

test: Reply
 
LinkBack Thread Tools
Old January 25th, 2013, 10:28 PM   #1 (permalink)
Member
Thread Author (OP)
 
Join Date: Dec 2011
Location: chennai
Posts: 150
 
Device(s):
Carrier: Not Provided

Thanks: 1
Thanked 0 Times in 0 Posts
Default android paypal invoice order with more than one item

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:

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);
    }
}

krishnaveni is offline  
Reply With Quote
Sponsors
Old January 28th, 2013, 06:47 AM   #2 (permalink)
Member
Thread Author (OP)
 
Join Date: Dec 2011
Location: chennai
Posts: 150
 
Device(s):
Carrier: Not Provided

Thanks: 1
Thanked 0 Times in 0 Posts
Default

Hi.,

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

I have used below code:
Quote:
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);


StringBuffer buffer = sb.append("<tr>" + "<td>" + title
+ "</td><td>" + qty + " * " + cost
+ "</td>" + " = <td>" + total
+ " " + "</td></tr>");


item1.setName(buffer.toString());
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...
krishnaveni is offline  
Last edited by krishnaveni; January 28th, 2013 at 06:47 AM. Reason: add more content
Reply With Quote
Reply
Tags
android, invoice, invoice application, invoices, java, paypal, paypal on mobile, paypal personal payments, paypal-sandbox


Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 10:16 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.