Yuansfer DOCS
  • Introduction
  • GUIDE
    • Online Payment
    • Point of Sale
      • Scan QR Code
      • Create QR Code
    • Plugins
    • Payment Methods
    • Financial Report
    • Security
    • Incident Priorities
    • SDK
    • Tutorials & Examples
      • PHP SDK
      • JAVA SDK
      • C# SDK
      • JS SDK
  • API REFERENCE V3
    • Sandbox Environment
      • Apply Sandbox Credentials
    • Signing API Parameters
    • Customers
      • Register Customer
      • Retrieve Customer
      • Update Customer
    • Payments
      • Online Payment
        • Yuansfer Checkout
        • Yuansfer Integrated Payment
          • Braintree Payments
          • Prepay
        • Recurring Payments
          • Authorize
          • Apply Token
          • Pay
          • Revoke
      • Point of Sale Payment
        • Scan QR Code
          • Add
          • Prepay
        • Create QR Code
    • Transaction Revert
      • Refund
      • Cancel
    • Transaction Data Search
      • Transaction Query
    • Payouts
      • Create Payee
      • Retrieve Payee
      • Balance
      • Send Money
      • Search Payments
    • Notes
  • 中文
Powered by GitBook
On this page

Was this helpful?

  1. API REFERENCE V3
  2. Payments
  3. Online Payment
  4. Yuansfer Integrated Payment

Prepay

Referred to as prepay

Prepay

POST https://mapi.yuansfer.com/micropay/v3/prepay

This API does the mobile payment for the In-APP and/or WeChat Mini program solutions.

Request Body

Name
Type
Description

merchantNo*

string

Merchant ID

storeNo*

string

Store ID

amount*

number

The price amount.

currency*

number

The supported transaction currency is "USD", "CNY".

settleCurrency*

string

The supported settlement currency is "USD".

vendor*

string

The possible payment channels are "alipay", "wechatpay".

ipnUrl*

string

The instant Payment Notification Handler URL. IPN URL must be secure.

openid

string

openid from WeChat, which is only needed for the Wechat Mini-Program.

reference*

string

The Invoice Number of the transaction in the merchant's system.

terminal*

string

The possible values are: "MINIPROGRAM", "APP".

description

string

The description of the transaction which will be displayed on the invoice.

note

string

The payment note.

timeout

integer

The timeout in minutes. The default value is 120.

verifySign*

string

The parameter signature.

{
    "result": {
        "nonceStr": "QyGptpsnpbydUzdVvkJy5fysWHYO48uF",
        "package": "prepay_id=wx131236528509476a97469b574a5ea30000",
        "paySign": "F2BB1584CB384DC008C665BD19FBB736BF24F1727CEB01159F9BEFA1162A61B7",
        "signType": "HMAC-SHA256",
        "timeStamp": "1602563859"
    },
    "ret_msg": " prepay success",
    "ret_code": "000100"
}

Response

Parameter

Type

Description

result

object

The wechat-mini result object.

The wechat-app result object.

The alipay-app result object.

ret_msg

string

The response return message.

ret_code

string

wehcat-mini result object

Parameter

Type

Description

timeStamp

string

The timestamp.

nonceStr

string

A random string.

package

string

prepay_id information.

signType

string

The signature type.

paySign

string

The signature.

wechat-app result object

Parameter

Type

Description

appid

string

The App Id.

noncestr

string

A random string.

package

string

The value is 'Sign=WXPay'.

partnerid

string

partnerid information.

prepayid

string

prepay_id information.

sign

string

The signature.

timestamp

string

The timestamp.

alipay-app result object

Parameter

Type

Description

payInfo

string

The payment information.

curl -XPOST -H "Content-type: application/json" -d '{
    "merchantNo": "200043",
    "storeNo": "300014",
    "verifySign": "09f722178f6cf2e71c9dfdd664e8663b",
    "amount": "10",
    "currency": "CNY",
    "settleCurrency": "USD",
    "ipnUrl": "http://zk-tys.yunkeguan.com/login/test",
    "reference": "test2020101302",
    "description": "司机支付会员费用",
    "vendor": "wechatpay",
    "terminal": "MINIPROGRAM",
    "openid": "ocBgh5fnabrf-pxPgCWXlq2mOvG8"
}' 'https://mapi.yuansfer.com/micropay/v3/prepay'
<?php
    function microprepay()
    {
        $url = 'https://mapi.yuansfer.com/micropay/v3/prepay';
        $token = '5cbfb079f15b150122261c8537086d77a';
        $params = [
            'merchantNo' => '200043',
            'storeNo' => '300014',
            'amount' => '0.01',
            'currency' => 'USD',
            'settleCurrency' => 'USD',
            'vendor' => 'wechatpay',
            'ipnUrl' => 'https://nengjtian.s1.natapp.cc/login/test',
            'reference' => 'test2018070101',
            'description' => 'test_description',
            'note' => 'test_note',
            'openid' => '***'
        ];
        ksort($params, SORT_STRING);
        $str = '';
        foreach ($params as $k => $v) {
            $str .= $k . '=' . $v . '&';
        }
        $params['verifySign'] = md5($str . md5($token));
        echo 'verifySign:', $params['verifySign'];
        echo "\n";
        $ch = curl_init($url);
        curl_setopt_array($ch, array(
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_HEADER => false,
            CURLOPT_POST => true,
            CURLOPT_POSTFIELDS => http_build_query($params),
        ));
        $result = curl_exec($ch);
        curl_exec($ch);
        echo $result;
        echo "\n";
        return json_decode($result, true);
    }
    microprepay();
?>
public class MicropayTest {

    public static final String TEST_URL = "https://mapi.yuansfer.yunkeguan.com";            //testing domain
    public static final String PROD_URL = "https://mapi.yuansfer.com";                      //production domain
    public static final String YUANSFER_TOKEN = "5c5fe30183be69fceff8174358d4b8ae";


    public static void main(String[] args) {
        YuansferVerifySignHelper helper = new YuansferVerifySignHelper();

        AppMircopayDto dto = paramSetting();
        Map<String, Object> params = ReflectionUtils.convertBean2MapIgnoreNullVal(dto, new String[]{"serialVersionUID"});
        String verifySign = helper.getYuansferVerifySign(params, YUANSFER_TOKEN);
        params.put("verifySign", verifySign);

        String url = TEST_URL + "/micropay/v2/prepay";
        String ret = HttpClientUtils.post(url, null, params);
        System.out.println(ret);
    }

    public static AppMircopayDto paramSetting() {
        AppMircopayDto dto = new AppMircopayDto();
        /**
         * merchantNo,storeNo is necessory, and they are provided by Yuansfer
         */
        dto.setMerchantNo("200043");                                                //The Merchant NO.
        dto.setStoreNo("300014");                                                   //The Store NO.

        /**
         * transaction infomation is necessory
         */
        dto.setAmount("0.01");                                                      //The amount, unit "division"
        dto.setCurrency("USD");                                                     //currency, "USD"
        dto.setSettleCurrency("USD");                                               //SettleCurrency, "USD"
        dto.setIpnUrl("https://nengjtian.s1.natapp.cc/login/test");                 //Asynchronous callback address
        dto.setReference("9091023122");                                             //order NO. of client's system
        dto.setOpenid("***");                                                       //wechat openid
        dto.setVendor("wechatpay");                                                 //"wechatpay"

        /**
         * note,desription are optional
         */
        dto.setDescription("test-description");                                     //description
        dto.setNote("test-note");                                                   //note

        return dto;
    }
}
func mciropay(t *table) {
    req := yuan.Securepay{
        MerchantNo:        "200043", //customer The merchant NO.
        StoreNo:           "300014",
        Currency:          "USD",
        SettleCurrency:    "USD",
        Amount:            "0.01",
        Vendor:            "wechatpay",
        Reference:         fmt.Sprintf("demo_%d", time.Now().Unix()), //sequence number of customer system
        IpnUrl:            "https://customer-ipn",        //internet accessible
        Description:       "description",
        Note:              "note",
        Openid:            "***",
    }
    resp, err := req.PostToYuansfer(yuansferToken)
    if err != nil {
        fmt.Println(err)
        return
    }
    fmt.Println(resp)
}
PreviousBraintree PaymentsNextRecurring Payments

Last updated 2 years ago

Was this helpful?

The response return code. For more details, see .

here