PayPal支付变量用于post返回url

时间:2015-10-27 20:57:59

标签: paypal paypal-ipn

我目前正在使用PayPal通过API进行付款,如下所示:

<form id="payment" method="post" action= "https://www.sandbox.paypal.com/cgi-bin/webscr">
    <input type="hidden" name="cmd" value="_xclick">
    <input type="hidden" name="currency_code" value="USD">
    <input type="hidden" name="business" value="xxx@yahoo.com">
    <input type="hidden" name="item_name" value="Order">
    <input type="hidden" name="amount" value="1.00">
    <input type="hidden" name="return" value="http://www.example.com/callback" />
    <input type='hidden' name='rm' value='2'>
</form>

https://developer.paypal.com/webapps/developer/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables/#id08A6HI0709B所述,rm设置为2,以便在付款流程后使用POST方法作为返回网址。

但是,返回POST变量没有详细描述,我从chrome获得了一些变量:

mc_gross:1.00
mc_currency:USD

这很容易理解。但变量如:

verify_sign:AIcINKz4gusKUvaiOqo3JiAvlEBFA-7ApBee-2bb5OtUUM5RhVUumd84
auth:AEH3nN1f7cUPFUFS4wPBRv6gOw6CV0BppygOu6y-vRHspA3a-ae-y2BnH1tQds1bwOG4EFqxZrcgNxLXKZdsDWg

我没有发现其含义。可能这应该像加密或校验和?如果是,我该如何检查这些返回变量的验证?

1 个答案:

答案 0 :(得分:1)

这是支付宝付款的一个例子。

PayPalPayment *payment = [[PayPalPayment alloc] init];

payment.amount = [self.paymentAmount decimalNumberByRoundingAccordingToBehavior:roundUp];

payment.currencyCode = @"USD";

self.PayPalReceiverEmail = [[self.photo objectForKey:kPAPPhotoUserKey] objectForKey:kPayPalReceiverEmailKey];

payment.shortDescription = self.PayPalReceiverEmail;

if (([[NSDecimalNumber notANumber] isEqualToNumber:payment.amount] ) ) {
// This particular payment will always be processable. If, for
// example, the amount was negative or the shortDescription was
// empty, this payment wouldn't be processable, and you'd want
// to handle that here.
  UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Please enter a valid amount" message:nil delegate:nil cancelButtonTitle:nil otherButtonTitles:@"Dismiss", nil];
  [alert show];

}
else {
if  (!payment.processable)
{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Payment cannot be processed. Please contact technical support." message:nil delegate:nil cancelButtonTitle:nil otherButtonTitles:@"Dismiss", nil];
    [alert show];
}
else
{
// Any customer identifier that you have will work here. Do NOT use a device- or
// hardware-based identifier.
//self.customerId = @"user-12345";
  self.customerId = [PFUser currentUser].objectId;

// Set the environment:
// - For live charges, use PayPalEnvironmentProduction (default).
// - To use the PayPal sandbox, use PayPalEnvironmentSandbox.
// - For testing, use PayPalEnvironmentNoNetwork.
[PayPalPaymentViewController setEnvironment:self.environment];


  if (self.PayPalReceiverEmail && self.PayPalReceiverEmail.length >0 )
  {
      PayPalPaymentViewController *paymentViewController;

      if (self.PayPalClientId && self.PayPalClientId.length > 0)
      {


   paymentViewController = [[PayPalPaymentViewController alloc] initWithClientId:self.PayPalClientId
                                                                                               receiverEmail:self.PayPalReceiverEmail
                                                                                                     payerId:self.customerId
                                                                                                     payment:payment
                                                                                                    delegate:self];

          paymentViewController.hideCreditCardButton = !self.acceptCreditCards;

            }
    else
    {

       paymentViewController = [[PayPalPaymentViewController alloc] initWithClientId:kPayPalClientId
                                                                                                     receiverEmail:self.PayPalReceiverEmail
                                                                                                           payerId:self.customerId
                                                                                                           payment:payment
                                                                                                          delegate:self];

        paymentViewController.hideCreditCardButton = YES;

    }

// Setting the languageOrLocale property is optional.
//
// If you do not set languageOrLocale, then the PayPalPaymentViewController will present
// its user interface according to the device's current language setting.
//
// Setting languageOrLocale to a particular language (e.g., @"es" for Spanish) or
// locale (e.g., @"es_MX" for Mexican Spanish) forces the PayPalPaymentViewController
// to use that language/locale.

// For full details, including a list of available languages and locales, see PayPalPaymentViewController.h.
paymentViewController.languageOrLocale = @"en";


[self presentViewController:paymentViewController animated:YES completion:nil];