Alipay

Alipay is one of the leading 3rd party service payment provider in China. With more than 450M+ active users, your merchants can accept Alipay wallets by scanning the customer's code with your integrated camera or external barcode scanner.



It's very important for you to make sure to include QR code and baarcode scanning capabilities within your application in order to be able to scan an Alipay customer code. This can be done through your device integrated camera or an external scanner which connects to your device.



In order to accept Alipay as alternative payment method, create MPAccountParameters which will result of the code scanned from the customer’s Alipay mobile. Then provide them to startTransactionWithParameters:


- (IBAction)transaction:(id)sender {
    MPTransactionProvider* transactionProvider =
    [MPMpos transactionProviderForMode:MPProviderModeTEST
                    merchantIdentifier:@"MERCHANT_IDENTIFIER"
                     merchantSecretKey:@"MERCHANT_SECRET_KEY"];
    
    MPTransactionParameters *transactionParameters =
    [MPTransactionParameters chargeWithAmount:[NSDecimalNumber decimalNumberWithString:@"5.00"]
                                     currency:MPCurrencyEUR
                                    optionals:^(id  _Nonnull optionals) {
                                        optionals.subject = @"Bouquet of Flowers"; /*By adding a subject, the shopper will be able to see his transaction on his Alipay app*/

                                        optionals.customIdentifier = @"yourReferenceForTheTransaction";
                                    }];

    MPAccountParameters *accParams = [MPAccountParameters alipayParametersWithShopperIdentifier:@"280615575258203712" source:MPPaymentDetailsSourceQRCode];  /*“12847452” refers to the code scanned.*/

    MPTransactionProcess *process =
    [transactionProvider startTransactionWithParameters:transactionParameters
                                      accountParameters:accParams
                                        	 registered:^(MPTransactionProcess *process,
                                                          MPTransaction *transaction)
     {
         NSLog(@"registered MPTransactionProcess, transaction id: %@", transaction.identifier);
     }
                                          statusChanged:^(MPTransactionProcess *process,
                                                          MPTransaction *transaction,
                                                          MPTransactionProcessDetails *details)
     {
         NSLog(@"%@\n%@", details.information[0], details.information[1]);
     }
     
                                              completed:^(MPTransactionProcess *process,
                                                          MPTransaction *transaction,
                                                          MPTransactionProcessDetails *details)
     {
         NSLog(@"Transaction ended, transaction status is %lu", (unsigned long) transaction.status);
         
         if (details.state == MPTransactionProcessDetailsStateApproved) {
             // Ask the merchant, whether the shopper wants to have a receipt
             // and close the checkout UI
         } else {
             // Allow your merchant to try another transaction
         }
         
         // only close your modal here
     }];
}

In order to generate custom receipts, please make sure you are familiar with our receipt functionality.

Alipay is one of the leading 3rd party service payment provider in China. With more than 450M+ active users, your merchants can accept Alipay wallets by scanning the customer's code with your integrated camera or external barcode scanner.



It's very important for you to make sure to include QR code and barcode scanning capabilities within your application in order to be able to scan an Alipay customer code. This can be done through your device integrated camera or an external scanner which connects to your device.



In order to accept Alipay as alternative payment method, create AccountParameters with .wallet(), alipay() and shopperAccountIdentifier() which will result of the code scanned from the customer’s Alipay mobile app. Then pass along the account parameters to startTransaction:


void transaction() {
    final TransactionProvider transactionProvider = Mpos.createTransactionProvider(this,
            ProviderMode.TEST,
            "MERCHANT_IDENTIFIER",
            "MERCHANT_SECRET_KEY");

    TransactionParameters transactionParameters = new TransactionParameters.Builder()
                                                .charge(new BigDecimal("5.00"), io.mpos.transactions.Currency.EUR)
                                                .subject("Bouquet of Flowers")
                                                .customIdentifier("yourReferenceForTheTransaction")
                                                .build();

    AccountParameters accountParameters = new AccountParameters.Builder()
        						   		.wallet()
        						   		.alipay()
        						   		.shopperAccountIdentifier(PaymentDetailsSource.QR_CODE, "280615575258203712") /*QR code scanned*/
        						   		.build();                                              

    
    TransactionProcess paymentProcess = transactionProvider.startTransaction(transactionParameters, accountParameters,
            new BasicTransactionProcessWithRegistrationListener() {

                @Override
                public void onRegistered(TransactionProcess process,
                                         Transaction transaction) {
                    Log.d("mpos", "transaction identifier is: " + transaction.getIdentifier() + ". Store it in your backend so that you can always query its status.");
                }

                @Override
                public void onStatusChanged(TransactionProcess process ,
                                            Transaction transaction,
                                            TransactionProcessDetails processDetails) {
                    Log.d("mpos", "status changed: " + Arrays.toString(processDetails.getInformation()));
                }

                @Override
                public void onCompleted(TransactionProcess process,
                                        Transaction transaction,
                                        TransactionProcessDetails processDetails) {
                    Log.d("mpos", "completed");

                    if (processDetails.getState() == TransactionProcessDetailsState.APPROVED) {
                            // print the merchant receipt
                            Receipt merchantReceipt = transaction.getMerchantReceipt();
     
                            // ask the merchant, whether the shopper wants to have a receipt
                            Receipt customerReceipt = transaction.getCustomerReceipt();
            		
                            // and close the checkout UI
                    } else {
                        // Allow your merchant to try another transaction
                    }
                }
            });
}

@Override
public void onBackPressed() {
    Toast.makeText(this, "The back button is disabled during a transaction. Please use the 'abort' button to cancel the transaction.", Toast.LENGTH_LONG).show();
}

In order to generate custom receipts, please make sure you are familiar with our receipt functionality.

Can we help you?

If you cannot find your answer, contact us and we'll get in touch with you soon.

© Copyright 2017 Payworks GmbH. Legal.