I am implmenting payment with clover.. using clover sdk I got successful payment response with payment ID but my order ID is null how can I get order ID
I am implmenting payment with clover.. using clover sdk I got successful payment response with payment ID but my order ID is null how can I get order ID
Hi,
I was having the same problem, and I ended up creating the Order by myself, and then passing the Order ID from the newly created order to the Payment application. (via Intents.EXTRAORDERID).
private OrderConnector orderConnector;
private Account account;
private int cardEntryMethodsAllowed = Intents.CARD_ENTRY_METHOD_MAG_STRIPE | Intents.CARD_ENTRY_METHOD_ICC_CONTACT | Intents.CARD_ENTRY_METHOD_NFC_CONTACTLESS | Intents.CARD_ENTRY_METHOD_MANUAL;
@Override
public void onResume() {
super.onResume();
// Retrieve the Clover account
if (account == null) {
account = CloverAccount.getAccount(this);
// If an account can't be acquired, exit the app
if (account == null) {
Toast.makeText(this, "Could not access account", Toast.LENGTH_SHORT).show();
}
}
connect();
}
@Override
public void onPause() {
disconnect();
super.onPause();
}
private void connect() {
disconnect();
if (account != null) {
orderConnector = new OrderConnector(this, account, null);
orderConnector.connect();
}
}
private void disconnect() {
if (orderConnector != null) {
orderConnector.disconnect();
orderConnector = null;
}
}
private class PaymentAsyncTask extends AsyncTask<Void, Void, Order> {
@Override
protected final Order doInBackground(Void... params) {
String orderId = null;
try {
return orderConnector.createOrder(new Order());
} catch (RemoteException e) {
e.printStackTrace();
} catch (ClientException e) {
e.printStackTrace();
} catch (ServiceException e) {
e.printStackTrace();
} catch (BindingException e) {
e.printStackTrace();
}
return null;
}
@Override
protected final void onPostExecute(Order order) {
if(order != null)
{
Intent intent = new Intent(Intents.ACTION_SECURE_PAY);
//EXTRA_AMOUNT is required for secure payment
intent.putExtra(Intents.EXTRA_AMOUNT, amount);
intent.putExtra(Intents.EXTRA_TIP_AMOUNT, tip);
intent.putExtra(Intents.EXTRA_ORDER_ID, order.getId());
//Allow only selected card entry methods
intent.putExtra(Intents.EXTRA_CARD_ENTRY_METHODS, cardEntryMethodsAllowed);
intent.putExtra(Intents.EXTRA_TRANSACTION_NO, postrxno);
dumpIntent(intent);
startActivityForResult(intent, CLOVER_PAYMENT_REQUEST);
}
}
}
1 Person is following this question.