Skip to main content
knowledgecenter.2checkout.com

Use UnionPay

Overview

Place an order with catalog products defined in your Control Panel and collect the payment using UnionPay.

Requirements

Shoppers in China, Macau, Hong Kong, and Singapore, as well as other APAC countries, can purchase using UnionPay. 

Supported currencies

  • CNY
  • USD
  • EUR
  • GBP
  • AUD
  • CAD
  • CHF
  • JPY
  • PLN
  • SEK
  • RUB
  • BRL
  • ZAR

Workflow

  1. If the shopper is paying with any one of the supported currencies, then they can use UnionPay as a payment method in the shopping cart.
  2. After the order is generated by calling the placeOrder method, in the order's details the shopper will find a URL where they need to be redirected in order to finish the payment.
  3. The URL can be found in the PaymentMethod/Redirect response object, under the Redirect attribute. The shopper needs to be redirected to that URL via a provided method (usually a POST call), with the parameters available in the API response sent to the URL in the body of the request.
  4. Once the shopper finishes the payment process on the UnionPay side, the order will be updated in the 2Checkout system as well.

Request Parameters

Parameters Type/Description

sessionID

Required (string)

 

Session identifier, the output of the Login method. Include sessionID into all your requests. 2Checkout throws an exception if the values are incorrect.  The sessionID expires in 10 minutes.

Order

Required (Object)

 

Object designed to collect all data necessary for an order, including billing, product/subscription plan, and payment details.

See the code sample for more details. 

Response Parameters

Parameter Type/Description

Order information

Object

  Object containing order information.

 

Request Example

<?php

require ('PATH_TO_AUTH');

$CartObj = new stdClass();
$CartObj->Currency = 'CNY';
$CartObj->Language = "EN";
$CartObj->Country = 'CN';
$CartObj->CountryCode = 'CN';
$CartObj->CustomerIP = '91.220.121.21';
$CartObj->Source = "sourceAPI.net";
$CartObj->LocalTime = date('Y-m-d H:i:s');
$CartObj->CustomerReference = '421820999';
$CartObj->Items = array();

$CartObj->Items[0] = new stdClass();
$CartObj->Items[0]->Code = '67B4EDC822'
$CartObj->Items[0]->Quantity = 1;

$CartObj->Items[0]->PriceOptions = [];

$priceOption = new stdClass();
$priceOption->Options = [];

$priceOptionOption = new stdClass();
$priceOptionOption->Name = '10 users';
$priceOptionOption->Value = '10_users';
$priceOptionOption->Surcharge = 0;

$priceOption->Options[] = $priceOptionOption;
$CartObj->Items[0]->PriceOptions[] = $priceOption;

$priceOption2 = new stdClass();
$priceOption2->Name = 'Maintenance period';
$priceOption2->Code = 'MAINTE_PERIOD';
$priceOption2->Options = [];

$priceOptionOption2 = new stdClass();
$priceOptionOption2->Name = '12 months';
$priceOptionOption2->Value = 'jira_maintenance_12_mths';
$priceOptionOption2->Surcharge = 0;

$priceOption2->Options[] = $priceOptionOption2;
$CartObj->Items[0]->PriceOptions[] = $priceOption2;

$CartObj->MachineId = 'machineIdTestAlexB';
$CartObj->Discount = null;
$CartObj->ExternalReference = null;

$CartObj->BillingDetails = new stdClass();
$CartObj->BillingDetails->IsCompany = false;
$CartObj->BillingDetails->Address1 = 'Xian Jing Blvd 77';
$CartObj->BillingDetails->Address2 = 'floor 1';
$CartObj->BillingDetails->City = 'Shanghai';
$CartObj->BillingDetails->State = '';
$CartObj->BillingDetails->CountryCode = 'CN';
$CartObj->BillingDetails->Phone = '010-6552-9988';
$CartObj->BillingDetails->Email = 'hujianbing@336699.cn';
$CartObj->BillingDetails->FirstName = 'Hu';
$CartObj->BillingDetails->LastName = 'Jianbing';
$CartObj->BillingDetails->Zip = '334321';


$CartObj->DeliveryDetails = new stdClass();
$CartObj->DeliveryDetails->Address1 = 'Xian Jing Blvd 77';
$CartObj->DeliveryDetails->Address2 = 'floor 1';
$CartObj->DeliveryDetails->City = 'Shanghai';
$CartObj->DeliveryDetails->State = $state;
$CartObj->DeliveryDetails->CountryCode = 'CN';
$CartObj->DeliveryDetails->Phone = '010-6552-9988';
$CartObj->DeliveryDetails->Email = 'hujianbing@336699.cn';
$CartObj->DeliveryDetails->FirstName = 'Hu';
$CartObj->DeliveryDetails->LastName = 'Jianbing';
$CartObj->DeliveryDetails->Zip = '334321';

$CartObj->PaymentDetails = new stdClass();
$CartObj->PaymentDetails->Type = "UNIONPAY";
$CartObj->PaymentDetails->Currency = 'CNY';
$CartObj->PaymentDetails->CustomerIP = '91.220.121.21';

$CartObj->PaymentDetails->PaymentMethod = new stdClass();
$CartObj->PaymentDetails->PaymentMethod->RecurringEnabled = false;


$jsonRpcRequest = array (
'method' => 'placeOrder',
'params' => array($sessionID, $CartObj),
'id' => $i++,
'jsonrpc' => '2.0'
);

var_dump (callRPC((Object)$jsonRpcRequest, $host, true));

 

  • Was this article helpful?